LoginSignup
13
17

WindowsPC に Stable Diffusion web UI (AUTOMATIC1111版)をインストールする方法

Last updated at Posted at 2023-03-10

1. はじめに

今回は、自分自身への備忘録を兼ねて、WindowsPC に Stable Diffusion web UI (AUTOMATIC1111版)をインストールする方法を、お伝えしたいと思います。

2. この記事を読んでできること

  • WindowsPC に Stable Diffusion web UI をインストールできるようになる
  • Stable Diffusion を使えるようになる

3. 注意事項

  • 18歳以上であること

4. 必要なもの

  • WindowsPC(この記事では Windows11 を利用)
  • グラフィックボード(NVIDIAの「GeForce RTX20」シリーズ以降、VRAM8GB以上)
  • HDD または SSD(十分なディスク容量があること)
  • インターネット環境(有線LAN推奨)
  • キーボード
  • マウス
  • HDMIディスプレイ

5. Stable Diffusion web UI (.zipファイル)のダウンロード

  • GitHubサイトを開き、「sd.webui.zip」ファイルをダウンロードする
  • .zipファイルを解凍する
  • 参考:この記事作成時のファイルバージョン:sd.webui.zip(v1.0.0-pre)

6. モデルファイル の 格納

  • 自力で、StableDiffusion のモデルファイルを入手し、webui/models/Stable-diffusion フォルダ配下に格納する

  • ChilloutMix-ni-fp16.safetensors

image.png

7. VAE ファイル の格納

image.png

8. Stable Diffusion web UI の初回環境構築

  • sd.webui フォルダ配下の run.batファイルを実行する
  • フォルダ名は sd.webui ではなく stable-diffusion-webui が一般的のようです
  • フォルダ名は run.batファイルを実行する前に、sd.webui から stable-diffusion-webui へ変更しておくと、他の参考サイトと同じフォルダ名称になりわかりやすいかもしれません

image.png

image.png

image.png

エラー内容
raise RuntimeError("Cannot add middleware after an application has started")
RuntimeError: Cannot add middleware after an application has started
続行するには何かキーを押してください . . .

9. エラー発生時のトラブルシューティング(2023/03/10 時点の解決例)

  • cmd コマンドプロンプトを開き、以下のコマンドを実行する
  • cmd コマンドの開き方は、エクスプローラーで python フォルダまで移動し、エクスプローラーのアドレスバーに cmd と入力し、ENTERキーを押下するとcmd コマンドプロンプトを開きます
  • コマンド実行結果が成功だったら、再度、sd.webui フォルダ配下の run.batファイルを実行してみる
コマンドプロンプト
// ディレクトリの移動(python.exeファイルがあるフォルダ内へ移動)
> cd C:\Program Files\sd.webui\system\python

// コマンド実行
> python.exe -m pip install --upgrade fastapi==0.90.1

// Successfully installed fastapi-0.90.1 starlette-0.23.1 が出力されると成功らしい
// コマンドプロンプトを終了する
> exit

image.png

image.png

10. Stable Diffusion web UI をブラウザで開く

image.png

11. プロンプト の 設定

  • 画面左上の1つ目のテキストボックスに「 cat 」と入力する

image.png

12. Stable Diffusion の 実行

image.png

13. おわりに

いかがでしたでしょうか?WindowsPC に Stable Diffusion web UI (AUTOMATIC1111版)をインストールし、Stable Diffusion を実行することができたのではないかと思います
今回の記事が、みなさまの学習の参考になれば幸いです

2023/03/10 TAKAHIRO NISHIZONO



14. 追記その1:モデルファイル「.safetensors」拡張子ファイルを入手しよう

image.png

15. 追記その2:VAEファイル「.ckpt」拡張子ファイルを入手しよう

image.png

16. 追記その3:ジェネリックモデルファイル「chilled_re-generic_v2.safetensors[589d7600e1]」マージモデルを自作しよう

chilled_re-generic_v2 Recipe[589d7600e1]
chilled_re-generic_v2 Recipe
ALL Weighted sum merge
museV1_v1:0.4+(Basil_mix_fixed:0.3+(lofi_V1Fp16:0.5+colorful_v13))

// A3:補足
merge1.lofi_V1Fp16:colorful_v13=50%:50%=M:0.5
merge2.Basil_mix_fixed:merge1=70%:30%=M:0.3
merge3.museV1_v1:merge2=60%:40%=M:0.4
M:0.5→M:0.3→M:0.4=perfect!

