Fooocus のインストール,Stable Diffusion XL (SDXL) による画像生成の実行(Fooocus,Stable Diffusion XL,PyTorch,Python を使用)(Windows 上)
【目次】
Stable Diffusion XL (SDXL)
Stable Diffusion XL (SDXL) は,Stability AIによって開発されたDiffusionベースの image-to-text の画像生成モデルである. SDXLはStable Diffusion with Larger UNet Backboneの略称である.
SDXLは,以前のStable Diffusionモデルと比較して,UNetバックボーンのサイズが3倍に増加している.この増加は,アテンションブロック数の増加とクロスアテンションコンテキストの拡大によるものである.また,SDXLはリファインメントモデルを導入している.このリファインメントモデルは,SDXLによって生成された画像の視覚的な精度を向上させるために使用される.
【文献】
D ustin Podell, Zion English, Kyle Lacey, Andreas Blattmann, Tim Dockhorn, Jonas Müller, Joe Penna, Robin Rombach: SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis. CoRR abs/2307.01952, 2023.
https://arxiv.org/pdf/2307.01952v1.pdf
【サイト内の関連ページ】
- Stable Diffusion XL 1.0 (SDXL 1.0) のインストール,画像生成(img2txt),画像変換(img2img),APIを利用して複数画像を一括生成(AUTOMATIC1111,Python,PyTorch を使用)(Windows 上)
- Stable Diffusion XL を用いて複数の画像を一度に生成するアプリケーション(Fooocus の txt2img の API,Python,PyTorch を使用)(Windows 上): 別ページ »で説明,
【関連する外部ページ】
- Paper with Code のページ: https://paperswithcode.com/paper/sdxl-improving-latent-diffusion-models-for
- 公式のソースコード (GitHub のページ): https://github.com/Stability-AI/generative-models
- Fooocus の GitHub のページ: https://github.com/lllyasviel/Fooocus
前準備
Build Tools for Visual Studio 2022,NVIDIA ドライバ,NVIDIA CUDA ツールキット 11.8,NVIDIA cuDNN 8.9.7 のインストール(Windows 上)
【サイト内の関連ページ】 NVIDIA グラフィックスボードを搭載しているパソコンの場合には, NVIDIA ドライバ, NVIDIA CUDA ツールキット, NVIDIA cuDNN のインストールを行う.
- Windows での Build Tools for Visual Studio 2022 のインストール: 別ページ »で説明
- Windows での NVIDIA ドライバ,NVIDIA CUDA ツールキット 11.8,NVIDIA cuDNN v8.9.7 のインストール手順: 別ページ »で説明
【関連する外部ページ】
- Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022)の公式ダウンロードページ: https://visualstudio.microsoft.com/ja/visual-cpp-build-tools/
- NVIDIA ドライバのダウンロードの公式ページ: https://www.nvidia.co.jp/Download/index.aspx?lang=jp
- NVIDIA CUDA ツールキットのアーカイブの公式ページ: https://developer.nvidia.com/cuda-toolkit-archive
- NVIDIA cuDNN のダウンロードの公式ページ: https://developer.nvidia.com/cudnn
Fooocus のインストールと動作生成(Windows 上)
Fooocus の stable-diffusion-webui の GitHUb のページ: https://github.com/Fooocus/stable-diffusion-webui
管理者権限のコマンドプロンプトで以下を実行する.管理者権限は,winget の --scope machine オプションでシステム全体にインストールするために必要となる.
管理者権限のコマンドプロンプトで以下を実行する。管理者権限のコマンドプロンプトを起動するには、Windows キーまたはスタートメニューから「Git のインストール(Windows 上) [クリックして展開]
REM Git をシステム領域にインストール
winget install --scope machine --id Git.Git -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=""icons,ext\reg\shellhere,assoc,assoc_sh"" /o:PathOption=Cmd /o:CRLFOption=CRLFCommitAsIs /o:BashTerminalOption=MinTTY /o:DefaultBranchOption=main /o:EditorOption=VIM /o:SSHOption=OpenSSH /o:UseCredentialManager=Enabled /o:PerformanceTweaksFSCache=Enabled /o:EnableSymlinks=Disabled /o:EnableFSMonitor=Disabled"
7-Zip のインストール(Windows 上) [クリックして展開]
cmd」と入力し、表示された「コマンドプロンプト」を右クリックして「管理者として実行」を選択する。REM 7-Zip をシステム領域にインストール
winget install --scope machine --id 7zip.7zip -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements
REM 7-Zip のパス設定
powershell -NoProfile -Command "$p='C:\Program Files\7-Zip'; $c=[Environment]::GetEnvironmentVariable('Path','Machine'); if((Test-Path $p) -and $c -notlike \"*$p*\"){[Environment]::SetEnvironmentVariable('Path',\"$p;$c\",'Machine')}"
Fooocus のインストール
- Fooocus の GitHub のページを開く
- このページで,Windows の下の「Click here to download」をクリック
- ダウンロードしたファイルを展開(解凍する).
7-zip の利用が便利.右クリックメニューで「7-Zip」(「7-Zip」が表示されないときは「Show more options」,「7-Zip」),「展開」.展開先を「C:\」に設定して,「OK」をクリック.
このとき,展開先として「Fooocus_win64_1-1-10」のように表示されるので確認しておくこと.
- Windows で,管理者権限でコマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー >
cmdと入力 > 右クリック > 「管理者として実行」)。 - 起動
次のコマンドを実行. 「Fooocus_win64_1-1-10」のところは,先ほど確認した展開先を指定すること
cd C:\ cd Fooocus_win64_1-1-10 run.bat
- 起動できたことの確認
エラーメッセージが出ていないことを確認.
- Web ブラウザの画面が開く
- 英語の文章を入れて,「Generate」をクリック.結果を確認.
プロンプトとして次を入れている.
Standing on a sandy beach by the sea, the vast ocean reflects sunlight. A forest trees, while in the distance, mountains with snow-capped peaks appear. The clear blue sky and warm sunlight create a perfect setting. Today is meant for playing on the beach, inspired by the beautiful scenery.
- 画像が2枚表示されるので確認.
一度に生成する画像の枚数は「Advanced」をチェックすることにより出てくる設定画面で設定できる.
画像をクリックすると拡大表示できる.