## 概要 [[Windows]]から[[macOS]]に移行したのと、以前[[Stable Diffusion]]を試してから3年くらい経ったので、久々に試してみたいと思ったので。前回のは以下。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://publish-01.obsidian.md/access/35d05cd1bf5cc500e11cc8ba57daaf88/favicon-64.png" /> <span class="link-card-v2-site-name">Minerva</span> </div> <div class="link-card-v2-title"> 📜2022-08-23 Stable Diffusionを試してみた </div> <div class="link-card-v2-content">Stable DiffusionをWindows 10とPowerShell環境で動作させるため、Anacondaで仮想環境を構築し、必要なckptファイルをHugging Faceから取得した。初回は依存関係やCUDAメモリ不足でエラーが発生したが、軽量化されたフォーク版を利用し、最終的に画像生成に成功した。</div> <img class="link-card-v2-image" src="https://publish-01.obsidian.md/access/35d05cd1bf5cc500e11cc8ba57daaf88/Notes/attachments/activity.webp" /> <a data-href="📜2022-08-23 Stable Diffusionを試してみた" class="internal-link"></a> </div> %%[[📜2022-08-23 Stable Diffusionを試してみた]]%% ### 環境 [[MacBook Pro M4 Pro]]。12コアCPU、16コアGPU、16コアNeural Engine搭載Apple M4 Proチップ。24GBユニファイドメモリ。 | 対象 | バージョン | | ------------------- | -------- | | [[macOS]] | 15.5 | | [[CMake]] | 4.0.3 | | [[Protocol Buffer]] | 29.3 | | [[Python]] | 3.10.18 | | [[Rust]] | 1.88.0 | | [[Git]] | 2.50.1 | | [[wget]] | 1.25.0 | | [[mise]] | 2025.7.0 | ## インストール [[Stable Diffusion Web UI]]のドキュメントを参考に。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" /> <span class="link-card-v2-site-name">GitHub</span> </div> <div class="link-card-v2-title"> Installation on Apple Silicon </div> <div class="link-card-v2-content"> Stable Diffusion web UI. Contribute to AUTOMATIC1111/stable-diffusion-webui development by creating an account o ... </div> <img class="link-card-v2-image" src="https://opengraph.githubassets.com/ae498e59b8876b3e9eaacada6c31dbc9c0f54f2c3ba04e74de9c4387f06cf00b/AUTOMATIC1111/stable-diffusion-webui" /> <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon"></a> </div> > 1. If Homebrew is not installed, follow the instructions at https://brew.sh to install it. Keep the terminal window open and follow the instructions under "Next steps" to add Homebrew to your PATH. [[Homebrew]]はインストール済なので不要。 > 2. Open a new terminal window and run `brew install cmake protobuf rust [email protected] git wget` ``` brew install cmake protobuf mise use -g [email protected] ``` - [[Python]]はグローバルインストールしたくないので[[mise]]で - [[Git]] と [[wget]] はインストール済なので不要 - [[Rust]] は [[mise]]でインストール済なので不要 > 3. Clone the web UI repository by running `git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui` ```console git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui ``` > 4. Place Stable Diffusion models/checkpoints you want to use into `stable-diffusion-webui/models/Stable-diffusion`. If you don't have any, see [Downloading Stable Diffusion Models](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon#downloading-stable-diffusion-models) below. ```console cd stable-diffusion-webui/models/Stable-diffusion mv <ダウンロードしたモデルファイル> . ``` 今回ダウンロードしたファイルは以下3つ。 | モデル名 | バージョン | | ------------------- | ------- | | [[blue_pencil-XL]] | v7.0.0 | | [[anima_pencil-XL]] | v5.0.0 | | [[novaAnimeXL]] | IL v9.0 | モデルは[[SDXL]]対応のものを、いくつかの記事を参考にしたうえでチョイス。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://assets.st-note.com/poc-image/manual/note-common-images/production/icons/android-chrome-192x192.png" /> <span class="link-card-v2-site-name">note(ノート)</span> </div> <div class="link-card-v2-title"> StableDiffusionでイラストを生成する。(元画像を使う方法も)|しおん あい </div> <div class="link-card-v2-content"> しおん あいです エッチなお姉さんの「写真画像」はすでに生成ができているんだけど、イラスト!イラストを出したい!エッチだろうがなんだろうが、写真じゃなくて「イラスト画像」を出したい!という方向けの記事となっています。 ... </div> <img class="link-card-v2-image" src="https://assets.st-note.com/production/uploads/images/151570480/rectangle_large_type_2_618161493948fc8274e047075a3e3800.png?fit=bounds&quality=85&width=1280" /> <a href="https://note.com/glad_cedum1421/n/n397f84cb71e4"></a> </div> <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://romptn.com/article/wp-content/uploads/2024/03/cropped-roptn_logo_%E9%80%8F%E9%81%8E-32x32.png" /> <span class="link-card-v2-site-name">romptn Magazine</span> </div> <div class="link-card-v2-title"> 【2025年7月】Stable Diffusionのおすすめモデル6選と人気モデルTOP10! </div> <div class="link-card-v2-content"> Stable Diffusionで、どのモデルを使おうか迷った経験はありませんか?今回は60種以上のモデルを試した編集者が、特におすすめのモデルを実写・リアル系、イラスト・アニメ系に分けてそれぞれご紹介します! ... </div> <img class="link-card-v2-image" src="https://romptn.com/article/wp-content/uploads/2023/09/%E6%96%B0%E3%82%B5%E3%83%A0%E3%83%8D_%E5%8E%9F%E6%9C%AC-18-1.png" /> <a href="https://romptn.com/article/15500"></a> </div> > 5. `cd stable-diffusion-webui` and then `./webui.sh` to run the web UI. A Python virtual environment will be created and activated using venv and any remaining missing dependencies will be automatically downloaded and installed. ```console cd ../../ ./webui.sh ``` 仮想環境が作成されて依存関係がインストールされていく。 > 6. To relaunch the web UI process later, run `./webui.sh` again. Note that it doesn't auto update the web UI; to update, run `git pull` before running `./webui.sh.` すでに起動しているのでこのまま使って良さそう。一旦静観。 ## 動かしてみる ### [[novaAnimeXL]]で生成開始するとエラーが出る ```error modules.devices.NansException: A tensor with NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check. ``` `webui-user.sh` を以下のように変更する。 ```diff - # export COMMANDLINE_ARGS="" + export COMMANDLINE_ARGS="--no-half" ``` `./webui.sh` を再実行したがまだ駄目っぽい。 ```error Python 3.10.18 (main, Jul 23 2025, 00:27:13) [Clang 20.1.4 ] Version: v1.10.1 Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2 Traceback (most recent call last): File "/Users/tadashi-aikawa/git/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py", line 48, in <module> main() File "/Users/tadashi-aikawa/git/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py", line 39, in main prepare_environment() File "/Users/tadashi-aikawa/git/github.com/AUTOMATIC1111/stable-diffusion-webui/modules/launch_utils.py", line 387, in prepare_environment raise RuntimeError( RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check ``` `webui-user.sh` を再び変更。 ```diff - export COMMANDLINE_ARGS="--no-half" + export COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half" ``` `./webui.sh` を起動したら無事に生成された。 ## 全身を入れる **冒頭に** `full body` を入れる。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://ai-illust-kouryaku.com/wp-content/uploads/2024/10/cropped-%E7%94%9F%E6%88%90AI%E6%94%BB%E7%95%A5_%E3%83%95%E3%82%A1%E3%83%93%E3%82%B3%E3%83%B3-32x32.jpg" /> <span class="link-card-v2-site-name">生成AI攻略</span> </div> <div class="link-card-v2-title"> 【Stable Diffusion】全身が出ない・全身で顔が崩れた時の対処法 </div> <div class="link-card-v2-content"> 全身を画像生成する「full body」の呪文を入れても上手く全身で反映されない場合があって困っている人は多いと思います。記事内では、全身が出ない場合や全身を生成して顔が崩れてしまった時の対処法について解説します。 ... </div> <img class="link-card-v2-image" src="https://ai-illust-kouryaku.com/wp-content/uploads/2023/10/%E3%82%A2%E3%82%A4%E3%82%AD%E3%83%A3%E3%83%83%E3%83%81-14.png" /> <a href="https://ai-illust-kouryaku.com/archives/9465"></a> </div> ## 顔を再利用する > [!todo] > 整理中 > - https://huggingface.co/h94/IP-Adapter-FaceID/tree/main > - ip-adapter-faceid-plusv2_sdxl.bin > - ip-adapter-faceid-plusv2_sdxl_lora.safetensors <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://assets.st-note.com/poc-image/manual/note-common-images/production/icons/android-chrome-192x192.png" /> <span class="link-card-v2-site-name">note(ノート)</span> </div> <div class="link-card-v2-title"> 【Stable Diffusion】同じ顔にできるReference Onlyの使い方について解説|レベルマ【生成AI情報発信】 </div> <div class="link-card-v2-content"> 「同じ顔で別の画像生成をしたいけど、どうやって出来るのかな?」と困っている方のために、 この記事では、Reference Onlyの使い方について解説します。 Reference Onlyとは Referenc ... </div> <img class="link-card-v2-image" src="https://assets.st-note.com/production/uploads/images/204588740/rectangle_large_type_2_adbfb8b512d8d87025109376f25d3b13.png?fit=bounds&quality=85&width=1280" /> <a href="https://note.com/levelma/n/nc138bc3ae628"></a> </div> ### トラブル ``` No module named 'insightface' ``` ``` source venv/bin/activate pip install insightface==0.7.3 onnxruntime opencv-python-headless ``` ### ControlNet [[ControlNet for Stable Diffusion WebUI]]を使う。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://ferret-one.akamaized.net/images/6455e45415a7954ed7cfcc51/original.png?utime=1683350612" /> <span class="link-card-v2-site-name">業界最安級GPUクラウド | GPUSOROBAN</span> </div> <div class="link-card-v2-title"> 【Stable Diffusion Web UI】ControlNetの使い方まとめ+Cannyの紹介 </div> <div class="link-card-v2-content"> この記事では、Stable Diffusion WebUI(AUTOMATIC1111版・Forge版)で、ContorlNetをインストールする方法をまとめて紹介しています。併せてControlNetのモデルの1つであるC ... </div> <img class="link-card-v2-image" src="https://ferret-one.akamaized.net/images/65cacf8c329f5c222f3b298f/large.png?utime=1707790220" /> <a href="https://soroban.highreso.jp/article/article-072"></a> </div> [[Stable Diffusion Web UI]]の `Extensions` タブからインストール。 ![[2025-07-27-11-38-38.avif]] ![[2025-07-27-11-43-24.avif]] [[Stable Diffusion Web UI]] を再起動する。 #### モデルインストール [[Hugging Face]]から[インストール](https://huggingface.co/lllyasviel/sd_control_collection/tree/main)する。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://highreso.jp/edgehub/wp-content/uploads/2024/02/cropped-edgehub-icon-32x32.png" /> <span class="link-card-v2-site-name">EdgeHUB</span> </div> <div class="link-card-v2-title"> Stable DiffusionのControlNetとは?インストールから解説!【SDXL対応】 | EdgeHUB </div> <div class="link-card-v2-content"> Stable DiffusionにはControlNetと呼ばれる拡張機能があります。ControlNetを利用することによって、画像からポーズを抽出したり、線画を抽出したりして画像を生成することができます。この記事では、C ... </div> <img class="link-card-v2-image" src="https://highreso.jp/edgehub/wp-content/uploads/2024/07/controlnet-eyecatch.jpg" /> <a href="https://highreso.jp/edgehub/stablediffusion/controlnet.html"></a> </div> > [!note] > モデルによっては[[Civitai]]からもインストールできる。こっちはログイン不要なので楽。 ## [[VAE]] > [!note] > 同梱されているっぽくていらなそうなので様子見。 `vae-ft-mse-840000-ema-pruned` がいいらしい。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://lucirc.com/favicon.ico" /> <span class="link-card-v2-site-name">自分コンテンツ計画</span> </div> <div class="link-card-v2-title"> 【VAE】vae-ft-mse-840000-ema-prunedの使い方 </div> <div class="link-card-v2-content"> 「Stable Diffusionで生成した画像が、なんとなくぼやけている」 そんな時は「VAE」という機能を使うと、ぼやけてる部分やくすみ、トーンアップなど簡単に改善できます。 その中でもよく使われ ... </div> <img class="link-card-v2-image" src="https://lucirc.com/wp-content/uploads/2023/11/vae-ft-mse-840000-ema-pruned-eyecatch.jpg" /> <a href="https://lucirc.com/vae-ft-mse-840000-ema-pruned/"></a> </div>