お知らせ

現在サイトのリニューアル作業中のため、全体的にページの表示が乱れています。
投稿日:
ソフトウェア::Stable Diffusion

Automatic 1111よりいいらしいので使ってみる。

日本語表示が面倒だったので、途中から表示言語を英語に変えている。

確認環境

Env Ver
ComfyUI v0.3.38

導入方法

インストール

公式サイトからインストーラーをダウンロードして実行するだけ。

Cドライブにしか対応してないらしいが、モデルや出力先は変更可能なので、インストールパスはそのままでよい。

モデルパスの変更方法

  1. ComfyUIのインストール先を開く
    標準はここ:%HOMEPATH%\AppData\Local\Programs\@comfyorgcomfyui-electron\resources\ComfyUI
  2. extra_model_paths.yaml.exampleextra_model_paths.yamlにリネームする
  3. 以下のコメントアウトをコピペして適当に治す。is_default: trueのコメントを外して有効化しておく
    #comfyui:
    #     base_path: path/to/comfyui/
    #     # You can use is_default to mark that these folders should be listed first, and used as the default dirs for eg downloads
    #     #is_default: true
    #     checkpoints: models/checkpoints/
    #     clip: models/clip/
    #     clip_vision: models/clip_vision/
    #     configs: models/configs/
    #     controlnet: models/controlnet/
    #     diffusion_models: |
    #                  models/diffusion_models
    #                  models/unet
    #     embeddings: models/embeddings/
    #     loras: models/loras/
    #     upscale_models: models/upscale_models/
    #     vae: models/vae/
    

出力先の変更方法

paste-image-2025-59-14_16-58-41-221.png

設定→サーバー設定の一番下にある「出力ディレクトリ」を設定する。

paste-image-2025-59-14_17-58-55-654.png

画像の保存ノードのファイル名プレフィックスをクリックし、Valueにフォルダ名/任意の文字列をつけることでフォルダわけもできる。フォルダ名/だけ指定してもうまくいかないので注意。

ClipSkipの設定(不明)

paste-image-2025-49-14_17-48-35-338.png

CLIP Set Last LayerノードをLoad Checkpointに接続することで実現できるらしい?

Hires.fixの設定

paste-image-2025-35-14_17-34-6-915.png

KSampler→Upscale Latent By→KSampler→VAEで繋ぐと同様のことができるらしい。

感想

起動が早い

1111は1分近くかかるがComfyは数秒で起動するため、ここはいいと思った。

保存先を柔軟に変更できる

1111では基本的に生成種別、日付別に保存されるため整理が手間である。

画像の生成品質を上げる方法がわからなかった

a_00014_.png
a_00015_.png

これはConmfy UIを以下の構成にして生成したものだ。

paste-image-2025-49-14_17-48-19-287.png

一枚目はこういう絵柄だといえばまだありかもしれないが、二枚目は微妙だ。これはどうもHires.fix相当の機能が期待通りに動いていないのが理由に見えるが、恐らくそういった事柄を探求するモチベーションがないと、上手いこと使えないと思われる。

また上記のノード接続だと生成速度も速いとは言えず、これ以上要素を増やすとなると実用性は怪しいと感じた。

現状はまだ1111で十分

1111-hirefix_31sec.png

1111だとこのくらいのものがパッと出てくるため、個人的には今のところ1111でいいかなと思った。カリカリにチューニングすることで1111を超えてくる可能性は否定できないが、大抵のケースで設定値は固定であり、プログラマブルである必要性はアニメーションとかの分野になってくると思われるので、動画を作るならComfy、そうでなければ1111で十分な気がした。

投稿日:
ソフトウェア::Stable Diffusion

SDXLでキャラクターLoraをいい感じに作る方法。学習には教師画像のみを用いる。

必要なもの

やり方

1. 学習用の素材となる画像を集める

学習画像の枚数・パターン

多ければ多いほどいいが、多すぎると学習に時間がかかりすぎるので、ある程度選別する。

例えば3Dキャラクターを学習する場合は、1ポーズ当たり正面・斜め前・横・斜め後ろ・真後ろの流れで一周八面の画像をいくつかのポーズ分作っておくと再現性が高くなる。

