![見出し画像](https://assets.st-note.com/production/uploads/images/94889346/rectangle_large_type_2_78b4e8d4cae1e419b120ad253bd0e080.jpeg?width=1200)
StableDeffusion 環境構築 for WEBUI(2022.10.21執筆版)
概要
StableDeffusion 環境構築 for WEBUI
ブック作成時の参考URL
0:事前準備
・ZIPファイル解凍ツール(多分既存でOK)
・HuggingFaceアカウント
・8GB以上のVRAMを持つNVIDIAのグラボ搭載してること
・Gitのインストール(必要な人は導入すること
1:必要ファイル準備
・学習済みモデルデータの取得
※要HuggingFaceアカウント、適当なgmailとかで取れた。
CompVis/stable-diffusion-v-1-4-original · Hugging Face(以下パス)より学習済みモデルデータ取得
https://huggingface.co/CompVis/stable-diffusion-v-1-4-original
sd-v1-4.ckptをダウンロード
![](https://assets.st-note.com/img/1672384235874-wsQDmf0N1T.png?width=1200)
・ソースコードの取得~準備
Sutable Diffusion web UIソースを取得。
GitHub - hlky/stable-diffusion(以下パス)よりコードを取得する。https://github.com/sd-webui/stable-diffusion-webui
![](https://assets.st-note.com/img/1672384277286-aivuYRW9pM.png?width=1200)
・minicondaインストーラの取得
Miniconda — conda documentation(以下パス)よりインストーラを取得https://docs.conda.io/en/latest/miniconda.html
※取得するインストーラは自分の環境のアーキテクチャに合わせる。Win10の64bitで実施した。
![](https://assets.st-note.com/img/1672384312422-dhZHarzf1K.png?width=1200)
2:環境構築
・取得ファイルは任意フォルダにまとめておく
![](https://assets.st-note.com/img/1672384362667-bierMtrBLx.png?width=1200)
・sd-v1-4.ckptのリネーム
ダウンロードした「sd-v1-4.ckpt」を「model.ckpt」にリネームする。
変更前:sd-v1-4.ckpt
![](https://assets.st-note.com/img/1672384399652-L2fIhYlCOO.png)
変更後:model.ckpt
![](https://assets.st-note.com/img/1672384424419-cjnVcN67CE.png)
・stable-diffusion-webui-master.zip解凍
ダウンロードした「stable-diffusion-webui-master.zip」を任意のフォルダに解凍する。
※ここが実行フォルダになるみたい。
![](https://assets.st-note.com/img/1672384563252-00QV6Ljgfg.png?width=1200)
・model.ckptの移動
解凍してできたフォルダの以下パスに、リネームした「model.ckpt」を移動する。
\stable-diffusion-webui-master\models\ldm\stable-diffusion-v1
![](https://assets.st-note.com/img/1672384547551-TBXjYdsn16.png?width=1200)
・「environment.yaml」の編集
以下パスにある「environment.yaml」をエディタで開いて編集する。
※pipコマンドで取得するデータのフォルダ名を変更する。
yumとかaptgetみたいなもんらしい。
\stable-diffusion-webui-master\models\ldm\stable-diffusion-v1\environment.yaml
![](https://assets.st-note.com/img/1672384633087-B2nzc2PXj2.png?width=1200)
・name: ldm → name: ldo
デフォルト設定から変更してるんだと思うよ。
![](https://assets.st-note.com/img/1672384661298-H7TewvM8sC.png?width=1200)
![](https://assets.st-note.com/img/1672384679721-x6FNu9yfrq.png?width=1200)
・Minacondaインストール
ダウンロードした「Miniconda3-latest-Windows-x86_64.exe」を実行してインストール
>NEXT
![](https://assets.st-note.com/img/1672384734404-sqdDtKMbfE.png)
>I Agree
![](https://assets.st-note.com/img/1672384759163-f25WoD4NKI.png)
>Just Me(任意だと思う)
![](https://assets.st-note.com/img/1672384784451-Xs3f2Pj4bI.png)
>インストール先はデフォルトのパスがいいみたい。任意フォルダやデフォルト設定フォルダだと、コマンド編集する必要がある。
![](https://assets.st-note.com/img/1672384954281-VbheCJKoHx.png?width=1200)
※c:\ProgramData 不可視になっているとデフォルト設定だとエクスプローラーで見れないがファイルは存在する
※インストール先のフォルダに空白があるとワーニングが出る。
![](https://assets.st-note.com/img/1672384833760-2EAlxxEmJp.png)
>チェックは任意、上だけチェックでいいと思う。。。パス設定だし…。
![](https://assets.st-note.com/img/1672384979147-cZVjrJv9V7.png)
>NEXT
![](https://assets.st-note.com/img/1672385052838-8Z3nZzZcBT.png)
>チェック外してFINISH
![](https://assets.st-note.com/img/1672385074178-nfkZ1S3YJR.png)
・Gitの導入
Gitよりインストーラを取得(Win版)
https://git-scm.com/download/win
![](https://assets.st-note.com/img/1672385092773-dABEZouffj.png?width=1200)
ダウンロードフォルダの「Git-2.38.1-64-bit.exe」を実行する。
※ここでは64bit版
![](https://assets.st-note.com/img/1672385110092-HObGYc4F66.png)
デフォのままNEXTでいいはず
![](https://assets.st-note.com/img/1672385135241-o5qeBRIBFe.png)
・webui.cmdの実行
解凍フォルダの「webui.cmd」を実行する。
![](https://assets.st-note.com/img/1672385158125-n2t7kcTGKI.png?width=1200)
実行したらこんな感じ(ネット上からデータ取得してる)
![](https://assets.st-note.com/img/1672385182511-MTTsNH6hoR.png?width=1200)
この辺出たら許可してあげて
![](https://assets.st-note.com/img/1672385194857-s18pXN0r0Y.png)
3:実行
・webui.cmdの処理が完了したときに出力されるURLをブラウザで開く
![](https://assets.st-note.com/img/1672385227938-8qDwrPCYuI.png?width=1200)
後は遊ぶだけ。終わり。
![](https://assets.st-note.com/img/1672385538068-PWygnUnivY.png?width=1200)
おまけ:
多機能のWEBUI版はここから
https://github.com/AUTOMATIC1111/stable-diffusion-webui
※これを使うとモデルデータ複数の切り替えが楽