chilled_re-generic_v2-merge1.png

chilled_re-generic_v2-merge2.png

chilled_re-generic_v2-merge3.png

17. 追記その4:モデルファイルの破損トークンを修復してみよう( chilled_re-generic_v2fix.safetensors[7e78128329] fixファイル生成)

image.png

  • cmd コマンドプロンプトを開き、以下のコマンドを実行する
コマンドプロンプト
// ディレクトリの移動(python.exeファイルがあるフォルダ内へ移動)
> cd C:\Program Files\sd.webui\system\python

// ヘルプを確認
> python fix_position_ids.py -h

// 破損個所の確認
> python fix_position_ids.py --model "C:\Program Files\sd.webui\webui\models\Stable-diffusion\chilled_re-generic_v2.safetensors" --verbose

// 破損個所の修復(fixファイルの生成)
> python fix_position_ids.py --model "C:\Program Files\sd.webui\webui\models\Stable-diffusion\chilled_re-generic_v2.safetensors" --out "C:\Program Files\sd.webui\webui\models\Stable-diffusion\chilled_re-generic_v2fix.safetensors"

// コマンドプロンプトを終了する
> exit

image.png

image.png

image.png

  • chilled_re-generic_v2:顔は似ているが、服装、肌への光の影がちがっている
  • chilled_re-generic_v2fix:顔は似ているが、服装、肌への光の影、髪トップのハイライトがちがっている
  • chilloutmix_NiPrunedFp32Fix:じゃっかん丸みのある顔、肌への光の影がはっきりしている印象

18. 追記その5:ジェネリックRecipe「chilled_re-generic.safetensors[89682ba94a]」

chilled_re-generic Recipe[89682ba94a]
ジェネリックRecipe
全て加重平均(ALL Weighted sum merge)
Basil_mix_fixed:0.3+(museV1_v1:0.3+(colorful_v2:0.5+lofi_V2pre))

chilled_re-generic_1.png

chilled_re-generic_2.png

chilled_re-generic_3.png

image.png

  • chilled_re-generic:chilled_re-generic_v2と比較すると西洋よりの顔、3回目マージのBasil_mix_fixedの7割影響が強く残っている、肌への光の影はしっかいりとあり、画面全体で活発な印象をうける、chilled_re-generic_v2で3回目マージのmuseV1_v1割合を6割としているのがv2改良ポイントのように感じる
  • Basil_mix_fixed:西洋の学習データで作られたモデルが多い中での、東洋エッセンスを多く含むモデルファイル、マージによるジェネリックモデルを生成する際の必要不可欠な隠し味

19. 追記その6:自分だけのオリジナルマージモデルRecipeを見つけてよう

  • いろいろ実験して試してみてね
chilled_re-generic_v2-correction Recipe
chilled_re-generic_v2-correction Recipe
ALL Weighted sum merge
0.6(museV1_v1) + 0.4(0.7(Basil_mix_fixed) + 0.3(0.5(lofi_V1Fp16) + 0.5(colorful_v13)))
LAST Marge vae-ft-mse-840000-ema-pruned.ckpt
realdos_re-generic Recipe
realdos_re-generic Recipe
ALL Weighted sum merge
0.3(Basil_mix_fixed) + 0.7(0.3(museV1_v1) + 0.7(0.5(colorful_v2) + 0.5(lofi_V2pre)))
LAST Marge vae-ft-mse-840000-ema-pruned.ckpt
chilled_re-generic-correction Recipe
chilled_re-generic-correction Recipe
ALL Weighted sum merge
0.7(Basil_mix_fixed) + 0.3(0.7(museV1_v1) + 0.3(0.5(colorful_v2) + 0.5(lofi_V2pre)))
LAST Marge vae-ft-mse-840000-ema-pruned.ckpt
musev1_re-generic Recipe
musev1_re-generic Recipe
ALL Weighted sum merge
0.9(museV1_v1) + 0.1(Basil_mix_fixed)
LAST Marge vae-ft-mse-840000-ema-pruned.ckpt
chillomusev1_re-generic Recipe
chillomusev1_re-generic Recipe
ALL Weighted sum merge
0.8(museV1_v1) + 0.2(Basil_mix_fixed)
LAST Marge vae-ft-mse-840000-ema-pruned.ckpt
Model Recipe
Model
0.85(0.8(sunshinemix_NotBakeInVAE) + 0.2(leehanadraw_v10)) + 0.15(Bstaber)