奇麗な画像があまりとれない場合は、極力そのキャラクターの特徴が出ている画像を数枚集める。4枚とかでもいい。1枚は試したことないのでどうなるのか不明。

学習素材となる画像の選定

学習元画像には背景が入っていてもいいが、そのキャラクターだけが映り込んでいるものを選ぶ。ほかのキャラクターが入っていたらトリミングするなどで消したほうが良い。

2. 学習用の素材画像にタグを打つ

  1. AUTOMATIC1111を起動し、Tagger→Batch from directoryを開く
  2. Additional tagsにキャラクターを出すためのトリガーワードを設定
    • 既存のタグと衝突するとぶれるはずなので、一意な名前にする。例えば今井リサならimlsみたいに、とりあえず自分で識別できそうな適当な文字列を当てておく

3. タグファイルを整理する

前項で1画像ファイルに対して1タグファイルができているので、このファイルの内容を整理していく。

まずはゴミワードを探して取り除く。大抵複数ファイルに跨っているので一括置換するのがいい。

次に固定要素を取り除く。例えば髪型や髪の色、瞳の色、アクセサリーの特徴みたいな、何があっても変わらない部分は消す。例えば紫目のキャラクターならpurple eyesを、ヘアアクセサリが特徴的なキャラクターであればhair ornamentを消すといった感じだ。残したい特徴をタグから取り除くことで、その特徴が固定化されやすくなる。

逆に変動させたい部分、逆に服装やポーズ、体の向き、メガネの有無など、変動しうる場所は残しておく。そうすると、いい感じに特徴をとらえたキャラクターが出やすくなる上、プロンプトにそれらを含めなくても出るようになるためトークンの節約にもなる。

但し、この細工は教師画像が少ないとあまり効果がない気がしている。

参考:LoRA/学習方法 - としあきdiffusion Wiki*

4. 学習とモデルの作成

以下のコードをNew Preset.xmloraとか適当な名前で保存し、Kohya_LoRA_param_GUIで読み込み、チェックポイントモデルと教師画像、モデルの出力先を適当に指定して実行するとモデルが生成される。

体感ではponyDiffusionV6XL_v6StartWithThisOne.safetensorsが無難な気がしている。

