
今更sd-webuiでSDXLのDreamBooth(フルファインチューニング)
以下の記事でSDXLのフルファインチューニング手順を紹介していますが、時間が経ち、色々動かなくなっているので、再度手順を紹介します。
また、↑の記事を作成した時は、派生モデルもファインチューニングできる手順でしたが、今やるとベースモデルをファインチューニングする手順になるようなので、改めて派生モデルを含めたフルファインチューニングを紹介します。
↓ベースモデル
↓今回フルファインチューニングする派生モデル
動画でも解説してます。
環境
OS:Windows 11
GPU:GeForce RTX 4090
CPU:i9-13900KF
memory:128G
事前インストール
・Python 3.10 or 3.11
・Git
環境構築
前提として、今回の手順ではStable Diffusion WebUIを利用し、このWebUIはDreamBooth専用の環境となります。
また、フルファインチューニングの手順のため、VRAMも22GB程度必要です。(設定次第では16GBぐらいでも行けるみたいですが。)
自分が調べて限りだと、これ以外でSDXLのDreamBoothを試す手段はほとんど存在しないと思います。
コマンドプロンプトで、以下のコマンドを実行します。
:: webuiをダウンロード
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
:: 初回起動(依存の自動セットアップが走る)
webui-user.bat
venv "E:\DeepLearning\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121
Collecting torch==2.1.2
Using cached https://download.pytorch.org/whl/cu121/torch-2.1.2%2Bcu121-cp310-cp310-win_amd64.whl (2473.9 MB)
Collecting torchvision==0.16.2
Using cached https://download.pytorch.org/whl/cu121/torchvision-0.16.2%2Bcu121-cp310-cp310-win_amd64.whl (5.6 MB)
Collecting filelock (from torch==2.1.2)
Using cached filelock-3.19.1-py3-none-any.whl.metadata (2.1 kB)
Collecting typing-extensions (from torch==2.1.2)
Using cached typing_extensions-4.15.0-py3-none-any.whl.metadata (3.3 kB)
Collecting sympy (from torch==2.1.2)
Using cached sympy-1.14.0-py3-none-any.whl.metadata (12 kB)
Collecting networkx (from torch==2.1.2)
Using cached networkx-3.4.2-py3-none-any.whl.metadata (6.3 kB)
Collecting jinja2 (from torch==2.1.2)
Using cached jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)
Collecting fsspec (from torch==2.1.2)
Using cached fsspec-2025.9.0-py3-none-any.whl.metadata (10 kB)
Collecting numpy (from torchvision==0.16.2)
Using cached numpy-2.2.6-cp310-cp310-win_amd64.whl.metadata (60 kB)
Collecting requests (from torchvision==0.16.2)
Using cached requests-2.32.5-py3-none-any.whl.metadata (4.9 kB)
Collecting pillow!=8.3.*,>=5.3.0 (from torchvision==0.16.2)
Using cached pillow-11.3.0-cp310-cp310-win_amd64.whl.metadata (9.2 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch==2.1.2)
Using cached MarkupSafe-3.0.2-cp310-cp310-win_amd64.whl.metadata (4.1 kB)
Collecting charset_normalizer<4,>=2 (from requests->torchvision==0.16.2)
Using cached charset_normalizer-3.4.3-cp310-cp310-win_amd64.whl.metadata (37 kB)
Collecting idna<4,>=2.5 (from requests->torchvision==0.16.2)
Using cached idna-3.10-py3-none-any.whl.metadata (10 kB)
Collecting urllib3<3,>=1.21.1 (from requests->torchvision==0.16.2)
Using cached urllib3-2.5.0-py3-none-any.whl.metadata (6.5 kB)
Collecting certifi>=2017.4.17 (from requests->torchvision==0.16.2)
Using cached certifi-2025.8.3-py3-none-any.whl.metadata (2.4 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy->torch==2.1.2)
Using cached https://download.pytorch.org/whl/mpmath-1.3.0-py3-none-any.whl (536 kB)
Using cached pillow-11.3.0-cp310-cp310-win_amd64.whl (7.0 MB)
Using cached filelock-3.19.1-py3-none-any.whl (15 kB)
Using cached fsspec-2025.9.0-py3-none-any.whl (199 kB)
Using cached jinja2-3.1.6-py3-none-any.whl (134 kB)
Using cached MarkupSafe-3.0.2-cp310-cp310-win_amd64.whl (15 kB)
Using cached networkx-3.4.2-py3-none-any.whl (1.7 MB)
Using cached numpy-2.2.6-cp310-cp310-win_amd64.whl (12.9 MB)
Using cached requests-2.32.5-py3-none-any.whl (64 kB)
Using cached charset_normalizer-3.4.3-cp310-cp310-win_amd64.whl (107 kB)
Using cached idna-3.10-py3-none-any.whl (70 kB)
Using cached urllib3-2.5.0-py3-none-any.whl (129 kB)
Using cached certifi-2025.8.3-py3-none-any.whl (161 kB)
Using cached sympy-1.14.0-py3-none-any.whl (6.3 MB)
Using cached typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Installing collected packages: mpmath, urllib3, typing-extensions, sympy, pillow, numpy, networkx, MarkupSafe, idna, fsspec, filelock, charset_normalizer, certifi, requests, jinja2, torch, torchvision
Successfully installed MarkupSafe-3.0.2 certifi-2025.8.3 charset_normalizer-3.4.3 filelock-3.19.1 fsspec-2025.9.0 idna-3.10 jinja2-3.1.6 mpmath-1.3.0 networkx-3.4.2 numpy-2.2.6 pillow-11.3.0 requests-2.32.5 sympy-1.14.0 torch-2.1.2+cu121 torchvision-0.16.2+cu121 typing-extensions-4.15.0 urllib3-2.5.0
Installing clip
Installing open_clip
Cloning assets into E:\DeepLearning\stable-diffusion-webui\repositories\stable-diffusion-webui-assets...
Cloning into 'E:\DeepLearning\stable-diffusion-webui\repositories\stable-diffusion-webui-assets'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (18/18), done.
Receiving objects: 100% (20/20), 132.70 KiB | 44.23 MiB/s, done.from 0)Receiving objects: 100% (20/20)
Cloning Stable Diffusion into E:\DeepLearning\stable-diffusion-webui\repositories\stable-diffusion-stability-ai...
Cloning into 'E:\DeepLearning\stable-diffusion-webui\repositories\stable-diffusion-stability-ai'...
remote: Enumerating objects: 586, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 586 (delta 1), reused 0 (delta 0), pack-reused 580 (from 4)Receiving objects: 97% (569/586), 67.67 MiB | Receiving objects: 99% (581/586), 67.67 MiB | 22.17 MiB/s
Receiving objects: 100% (586/586), 73.45 MiB | 22.21 MiB/s, done.
Resolving deltas: 100% (282/282), done.
Cloning Stable Diffusion XL into E:\DeepLearning\stable-diffusion-webui\repositories\generative-models...
Cloning into 'E:\DeepLearning\stable-diffusion-webui\repositories\generative-models'...
remote: Enumerating objects: 1108, done.
remote: Counting objects: 100% (532/532), done.
remote: Compressing objects: 100% (166/166), done.
remote: Total 1108 (delta 413), reused 366 (delta 366), pack-reused 576 (from 3)Receiving objects: 98% (1086/1108), 79.Receiving objects: 99% (1097/1108), 79.86 MiB | 22.82 MiB/s
Receiving objects: 100% (1108/1108), 86.65 MiB | 22.72 MiB/s, done.
Resolving deltas: 100% (578/578), done.
Updating files: 100% (148/148), done.
Cloning K-diffusion into E:\DeepLearning\stable-diffusion-webui\repositories\k-diffusion...
Cloning into 'E:\DeepLearning\stable-diffusion-webui\repositories\k-diffusion'...
remote: Enumerating objects: 1350, done.
remote: Counting objects: 100% (651/651), done.
Receiving objects: 100% (1350/1350), 239.59 KiB | 17.11 MiB/s, done.37/1350)
remote: Compressing objects: 100% (87/87), done.
remote: Total 1350 (delta 608), reused 566 (delta 564), pack-reused 699 (from 1)
Resolving deltas: 100% (948/948), done.
Cloning BLIP into E:\DeepLearning\stable-diffusion-webui\repositories\BLIP...
Cloning into 'E:\DeepLearning\stable-diffusion-webui\repositories\BLIP'...
remote: Enumerating objects: 277, done.
remote: Counting objects: 100% (183/183), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 277 (delta 145), reused 137 (delta 137), pack-reused 94 (from 1)Receiving objects: 100% (277/277)
Receiving objects: 100% (277/277), 7.04 MiB | 25.28 MiB/s, done.
Resolving deltas: 100% (152/152), done.
Installing requirements
Launching Web UI with arguments:
E:\DeepLearning\stable-diffusion-webui\venv\lib\site-packages\timm\models\layers\__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to E:\DeepLearning\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
100%|█████████████████████████████████████████████████████████████████████████████| 3.97G/3.97G [00:50<00:00, 84.1MB/s]
Calculating sha256 for E:\DeepLearning\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors: Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 653.6s (prepare environment: 561.5s, import torch: 21.4s, import gradio: 5.3s, setup paths: 2.7s, import ldm: 0.2s, initialize shared: 1.3s, other imports: 3.9s, list SD models: 51.2s, load scripts: 3.5s, initialize extra networks: 0.2s, create ui: 1.3s, gradio launch: 0.8s).正常にコマンドが実行できれば、以下のURLで画面が開きます。
http://127.0.0.1:7860/