image.png

image.png

test prompt 2
head portrait,realistic, best quality,masterpiece,ultra high res,(photo realistic)1.4,beautiful lighting, (extremely detailed CG unity 8k wallpaper)+, detailed beautiful face,detailed clothes,Casual Clothing,1 girl,upper body,above the waist,slim face,medium breasts, big brown eyes, cute, young, posing, looking at viewers, professional lighting, physically-based rendering,depth of field

Negative prompt: nsfw,paintings, sketches, kis, (worst quality:2)+, (low quality:2)+, (normal quality:2)+, lowres, normal quality, (monochrome)++, (grayscale)++, skin spots, acnes, skin blemishes, age spot, (outdoor)1.6, glans, anime,(worst quality, low quality)1.4, 3d, curvy, fat, gray_scale, (over three finger\\(fingers excluding thumb\\):2)+, (fused anatomy)+, (bad anatomy\\(body\\))+, (bad anatomy\\(hand\\))+, (bad anatomy\\(finger\\))+, (over four fingers\\(finger\\):2)++, (bad anatomy\\(arms\\))+, (over two arms\\(body\\))+, (bad anatomy\\(leg\\))+, (over two legs\\(body\\))+, (interrupted\\(body, arm, leg, finger\\))+, (bad anatomy\\(arm\\))+, (bad detail\\(finger\\))1.2, (bad anatomy\\(fingers\\))1.2, (multiful\\(fingers\\))1.2, (bad anatomy\\(finger\\))1.2, (bad anatomy\\(fingers\\))1.2, (fused\\(fingers\\))1.2, (over four fingers\\(finger\\):2)++, (multiful\\(hands\\))+, (multiful\\(arms\\))+, (multiful\\(legs\\))+, (bad detailed background)+, (unclear architectural outline)+, (non-linear background)+, heterochromia, monochrome, 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, lowres, 2girl3girl 4girl5girl, bad anatomy, more than 1penis, bad hands, text, error, missing fingers, cropped, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, Poor Quality, Poor Detail, Weird Detail, Low Quality Effect, extra_nipples, extra face, Multiple Views, extra penis, no penis between breast, , 2koma, 3koma, more than 1girl, (2feet, 3feet, extra legs, extra feet, 4toes, 6toes, 7toes, 8toes)++, 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, blurry background, multiple views, awkward_armpit, glow, reference inset, (mutated hands and fingers)1.5, (long body )1.3, long neck,

Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 1053927817, Size: 512x512,

22. 追記その8:イラスト風マージモデルファイルを作ろう

  • SukiyakiMix-v1.0 はマージレシピが公開されているイラスト風モデルファイルです、レシピを参考にオリジナルのイラスト風モデルファイルを作成してみましょう

  • アニメでは人間の色味がそのままでは適さない場合が多いので、好みに合わせて VAE ファイルを変えてみて色調を調整してみましょう

  • pastel-mix

  • AbyssOrangeMix2_sfw

  • orangemix.vae.pt

SukiyakiMix-v1.0 Recipe
SukiyakiMix-v1.0 Recipe
ALL Weighted sum merge
pastel-mix:AbyssOrangeMix2_sfw (AOM2s) = 6:4
LAST Marge orangemix.vae.pt

21. 追記その7:モデルファイルの比較

image.png

image.png

image.png

image.png

test prompt
head portrait,realistic, best quality,masterpiece,ultra high res,(photo realistic)1.4,beautiful lighting, (extremely detailed CG unity 8k wallpaper)+, detailed beautiful face,detailed clothes,Casual Clothing,1 girl,medium breasts, big brown eyes, cute, young, posing, looking at viewers, professional lighting, physically-based rendering,depth of field