<?xml version="1.0" encoding="utf-8"?>
<TrainParams xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ModelPath></ModelPath>
  <TrainImagePath></TrainImagePath>
  <OutputPath></OutputPath>
  <TensorBoardLogPath />
  <LoraModelPath />
  <LearningRate>0.0001</LearningRate>
  <Resolution>1024</Resolution>
  <BatchSize>2</BatchSize>
  <Epochs>8</Epochs>
  <NetworkDim>8</NetworkDim>
  <NetworkAlpha>3</NetworkAlpha>
  <RegImagePath />
  <ShuffleCaptions>true</ShuffleCaptions>
  <KeepTokenCount>0</KeepTokenCount>
  <SaveEveryNEpochs>0</SaveEveryNEpochs>
  <OptimizerType>AdamW8bit</OptimizerType>
  <WarmupSteps>250</WarmupSteps>
  <OutputName></OutputName>
  <Comment />
  <CpuThreads>1</CpuThreads>
  <NoBucketUpscaling>false</NoBucketUpscaling>
  <UseWarmupInit>false</UseWarmupInit>
  <ClipSkip>2</ClipSkip>
  <Seed>42</Seed>
  <SavePrecision>fp16</SavePrecision>
  <SchedulerType>cosine_with_restarts</SchedulerType>
  <MinBucketResolution>320</MinBucketResolution>
  <MaxBucketResolution>1536</MaxBucketResolution>
  <CaptionFileExtension>.txt</CaptionFileExtension>
  <VAEPath />
  <UnetLR>-1</UnetLR>
  <TextEncoderLR>-1</TextEncoderLR>
  <NoiseOffset>0</NoiseOffset>
  <Momentum>0.9</Momentum>
  <advancedTrainType>UNetOnly</advancedTrainType>
  <CrossAttenType>xformers</CrossAttenType>
  <UseGradient>true</UseGradient>
  <UseWeightedCaptions>false</UseWeightedCaptions>
  <AdaptiveNoiseScale>0</AdaptiveNoiseScale>
  <MinSNRGamma>0</MinSNRGamma>
  <MultiresNoiseIterations>0</MultiresNoiseIterations>
  <MultiresNoiseDiscount>0</MultiresNoiseDiscount>
  <NetworkDropout>0</NetworkDropout>
  <RankDropout>0</RankDropout>
  <ModuleDropout>0</ModuleDropout>
  <MaxNormReg>0</MaxNormReg>
  <CaptionDropout>0</CaptionDropout>
  <IpNoiseGamma>0</IpNoiseGamma>
  <ModuleType>LoRA</ModuleType>
  <AlgoType>lora</AlgoType>
  <ConvDim>4</ConvDim>
  <ConvAlpha>1</ConvAlpha>
  <UseConv2dExtend>true</UseConv2dExtend>
  <DyLoRAUnit>4</DyLoRAUnit>
  <DatasetConfigPath />
  <TrainNorm>false</TrainNorm>
  <RescaledOFT>false</RescaledOFT>
  <ConstrainedOFT>false</ConstrainedOFT>
  <UseScalar>false</UseScalar>
  <UseTucker>false</UseTucker>
  <WeightDocomposition>false</WeightDocomposition>
  <UseBlockWeight>false</UseBlockWeight>
  <BlockWeightIn>
    <int>20</int>
    <int>20</int>
    <int>20</int>
    <int>20</int>
    <int>20</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
  </BlockWeightIn>
  <BlockWeightMid>0</BlockWeightMid>
  <BlockWeightMid01>20</BlockWeightMid01>
  <BlockWeightMid02>20</BlockWeightMid02>
  <BlockWeightOut>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>0</int>
    <int>20</int>
    <int>20</int>
    <int>20</int>
    <int>20</int>
    <int>20</int>
  </BlockWeightOut>
  <BlockWeightOffsetIn>0</BlockWeightOffsetIn>
  <BlockWeightOffsetOut>0</BlockWeightOffsetOut>
  <BlockWeightPresetTypeIn>none</BlockWeightPresetTypeIn>
  <BlockWeightPresetTypeOut>none</BlockWeightPresetTypeOut>
  <BlockWeightZeroThreshold>0</BlockWeightZeroThreshold>
  <UseBlockDim>false</UseBlockDim>
  <BlockDimIn>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
  </BlockDimIn>
  <BlockDimMid>32</BlockDimMid>
  <BlockDimMid01>4</BlockDimMid01>
  <BlockDimMid02>4</BlockDimMid02>
  <BlockDimBase>4</BlockDimBase>
  <BlockDimOutSDXL>4</BlockDimOutSDXL>
  <BlockDimOut>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
    <int>64</int>
  </BlockDimOut>
  <BlockAlphaIn />
  <BlockAlphaMid>-1</BlockAlphaMid>
  <BlockAlphaOut />
  <BlockAlphaInM>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
  </BlockAlphaInM>
  <BlockAlphaMidM>32</BlockAlphaMidM>
  <BlockAlphaMid01>4</BlockAlphaMid01>
  <BlockAlphaMid02>4</BlockAlphaMid02>
  <BlockAlphaBase>4</BlockAlphaBase>
  <BlockAlphaOutSDXL>4</BlockAlphaOutSDXL>
  <BlockAlphaOutM>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
    <decimal>64</decimal>
  </BlockAlphaOutM>
  <UseColorAug>false</UseColorAug>
  <UseFastLoading>true</UseFastLoading>
  <DontSaveMetadata>false</DontSaveMetadata>
  <UseFlipAug>false</UseFlipAug>
  <CropRandomly>false</CropRandomly>
  <CacheLatents>true</CacheLatents>
  <CacheLatentsToDisk>true</CacheLatentsToDisk>
  <HighVRAM>false</HighVRAM>
  <UseAdditionalOptArgs>false</UseAdditionalOptArgs>
  <LRSchedulerCycle>4</LRSchedulerCycle>
  <GradAccSteps>1</GradAccSteps>
  <DataLoaderThreads>1</DataLoaderThreads>
  <MaxTokens>75</MaxTokens>
  <mixedPrecisionType>fp16</mixedPrecisionType>
  <WeightDecay>0</WeightDecay>
  <Eps>1E-06</Eps>
  <D0>1E-06</D0>
  <GrowthRate>0</GrowthRate>
  <Betas0>0.9</Betas0>
  <Betas1>0.999</Betas1>
  <Betas2>0.999</Betas2>
  <DAdaptMomentum>0.9</DAdaptMomentum>
  <ProdigyBeta3>0</ProdigyBeta3>
  <DCoef>1</DCoef>
  <Decouple>false</Decouple>
  <NoProx>false</NoProx>
  <SafeguardWarmup>false</SafeguardWarmup>
  <UseBiasCorrection>false</UseBiasCorrection>
  <StableDiffusionType>XL</StableDiffusionType>
  <NoHalfVAE>false</NoHalfVAE>
  <CacheTextencoder>false</CacheTextencoder>
  <CacheTextencoderToDisk>false</CacheTextencoderToDisk>
  <IsEpoch>true</IsEpoch>
  <UseFullFP16>false</UseFullFP16>
  <UseFP8Base>false</UseFP8Base>
  <RelativeStep>true</RelativeStep>
  <ScaleParameter>true</ScaleParameter>
  <SaveState>false</SaveState>
  <MaskLoss>false</MaskLoss>
  <RandomNoiseOffset>false</RandomNoiseOffset>
  <RandomIpNoiseGamma>false</RandomIpNoiseGamma>
  <TokensSeparator />
  <LossType>LTwo</LossType>
  <HuberScheduleType>SNR</HuberScheduleType>
  <HuberC>0.1</HuberC>
  <LoRAPlusLRRatio>0</LoRAPlusLRRatio>
  <LoRAPlusUnetLRRatio>0</LoRAPlusUnetLRRatio>
  <LoRAPlusTELRRatio>0</LoRAPlusTELRRatio>