画像生成だけ、動作確認します。
以下だけ設定して生成します。

綺麗な画像が生成できました。

動作確認もできたので、DreamBoothの拡張機能をインストールします。
「Extensions」タブを開く。

「Available」タブを開く。

「Load from」をクリックする。

「dreambooth」で拡張機能を検索し、「Install」をクリックする。

Initializing Dreambooth
Dreambooth revision: 65c647473d2949eed3e62e97fc1b3146ffc9b788
Checking xformers...
Checking bitsandbytes...
Checking bitsandbytes (ALL!)
Installing bitsandbytes
Successfully installed bitsandbytes-0.47.0 torch-2.8.0
Checking Dreambooth requirements...
[Installed version of accelerate: 0.21.0
[Dreambooth] accelerate v0.21.0 is already installed.
[Installed version of bitsandbytes: 0.47.0
[Dreambooth] bitsandbytes v0.45.2 is already installed.
[Dreambooth] dadaptation v3.2 is not installed.
Successfully installed dadaptation-3.2
[Dreambooth] diffusers v0.32.2 is not installed.
Successfully installed diffusers-0.35.1 importlib_metadata-8.7.0 zipp-3.23.0
[Dreambooth] discord-webhook v1.3.1 is not installed.
Successfully installed discord-webhook-1.4.1
[Installed version of fastapi: 0.94.0
[Dreambooth] fastapi v0.94.0 is already installed.
[Installed version of gitpython: 3.1.32
[Dreambooth] gitpython v3.1.32 is already installed.
[Installed version of pillow: 9.5.0
[Dreambooth] pillow v11.3.0 is not installed.
Successfully installed pillow-11.3.0
[Dreambooth] pytorch_optimizer v3.4.0 is not installed.
Successfully installed pytorch_optimizer-3.8.0
[Installed version of tomesd: 0.1.3
[Dreambooth] tomesd v0.1.3 is already installed.
[Installed version of tqdm: 4.67.1
[Dreambooth] tqdm v4.67.1 is already installed.
[Installed version of transformers: 4.30.2
[Dreambooth] transformers v4.49.0 is not installed.
Successfully installed safetensors-0.6.2 tokenizers-0.22.0 transformers-4.56.1
[Dreambooth] xformers v0.0.27.post2 is not installed.
Successfully installed xformers-0.0.32.post2
[Dreambooth] tensorboard v2.18.0 is not installed.
Successfully installed absl-py-2.3.1 grpcio-1.74.0 markdown-3.9 tensorboard-2.20.0 tensorboard-data-server-0.7.2 werkzeug-3.1.3
[+] accelerate version 0.21.0 installed.
[+] diffusers version 0.35.1 installed.
[+] transformers version 4.56.1 installed.
[+] bitsandbytes version 0.47.0 installed.
[+] xformers version 0.0.32.post2 installed.完了したら、リスタートを要求されます。

「installed」タブをクリックして、「Apply and restart UI」をクリックします。

でました。
誰かが文句言ってます。
[+] accelerate version 0.21.0 installed.
[+] diffusers version 0.35.1 installed.
[+] transformers version 4.56.1 installed.
[+] bitsandbytes version 0.47.0 installed.
[+] xformers version 0.0.32.post2 installed.
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Traceback (most recent call last):
File "E:\DeepLearning\stable-diffusion-webui\launch.py", line 48, in <module>
main()
File "E:\DeepLearning\stable-diffusion-webui\launch.py", line 39, in main
prepare_environment()
File "E:\DeepLearning\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
続行するには何かキーを押してください . . .「stable-diffusion-webui\webui-user.bat」ファイルを以下のように修正します。
@echo off
set PYTHON=
set GIT=
set VENV_DIR=
set TORCH_COMPILE=0
set TORCHDYNAMO_DISABLE=1
set COMMANDLINE_ARGS=--skip-install
call webui.batこれらはPyTorchの新しい最適化機能を無効化します。
・TORCH_COMPILE=0: PyTorch 2.0のtorch.compile()機能を無効化
・TORCHDYNAMO_DISABLE=1: TorchDynamoコンパイラを無効化
・COMMANDLINE_ARGS=--skip-install: 最初のインストール処理を無効か
以下のコマンドでライブラリを入れなおす。
# 仮想環境をアクティベート
.\venv\Scripts\activate
python.exe -m pip install --upgrade pip
# 現在のPyTorchをアンインストール
pip uninstall torch torchvision torchaudio xformers
# PyTorch と xformers、 triton の再インストール
pip install torch==2.6.0+cu124 torchvision==0.21.0+cu124 torchaudio==2.6.0+cu124 --index-url https://download.pytorch.org/whl/cu124
pip install xformers --index-url https://download.pytorch.org/whl/cu124
pip install -U "triton-windows<3.3"ライブラリの入れなおしが完了したら、以下のコマンドを実行して、WebUIを起動する。
webui-user.bat
これで環境構築完了。
トレーニング
「Dreambooth」タブを開きます。

「model > Create」タブで以下の設定を入力して、「Create Model」をクリックする。

以下の設定にします。Source CheckpointはSDXLモデルであれば、何を選んでも問題ないです。何を選んでもベースモデルがダウンロードされます。

「models > dreambooth」フォルダに以下のフォルダが作成されます。
この時に作成される「working」フォルダが↑で何を選んでもベースモデルのダウンロードされる理由で、ベースモデルの関連ファイルがダウンロードされています。

以下から必要なworklingフォルダ配下をダウンロードします。
ベースモデルをトレーニングするの場合も、派生モデルをトレーニングする場合も、同様の手順でダウンロード可能です。
■ベースモデル
■illustriousSemi_v30
■meinaXL_v2
上記のどのURLでも以下のようなページが開きます。

三点アイコンから「Clone repository」をクリックします。

以下の画面が表示されるので、「git clone」コマンドを取得します。

以下が必要なコマンドです。
git clone https://huggingface.co/John6666/meinaxl-v2-sdxl以下のフォルダでコマンドプロンプトを開き、↑のコマンドを実行すると、以下のようになります。

今ある「working」フォルダは不要なので、以下のコマンドで必要なフォルダと差し替えます。
rmdir /s /q working
ren meinaxl-v2-sdxl working上記のコマンドで、以下のようになります。

次に、以下のコマンドで、unetフォルダに格納されている「.safetensors」拡張子のファイルを「.bin」拡張子のファイルに変換します。
パスなどについては適宜修正が必要です。
「.safetensors」だとVRAMが26GBぐらいまで使用され、学習が終わりません。また、「diffusion_pytorch_model.safetensors」をそのままのファイル名でフォルダに残しておくと、そちらを参照する可能性があるので、名前を変更します。
cd working\unet
E:\DeepLearning\stable-diffusion-webui\venv\Scripts\python -c "from safetensors.torch import load_file; import torch; sd=load_file('diffusion_pytorch_model.safetensors'); torch.save(sd, 'diffusion_pytorch_model.bin')"
ren diffusion_pytorch_model.safetensors old_diffusion_pytorch_model.safetensors
再度、WubUIを表示し、先程作成したModel名になっていることを確認する。

「Concepts > Instance Images」タブを開き、必要情報を入力する。(データセットのフォルダさえ間違えなければ、後は適当でもなんとかなります。)

今回のデータセットは以下を使います。

「Concepts > Class Images」タブを開き、必要情報を入力する。(データセットのフォルダさえ間違えなければ、後は適当でもなんとかなります。)

「Settings > Parameters」タブを開き、必要情報を入力します。

「Save Settings」をクリックして、設定を保存します。

以下のポップアップが表示されたら「OK」をクリックします。

「Train」をクリックします。

以下のポップアップが表示されたら「OK」をクリックします。

生成時間は1時間半、VRAM22GBでトレーニングが完了しました。
もし、一度でもトレーニングを中断した場合は、「Create Model」からやり直す必要があります。

以下のフォルダに学習済みファイルが出力されます。

生成結果比較
チューニング前と後で、同一seed・同一promptで生成した結果です。
■ベースモデル




■illustriousSemi_v30




■meinaXL_v2




オススメ
今回は手順紹介がメインなので、早め(90分)に学習が完了するようにTraining Steps Per Imageを100にしていますが、これを1000にして、15時間ぐらいVRAM漬けにするのがオススメです。

Nano Bananaが猛威を振るい時代に、img2imgで同一人物のupscaleができる手段の1つになればと思ってます。
