【備忘録】stable diffusionを2025年最新版にアップデート（再構築）

自分は、ちょうど1年ほど前に、MacbookProでStableDiffusionを作成した。

https://qiita.com/itohdaigo/items/602b54532ef0f333cc06


最近、モデルなどをアップデートできていないと思い、更新しようとしたのだが、なぜか更新できなかったので、再度作り直した。

```:エラー内容
(base) test@test stable-diffusion-webui % sudo git pull
Password:
fatal: invalid value for 'pull.rebase': 'merge'
(base) itoudaiware@itoudaiwarenoMacBook-Pro stable-diffusion-webui % git pull
fatal: invalid value for 'pull.rebase': 'merge'
(base) itoudaiware@itoudaiwarenoMacBook-Pro stable-diffusion-webui % git pull --no-rebase

remote: Enumerating objects: 17157, done.
remote: Counting objects: 100% (2495/2495), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 17157 (delta 2455), reused 2485 (delta 2451), pack-reused 14662 (from 2)
Receiving objects: 100% (17157/17157), 7.30 MiB | 1.29 MiB/s, done.
Resolving deltas: 100% (11929/11929), completed with 281 local objects.
From https://github.com/AUTOMATIC1111/stable-diffusion-webui
   22bcc7be..82a973c0  master                -> origin/master
 * [new branch]        Authenticated-Sysinfo -> origin/Authenticated-Sysinfo
 * [new branch]        Forbid-too-small-crop-region---compact -> origin/Forbid-too-small-crop-region---compact
 * [new branch]        SD3-Lora-page-filter---detection-not-implemented -> origin/SD3-Lora-page-filter---detection-not-implemented
 * [new branch]        add-Usage-Syntax-to-Prompts-from-file-or-textbox -> origin/add-Usage-Syntax-to-Prompts-from-file-or-textbox
 * [new branch]        add-middleware-after-app-has-started -> origin/add-middleware-after-app-has-started
 * [new branch]        bump-Pillow-blendmodes-dependency -> origin/bump-Pillow-blendmodes-dependency
 * [new branch]        canvas-undo-hotkey,adjust-brush-size-by-area -> origin/canvas-undo-hotkey,adjust-brush-size-by-area
 * [new branch]        compact-Soft-Inpainting-infotext -> origin/compact-Soft-Inpainting-infotext
 * [new branch]        consistency-dec       -> origin/consistency-dec
 * [new branch]        dev                   -> origin/dev
 * [new branch]        fix-sd_hijack-infotext-cased-by-conda-cache -> origin/fix-sd_hijack-infotext-cased-by-conda-cache
 * [new branch]        gradio-4.x-test       -> origin/gradio-4.x-test
 * [new branch]        gradio4               -> origin/gradio4
 * [new branch]        hires-button-opt-insert-gallery -> origin/hires-button-opt-insert-gallery
 * [new branch]        lora_emb_bundle       -> origin/lora_emb_bundle
 * [new branch]        method-3-fix-sd_hijack-infotext-cased-by-conda-cache -> origin/method-3-fix-sd_hijack-infotext-cased-by-conda-cache
 * [new branch]        more-extra-transparency-fix-again -> origin/more-extra-transparency-fix-again
 * [new branch]        option-reduce-connecting-to-huggingface -> origin/option-reduce-connecting-to-huggingface
 * [new branch]        py-3.9-fix            -> origin/py-3.9-fix
 * [new branch]        reduce-server-request -> origin/reduce-server-request
 * [new branch]        refiner_alt           -> origin/refiner_alt
 * [new branch]        release_candidate     -> origin/release_candidate
 * [new branch]        revert-use-of-gitpython-hijack -> origin/revert-use-of-gitpython-hijack
 * [new branch]        server-reload-API     -> origin/server-reload-API
 * [new tag]           v1.10.1               -> v1.10.1
 * [new tag]           v1.1.0                -> v1.1.0
 * [new tag]           v1.1.1                -> v1.1.1
 * [new tag]           v1.10.0               -> v1.10.0
 * [new tag]           v1.10.0-RC            -> v1.10.0-RC
 * [new tag]           v1.2.0                -> v1.2.0
 * [new tag]           v1.2.1                -> v1.2.1
 * [new tag]           v1.3.0                -> v1.3.0
 * [new tag]           v1.3.0-RC             -> v1.3.0-RC
 * [new tag]           v1.3.1                -> v1.3.1
 * [new tag]           v1.3.1-RC             -> v1.3.1-RC
 * [new tag]           v1.3.2                -> v1.3.2
 * [new tag]           v1.3.2-RC             -> v1.3.2-RC
 * [new tag]           v1.4.0                -> v1.4.0
 * [new tag]           v1.4.0-RC             -> v1.4.0-RC
 * [new tag]           v1.4.1                -> v1.4.1
 * [new tag]           v1.5.0                -> v1.5.0
 * [new tag]           v1.5.0-RC             -> v1.5.0-RC
 * [new tag]           v1.5.1                -> v1.5.1
 * [new tag]           v1.5.1-RC             -> v1.5.1-RC
 * [new tag]           v1.5.2                -> v1.5.2
 * [new tag]           v1.5.2-RC             -> v1.5.2-RC
 * [new tag]           v1.6.0                -> v1.6.0
 * [new tag]           v1.6.0-RC             -> v1.6.0-RC
 * [new tag]           v1.6.1                -> v1.6.1
 * [new tag]           v1.7.0                -> v1.7.0
 * [new tag]           v1.7.0-RC             -> v1.7.0-RC
 * [new tag]           v1.8.0                -> v1.8.0
 * [new tag]           v1.8.0-RC             -> v1.8.0-RC
 * [new tag]           v1.9.0                -> v1.9.0
 * [new tag]           v1.9.0-RC             -> v1.9.0-RC
 * [new tag]           v1.9.1                -> v1.9.1
 * [new tag]           v1.9.2                -> v1.9.2
 * [new tag]           v1.9.3                -> v1.9.3
 * [new tag]           v1.9.4                -> v1.9.4
error: Your local changes to the following files would be overwritten by merge:
	.github/ISSUE_TEMPLATE/bug_report.yml
	.github/pull_request_template.md
	.github/workflows/on_pull_request.yaml
	.github/workflows/run_tests.yaml
	.gitignore
	README.md
	configs/alt-diffusion-inference.yaml
	configs/instruct-pix2pix.yaml
	configs/v1-inference.yaml
	configs/v1-inpainting-inference.yaml
	environment-wsl2.yaml
	extensions-builtin/LDSR/ldsr_model_arch.py
	extensions-builtin/LDSR/scripts/ldsr_model.py
	extensions-builtin/LDSR/sd_hijack_autoencoder.py
	extensions-builtin/LDSR/sd_hijack_ddpm_v1.py
	extensions-builtin/Lora/extra_networks_lora.py
	extensions-builtin/Lora/lora.py
	extensions-builtin/Lora/preload.py
	extensions-builtin/Lora/scripts/lora_script.py
	extensions-builtin/Lora/ui_extra_networks_lora.py
	extensions-builtin/ScuNET/scripts/scunet_model.py
	extensions-builtin/ScuNET/scunet_model_arch.py
	extensions-builtin/SwinIR/scripts/swinir_model.py
	extensions-builtin/SwinIR/swinir_model_arch.py
	extensions-builtin/SwinIR/swinir_model_arch_v2.py
	extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js
	html/extra-networks-card.html
	html/footer.html
	html/image-update.svg
	html/licenses.html
	javascript/aspectRatioOverlay.js
	javascript/contextMenus.js
	javascript/dragdrop.js
	javascript/edit-attention.js
	javascript/extensions.js
	javascript/extraNetworks.js
	javascript/generationParams.js
	javascript/hints.js
	javascript/hires_fix.js
	javascript/imageMaskFix.js
	javascript/imageParams.js
	javascript/imageviewer.js
	javascript/localization.js
	javascript/notification.js
	javascript/progressbar.js
	javascript/textualInversion.js
	javascript/ui.js
	launch.py
	modules/api/api.py
	modules/api/models.py
	modules/call_queue.py
	modules/cmd_args.py
	modules/codeformer/codeformer_arch.py
	modules/codeformer/vqgan_arch.py
	modules/codeformer_model.py
	modules/deepbooru.py
	modules/devices.py
	modules/errors.py
	modules/esrgan_model.py
	modules/esrgan_model_arch.py
	modules/extensions.py
	modules/extra_networks.py
	modules/extra_networks_hypernet.py
	modules/extras.py
	modules/generation_parameters_copypaste.py
	modules/gfpgan_model.py
	modules/hashes.py
	modules/hypernetworks/hypernetwork.py
	modules/hypernetworks/ui.py
	modules/images.py
	modules/img2img.py
	modules/import_hook.py
	modules/interrogate.py
	modules/localization.py
	modules/lowvram.py
	modules/mac_specific.py
	modules/masking.py
	modules/modelloader.py
	modules/models/diffusion/ddpm_edit.py
	modules/models/diffusion/uni_pc/__init__.py
	modules/models/diffusion/uni_pc/sampler.py
	modules/models/diffusion/uni_pc/uni_pc.py
	modules/ngrok.py
	modules/paths.py
	modules/paths_internal.py
	modules/postprocessing.py
	modules/processing.py
	modules/progress.py
	modules/prompt_parser.py
	modules/realesrgan_model.py
	modules/safe.py
	modules/script_callbacks.py
	modules/script_loading.py
	modules/scripts.py
	modules/scripts_auto_postprocessing.py
	modules/scripts_postprocessing.py
	modules/sd_disable_initialization.py
	modules/sd_hijack.py
	modules/sd_hijack_clip.py
	modules/sd_hijack_clip_old.py
	modules/sd_hijack_inpainting.py
	modules/sd_hijack_ip2p.py
	modules/sd_hijack_open_clip.py
	modules/sd_hijack_optimizations.py
	modules/sd_hijack_unet.py
	modules/sd_hijack_utils.py
	modules/sd_hijack_xlmr.py
	modules/sd_models.py
	modules/sd_models_config.py
	modules/sd_samplers.py
	modules/sd_samplers_common.py
	modules/sd_samplers_compvis.py
	modules/sd_samplers_kdiffusion.py
	modules/sd_vae.py
	modules/sd_vae_approx.py
	modules/shared.py
	modules/shared_items.py
	modules/styles.py
	modules/sub_quadratic_attention.py
	modules/textual_inversion/autocrop.py
	modules/textual_inversion/dataset.py
	modules/textual_inversion/image_embedding.py
	modules/textual_inversion/learn_schedule.py
	modules/textual_inversion/logging.py
	modules/textual_inversion/preprocess.py
	modules/textual_inversion/textual_inversion.py
	modules/textual_inversion/ui.py
	modules/timer.py
	modules/txt2img.py
	modules/ui.py
	modules/ui_common.py
	modules/ui_components.py
	modules/ui_extensio
Aborting
Merge with strategy ort failed.
```