</TrainParams>

ちもろぐの【Stable Diffusion】AIイラストにおすすめなグラボをガチで検証【GPU別の生成速度】のベンチマークを個人環境で試してみた。

設定は「1024×1024:トキ(ネイティブ高解像度イラスト)」がベース。

検証機

構成 製品 備考
OS Windows 11 Pro Version 22621.3593
CPU Intel Core i7 13700 16C24T, 2.1 GHz, TDP 65W
GPU GeForce RTX 4070 Ti Driver: NVIDIA 555.85
MEM Crucial Ballistix BL2K16G32C16U4B DDR4-3200 16GB * 4
M/B ASUS TUF GAMING Z790-PLUS D4 ATX, Z790
CPU Cooler Noctua NH-U12A
CPU Fan Fractal Design Prisma AL-12 PWM 120mm PWM
SSD Solidigm P44 Pro SSDPFKKW020X7X1 NVMe SSD 2TB

共通設定

Stable Diffusionの設定

全てのケースで以下の設定を利用(モデルは後述)

設定
Clip skip2
ENSD31337
Propmpt 1girl, toki \(blue archive\), blue archive, toki sits cross-legged in her chair. looking at viewer, cowboy shot, masterpiece, best quality, newest,
Negative Prompt nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name,
VAE Automatic
Sampleing method Euler a
Sampleing steps 15
Width 1024px
Height 1024px
Batch count 5
Batch size 1
CFG Scale 7
Seed 50

NVIDIA Control Panelの設定

設定項目 設定値
CUDA - システムメモリフォールバックポリシー システムメモリフォールバックなしを優先
電源管理モード パフォーマンス最大化を優先

Windows Defenderのリアルタイム保護

特記がない限り有効化している。

ベンチマーク結果

Animagine XL 3.1 --xformers --opt-channelslast

起動オプション

set COMMANDLINE_ARGS=--xformers --opt-channelslast

使用モデル

animagine-xl-3.1.safetensors [e3c47aedb0]

スコア

処理時間25sec
平均生成速度3.64it/s
15/15 [00:04<00:00,  3.65it/s]
15/15 [00:03<00:00,  3.78it/s]
15/15 [00:03<00:00,  3.77it/s]
15/15 [00:03<00:00,  3.77it/s]
15/15 [00:03<00:00,  3.77it/s]
75/75 [00:25<00:00,  2.98it/s]
75/75 [00:25<00:00,  3.75it/s]

Animagine XL 3.1 --xformers

起動オプション

set COMMANDLINE_ARGS=--xformers

使用モデル

animagine-xl-3.1.safetensors [e3c47aedb0]