Negative prompt: nsfw,paintings, sketches, kis, (worst quality:2)+, (low quality:2)+, (normal quality:2)+, lowres, normal quality, (monochrome)++, (grayscale)++, skin spots, acnes, skin blemishes, age spot, (outdoor)1.6, glans, anime,(worst quality, low quality)1.4, 3d, curvy, fat, gray_scale, (over three finger\\(fingers excluding thumb\\):2)+, (fused anatomy)+, (bad anatomy\\(body\\))+, (bad anatomy\\(hand\\))+, (bad anatomy\\(finger\\))+, (over four fingers\\(finger\\):2)++, (bad anatomy\\(arms\\))+, (over two arms\\(body\\))+, (bad anatomy\\(leg\\))+, (over two legs\\(body\\))+, (interrupted\\(body, arm, leg, finger\\))+, (bad anatomy\\(arm\\))+, (bad detail\\(finger\\))1.2, (bad anatomy\\(fingers\\))1.2, (multiful\\(fingers\\))1.2, (bad anatomy\\(finger\\))1.2, (bad anatomy\\(fingers\\))1.2, (fused\\(fingers\\))1.2, (over four fingers\\(finger\\):2)++, (multiful\\(hands\\))+, (multiful\\(arms\\))+, (multiful\\(legs\\))+, (bad detailed background)+, (unclear architectural outline)+, (non-linear background)+, heterochromia, monochrome, 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, lowres, 2girl3girl 4girl5girl, bad anatomy, more than 1penis, bad hands, text, error, missing fingers, cropped, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, Poor Quality, Poor Detail, Weird Detail, Low Quality Effect, extra_nipples, extra face, Multiple Views, extra penis, no penis between breast, , 2koma, 3koma, more than 1girl, (2feet, 3feet, extra legs, extra feet, 4toes, 6toes, 7toes, 8toes)++, 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, blurry background, multiple views, awkward_armpit, glow, reference inset, (mutated hands and fingers)1.5, (long body )1.3, long neck,

Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 1860404385, Size: 512x512

22. 追記その8:おすすめ embeddings/ ファイル

23. 追記その9:おすすめ LoRA/ ファイル

24. 追記その10:裏技 画像精製のじゃっかん高速化

  • webui-user.bat ファイルに、--xformers を追記し保存する
webui-user.bat
 @echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--xformers

call webui.bat

25. 追記その11:呪文

webui-user.bat
▼品質 呪文
masterpiec, best quality, high resolution, ultra detailed,

▼作風 呪文
illustration,
anime,
manga,
realistic,
sketch,
pencil drawing,
watercolor,
oil painting,
claude Monet,
Pablo Picasso,

▼環境 呪文
full body,
portrait,
close up face,
cowboy shot,
wide shot,
from below,
viewfinder,
summer,
winter,
snowfall,
landscape of japan,
medieval europe,
middle ages,

▼主体 呪文
1 girl, smile, detailed beautiful skin, face focus, dress shirt, collarbone, dark_hair, long_hair, hair_flower, hair_ornament,
1 little girl, black short hair, cat ear, red eyes, torogao, embarrassed eyebrows, skin fang, mediam chest, frilled dress, white gloves on both hands,
woman, smile, office lady, tight skirt,
looking at viewer,

▼環境 呪文
windy, soft light,
outdoor, street, night,

▼ネガティブ 呪文
(worst quality:2),(low quality:2),(normal quality:2),((monochrome)),((grayscale)), missing fingers ,skin spots ,acnes,skin blemishes, nsfw

26. 追記その12:LoRA 適用時の Clip skip 値 2

26. 追記その12:ENSD 値 31337

27. 追記その13:おすすめ プロンプト50選

28. 追記その14:便利機能まとめ

29. 追記その15:LoRAファイル作ろう

30. 追記その16:高品質なアップスケーラー

31. 追記その17:ControlNetのインストール

32. 追記その18:ControlNet Tile を使ってみる(描画量アップ)

33. 追記その19:Tiled Diffusion (Tiled VAE) の使い方(分割アップスケール)

34. 追記その20:Tile Resampleの解説(描画量アップ+アップスケール)

35. 追記その21:邪魔な部分を簡単除去 - Lama Cleaner

36. 追記その22:画像生成AIで思い通りの画像を作る!「BRAV5」を使いこなすプロンプトのコツ

37. 追記その23:手や顔の崩れを簡単に修正できるADetailerのインストール・使い方を紹介します【Stable Diffusion WebUIの使い方】

38. 追記その24:愛音さんテクニック

38. 追記その24:xxx@AIart(@untn_xxx)さんテクニック

39. 追記その25:とーふのかけら(@konapieces)さんテクニック

▼プロンプト
(longeyelashes:0.8),
AsianEyesEra,

▼RoLA
lora:AsianEyesEra:1

image.png

13
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
17