インストール手順は以下の通り。

https://qiita.com/itohdaigo/items/602b54532ef0f333cc06

ただ、今回事前にXcodeをアンインストールしてしまっていたのが原因で、pythonのモジュールのインストールが最初うまくできなかった。
以下の2つのコマンドを実行してあげることで解決した。
```
xcode-select --install
brew install xz  
```
足りないモジュールは、lzmaというモジュールだった。pythonのバージョンなどを、以下の手順を参考にインストールする。

https://qiita.com/NOIZE/items/13cad682d089db86d840


その後、cloneコマンドを実行する。
```
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
```

cloneできたら、立ち上げを行う。
```
./webui.sh
```

このような出力結果がでてくる。`v1.10.1`で起動していたようだ。
```
################################################################
Launching launch.py...
################################################################
Python 3.10.0 (default, Feb 24 2025, 22:36:35) [Clang 16.0.0 (clang-1600.0.26.6)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
```

プロンプトは、過去に入れた内容と同じ内容をいれる。

最近のモデルを使ってみたいと思い、とりあえずこれを入れてみる。

https://civitai.com/models/827184/wai-nsfw-illustrious-sdxl

```
【プロンプト】
super fine illustration,an extremely cute and beautiful girl,highly detailed beautiful face and eyes,beautiful green pigtails hair,beautiful detailed jeans,solo, 1 girl,dynamic angle,cowboy shot,desolate deserts,shiney sun lighting,yellow tone
【ネガティブプロンプト】
EasyNegative
```

うーん、、なんか違う気がするな。普通すぎる。

![00001-2623976503.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1288524/014cae78-44b4-4f18-a964-405c5160edb9.png)

元の、Counterfeitv2.5で実行してみる。
*Counterfeitv3.0が出ているらしい。また試してみること。

https://huggingface.co/gsdf/Counterfeit-V3.0

まあ悪くない。とりあえず前回のクオリティを維持できている事は確認できた。
モデルを探すのはまた今度修正します。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1288524/e18257a4-1d9a-4284-86b4-566b95f4a22e.png)