スコア

処理時間27sec
平均生成速度3.29it/s
15/15 [00:04<00:00,  3.64it/s]
15/15 [00:05<00:00,  2.60it/s]
15/15 [00:04<00:00,  3.44it/s]
15/15 [00:04<00:00,  3.42it/s]
15/15 [00:04<00:00,  3.40it/s]
75/75 [00:27<00:00,  2.73it/s]
75/75 [00:27<00:00,  3.78it/s]

Animagine XL 3.1 起動オプションなし

起動オプション

なし

使用モデル

animagine-xl-3.1.safetensors [e3c47aedb0]

スコア

処理時間32sec
平均生成速度2.64it/s
15/15 [00:05<00:00,  2.60it/s]
15/15 [00:05<00:00,  2.73it/s]
15/15 [00:05<00:00,  2.73it/s]
15/15 [00:05<00:00,  2.70it/s]
15/15 [00:05<00:00,  2.66it/s]
75/75 [00:32<00:00,  2.32it/s]
75/75 [00:32<00:00,  2.74it/s]

Animagine XL 3.0 --xformers --opt-channelslast

起動オプション

set COMMANDLINE_ARGS=--xformers --opt-channelslast

使用モデル

animagineXLV3_v30.safetensors [e3c47aedb0]

スコア

処理時間25sec
平均生成速度3.61it/s
15/15 [00:04<00:00,  3.59it/s]
15/15 [00:03<00:00,  3.75it/s]
15/15 [00:03<00:00,  3.77it/s]
15/15 [00:03<00:00,  3.76it/s]
15/15 [00:04<00:00,  3.74it/s]
75/75 [00:25<00:00,  2.95it/s]
75/75 [00:25<00:00,  3.70it/s]

Animagine XL 3.0 --xformers --opt-channelslast --medvram-sdxl Windows Defender「リアルタイム保護」を無効化

起動オプション

Windows Defender「リアルタイム保護」を無効化

set COMMANDLINE_ARGS=--xformers --opt-channelslast --medvram-sdxl
set PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6, max_split_size_mb:128

使用モデル

animagineXLV3_v30.safetensors [e3c47aedb0]

スコア

処理時間45sec
平均生成速度2.99it/s
15/15 [00:05<00:00,  2.60it/s]
15/15 [00:04<00:00,  3.27it/s]
15/15 [00:04<00:00,  3.25it/s]
15/15 [00:04<00:00,  3.27it/s]
15/15 [00:04<00:00,  3.24it/s]
75/75 [00:45<00:00,  1.67it/s]
75/75 [00:45<00:00,  3.66it/s]

Animagine XL 3.0 --xformers --opt-channelslast --medvram-sdxl

起動オプション

set COMMANDLINE_ARGS=--xformers --opt-channelslast --medvram-sdxl

使用モデル

animagineXLV3_v30.safetensors [e3c47aedb0]

スコア

処理時間45sec
平均生成速度2.92it/s
15/15 [00:07<00:00,  2.11it/s]
15/15 [00:04<00:00,  3.25it/s]
15/15 [00:04<00:00,  3.24it/s]
15/15 [00:04<00:00,  3.26it/s]
15/15 [00:04<00:00,  3.27it/s]
75/75 [00:45<00:00,  1.64it/s]
75/75 [00:45<00:00,  3.68it/s]

おまけ1 --xformers

このベンチマークはグラフィックドライバのバージョンが異なる。バージョンは不明だが531.79以前と思われる。

NVIDIA Control Panelの設定

設定項目 設定値
CUDA - システムメモリフォールバックポリシー 設定項目がない
電源管理モード パフォーマンス最大化を優先

起動オプション

set COMMANDLINE_ARGS=--xformers

使用モデル

animagine-xl-3.1.safetensors [e3c47aedb0]

スコア

処理時間73sec
平均生成速度1.14it/s
15/15 [00:12<00:00,  1.23it/s]
15/15 [00:12<00:00,  1.16it/s]
15/15 [00:13<00:00,  1.11it/s]
15/15 [00:13<00:00,  1.13it/s]
15/15 [00:13<00:00,  1.12it/s]
75/75 [01:13<00:00,  1.02it/s]
75/75 [01:13<00:00,  1.22it/s]

おまけ2

このベンチマークはグラフィックドライバのバージョンが異なる。バージョンは不明だが531.79以前と思われる。

NVIDIA Control Panelの設定

設定項目 設定値
CUDA - システムメモリフォールバックポリシー 設定項目がない
電源管理モード パフォーマンス最大化を優先

起動オプション

なし

使用モデル

animagine-xl-3.1.safetensors [e3c47aedb0]

スコア

処理時間75sec
平均生成速度1.08it/s
15/15 [00:14<00:00,  1.04it/s]
15/15 [00:13<00:00,  1.10it/s]
15/15 [00:13<00:00,  1.09it/s]
15/15 [00:13<00:00,  1.11it/s]
15/15 [00:13<00:00,  1.12it/s]
75/75 [01:15<00:00,  1.00s/it]
75/75 [01:15<00:00,  1.12it/s]

まとめ

設定系のパフォーマンス影響など

  • Windows Defenderのリアルタイム保護は生成速度に有意な影響がないと思われる
  • Animagine XL 3.1とAnimagine XL 3.0での生成速度には特に差がないと思われる
  • --medvram-sdxlを付けると遅くなる
  • set PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.6, max_split_size_mb:128では特に意味がなさそうに見えた
  • --xformersを付けると早くなる
  • --opt-channelslastを付けると少しだけ早くなる
  • NVIDIAのドライバのバージョンを上げると劇的に早くなる
  • ちもろぐSDベンチでは4070Tiでの「1024×1024:トキ(ネイティブ高解像度イラスト)」の生成スコアは3.15it/sだったが、私の環境では平均3.64it/s、最高3.75it/s、最低2.98it/sであった
    • ちもろぐベンチのスコアが何処をとっているのかは不明だが、ちもろぐ側はCore i9 13900Kを利用しており、こちらのCore i7 13700であるため、CPUの割には悪くないスコアが出たと思う
  • 元記事を読む限り、ちもろぐ先生も結構ガッツリとNSFW生成をされていそうで安堵した(?

生成した画像

品質系プロンプトやHires. fixが入ってないので品質が微妙だが一応載せておく。

00031-2515629703.jpg
00032-2515629704.jpg
00039-1317932138.jpg

おまけ

品質系プロンプトやHires. fixを入れた版。ディティールや体の作りが、だいぶ良くなっている。

00068-1050591049.jpg
00071-3760681951.jpg
00072-2005537127.jpg

おまけ

ベンチとは一切関係なくなってしまうが、ついでにいつものキャラも出してみる。うちの子は元から可愛いのだが、SDXLの力で随分洗練され可愛くなった。

00053-1037353341.jpg
00042-3194554748.jpg
00051-2775255422.jpg

プロンプトなど

short hairではなくshot hairになっていることに、このプロンプトを生み出して一年半くらい経つ、今更気が付いた。

設定
Clip skip 2
ENSD 31337
Propmpt (illustration:1.0), masterpiece, best quality, 1girl, solo, happy, smile, theater, (perspective:1.3), from below, (looking away:1.2), (from side:1.0), {{shot_hair}}, smile, bangs, shaggy, (brown hair:1.1), swept_bangs, thick_eyebrows, skin_fang, closed mouth, {{purple eyes}}, gray {{jacket}}, white shirt, glasses, {{small breasts}},
Negative Prompt nsfw, (worst quality, low quality:1.4), (depth of field, blurry, bokeh:1.5), (greyscale, monochrome:1.0), multiple views, text, title, logo, signature, (tooth, lip, nose, 3d, realistic:1.0), dutch angle,(cropped:1.4), text, title, signature, logo, (loli:1.2), school satchel, pink, school bag, school uniform, from behind
Model animagine-xl-3.1.safetensors [e3c47aedb0]
VAE Automatic
Sampleing method Euler a
Hires. fix Upscaler: Latent, Hires steps: 0, Denosing strength: 0.7, upscale by: 2
Sampleing steps 20
Width 768px
Height 768px
Batch count 6
Batch size 1
CFG Scale 7
Seed -1

おまけのベンチスコア

参考までに上記設定でBatch countを6に変えた時の生成速度も貼っておく。なおpromptのshot hairはshort hairに直している。

処理時間118sec
平均生成速度3.09it/s
20/20 [00:04<00:00,  4.45it/s]
20/20 [00:12<00:00,  1.55it/s]
20/20 [00:04<00:00,  4.94it/s]
20/20 [00:12<00:00,  1.58it/s]
20/20 [00:03<00:00,  5.41it/s]
20/20 [00:12<00:00,  1.59it/s]
20/20 [00:03<00:00,  5.01it/s]
20/20 [00:12<00:00,  1.59it/s]
20/20 [00:03<00:00,  5.08it/s]
20/20 [00:12<00:00,  1.59it/s]
20/20 [00:03<00:00,  5.21it/s]
20/20 [00:12<00:00,  1.59it/s]
240/240 [01:53<00:00,  2.11it/s]
240/240 [01:53<00:00,  1.59it/s]

そしてこれは計測用の走行で出た子

00011-2765188767 (1).jpg
00000-1024304095.jpg
00008-2765188764.jpg

事前準備

事前に必要なコンポーネントをインストールしておく

セットアップコマンド

MSYS2などのPOSIX互換レイヤー上のシェルで動かすことを想定

# get Stable Diffusion web UI
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

# get extentions
git clone https://github.com/nolanaatama/sd-webui-tunnels stable-diffusion-webui/extensions/sd-webui-tunnels
git clone https://github.com/Mikubill/sd-webui-controlnet stable-diffusion-webui/extensions/sd-webui-controlnet
git clone https://github.com/fkunn1326/openpose-editor stable-diffusion-webui/extensions/openpose-editor
git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser
git clone https://github.com/DominikDoom/a1111-sd-webui-tagcomplete stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete
git clone https://github.com/Bing-su/dddetailer stable-diffusion-webui/extensions/dddetailer
git clone https://github.com/mcmonkeyprojects/sd-dynamic-thresholding stable-diffusion-webui/extensions/d-dynamic-thresholding

# make resource dirs
mkdir -p stable-diffusion-webui/models/ESRGAN/
mkdir -p stable-diffusion-webui/models/Lora/
mkdir -p stable-diffusion-webui/models/VAE/
mkdir -p stable-diffusion-webui/models/hypernetworks/
mkdir -p stable-diffusion-webui/extensions/sd-webui-controlnet/models/

# get controlnet
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_canny_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_canny_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_color_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_color_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_depth_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_keypose_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_keypose_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_openpose_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_openpose_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_seg_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_seg_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_sketch_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_sketch_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/t2iadapter_style_sd14v1.pth https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_style_sd14v1.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11e_sd15_ip2p.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11e_sd15_shuffle.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11f1e_sd15_tile.pth.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile.pth.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11f1p_sd15_depth.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_canny.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_inpaint.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_lineart.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_mlsd.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_normalbae.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_openpose.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_scribble.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_seg.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15_softedge.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge.pth
curl -Lo stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11p_sd15s2_lineart_anime.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime.pth

# get embeddings
curl -Lo stable-diffusion-webui/embeddings/badhandv4.pt https://civitai.com/api/download/models/20068
curl -Lo stable-diffusion-webui/embeddings/EasyNegative.pt https://huggingface.co/datasets/gsdf/EasyNegative/resolve/main/EasyNegative.pt

# get model
# upscaler
curl -Lo stable-diffusion-webui/models/ESRGAN/4x-UltraSharp.pth https://huggingface.co/nolanaatama/ESRGAN/resolve/main/4x-UltraSharp.pth
curl -Lo stable-diffusion-webui/models/ESRGAN/TGHQFace8x_500k.pth https://huggingface.co/dwnmf/deliberatev2/resolve/main/TGHQFace8x_500k.pth

# model
curl -Lo stable-diffusion-webui/models/Stable-diffusion/AOM3A1B_orangemixs.safetensors https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1B_orangemixs.safetensors

# vae
curl -Lo stable-diffusion-webui/models/VAE/orangemix.vae.pt https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt
curl -Lo stable-diffusion-webui/models/VAE/kl-f8-anime2.ckpt https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt

起動コマンド

dddetailerの依存ライブラリインストールで初回起動はかなり時間が掛かるので気長に待つ。

./webui-user.bat

設定

  1. Settings -> User Interface
  2. Quicksettings listに以下を追加
    • , sd_vae, CLIP_stop_at_last_layers
投稿日:
ソフトウェア::Stable Diffusion技術::AI

Colab Proとローカルマシンでどのくらい差が出るか簡単にベンチマークしてみたのでその結果です。

レンダリング条件

今回は以下の設定で回した結果を比較します。前回と同じです。

設定画面

ColabProでのNotebookは以下を使いました。

https://gist.github.com/Lycolia/cb432ad1b1ce083482b5487c131b5d12/80a059931c538b10d55cf9fcbf82220f24e64653

設定値は以下の通りです。

設定
Propmpt (illustration:1.0), masterpiece, best quality, 1girl, solo, happy, smile, theater, (perspective:1.3), from below, (looking away:1.2), (from side:1.0), {{shot_hair}}, smile, bangs, shaggy, (brown hair:1.1), swept_bangs, thick_eyebrows, skin_fang, closed mouth, {{purple eyes}}, gray {{jacket}}, white shirt, glasses, {{small breasts}},
Negative Prompt nsfw, (worst quality, low quality:1.4), (depth of field, blurry, bokeh:1.5), (greyscale, monochrome:1.0), multiple views, text, title, logo, signature, (tooth, lip, nose, 3d, realistic:1.0), dutch angle,(cropped:1.4), text, title, signature, logo, (loli:1.2), school satchel, pink, school bag, school uniform, from behind
Model AOM3A1B
VAE orangemix.vae.pt
Sampleing method Euler a
Sampleing steps 20
Width 512px
Height 512px
Batch count 1
Batch size 1
CFG Scale 7
Seed -1

ローカルマシンのスペック

Local 1

機材 内容 備考
OS Windows 11 Pro
M/B ASUS ROG STRIX Z390-F GAMING PCIe 3.0
CPU Intel Core i9-9900
GPU GeForce RTX 4070 Ti
MEM DDR4-3200 16GB * 4

Local 2

PCIeのバージョンを上げるとベンチスコアが伸びると聞いたので試してみた

機材 内容 備考
OS Windows 11 Pro
M/B ASUS TUF GAMING Z790-PLUS D4 PCIe 5.0
CPU Intel Core i7 13700
GPU GeForce RTX 4070 Ti
MEM DDR4-3200 16GB * 4

ベンチマーク結果

Colabは時間帯によって処理時間が変わるので2点計測しています。

4070 TiがColabProに大きく勝る結果となりました。UIの安定性や応答性でも体感ColabProを大きく上回り、ローカルストレージに出力結果や環境を溜め込み続けられる利便性があったり、起動速度に雲泥の差があったり、設定を記憶できたり、ローカルで動かせるならそれが一番楽だと感じました。

Colab Proは4:30と23:00に計測しています

グラボはZOTAC GAMING GeForce RTX 4070 Ti Trinity OCを使っていますが、発熱も60度くらいに収まるのでぼちぼち悪くないかなと思ってます。

おまけ

今回もベンチマーク中に生成された画像を何枚かピックアップして載せておきます

00001-1302401151.png

おまけ2

ローカルだと気楽に作れるのでサッと作ってみた高品質版

設定値は以下の通りです。

設定画面

設定
Propmpt (masterpiece, sidelighting, finely detailed beautiful eyes: 1.2), masterpiece*portrait, realistic, 3d face, glowing eyes, shiny hair, lustrous skin, (brown hair:1.1), short hair, smile, 1girl, embarassed, small breasts, theater, thick eyebrows, closed mouth, {{purple eyes}}, gray {{jacket}}, {{{{white shirt}}}}, glasses, {{small breasts}
Negative Prompt {{{{{{{nsfw}}}}}}, (worst quality, low quality:1.4), (depth of field, blurry, bokeh:1.5), (greyscale, monochrome:1.0), multiple views, text, title, logo, signature, (tooth, lip, nose, 3d, realistic:1.0), dutch angle,(cropped:1.4), text, title, signature, logo, (loli:1.2), school satchel, pink, school bag, school uniform, from behind
Model AOM3A1B
VAE orangemix.vae.pt
Sampleing steps 32
Sampleing method DPM++ SDE Karras
CFG Scale 7
Width 512px
Height 756px
Clip skip 2
Seed -1