0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

2025年4月時点での sd-webui-train-tools 導入方法

Posted at

Stable Diffusion Web UI の拡張機能 sd-webui-train-tools の導入方法です。

拡張機能 sd-webui-train-tools を導入するには Stable Diffusion Web UI をダウングレードする必要があります。
複数の解説ページにて、stable-diffusion-webui のApr 4, 2023のコミットである
Commit ID(Commit hash): 80752f43b22acd85bf6ab54b2e4788f144a0c813
が train-tools を動かすのに必要と言われていますが、2025年4月時点では、それでは動作しません。
過去の同じバージョンを導入しているのになぜ今だと動かないのか?
おそらく動作環境が変わっている、つまり依存関係にある他のソフトウェアのバージョンが今では異なっているためかと思われます。

sd-webui-train-tools の最終コミットは Mar 28, 2024 です。
この時点にあわせることを考えます。
なお、Stable Diffusion Web UI は、すべてのコミットを見ても、修正途中のソースが混じっているのか、動かせないものがほとんどなので、リリース版の中から選択します。
必要なのは、
Releases 1.8.0 (Mar 2, 2024)
Commit ID(Commit hash): bef51aed032c0aaa5cfd80445bc4cf0d85b408b5
です。

stable-diffusion-webuiを通常の手順でインストールすると最新版になっています。
ここから上記コミットIDを指定してダウングレードします。
stable-diffusion-webui のフォルダ上で、Git Bash のコンソールから(コマンドプロンプトや、「ターミナルで開く」→PowerShellコンソール からでもおそらく同じ)
git checkout bef51aed032c0aaa5cfd80445bc4cf0d85b408b5
を実行します。

(参考)【Stable Diffusion Web UI】アップデート・ダウングレードの方法
https://soroban.highreso.jp/article/article-045

これで webui-user.bat を起動すると、画面下部のバージョン表示が
version: v1.8.0
になっているはずです。

次に sd-webui-train-tools をインストールします。
[Extensions]タブから、[Install from URL]に
https://github.com/liasece/sd-webui-train-tools
を入力して[Install]ボタンを押すと、このURLのGitHubからダウンロードされ「extensions」フォルダに入ります。
[Installed]タブからも、インストールされていることが確認できるはずです。

しかしそのままでは動かないので、[Apply and restart UI]ボタンは押さずに、Stable Diffusion Web UIを終了させてリソースの修正をかけます。

numpyのダウングレード

numpy 1.24.2 リリース日: 2023年2月6日
を適用します。
pip uninstall numpy
pip install numpy=1.24.2

修正(1)

(参考: https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11312427706
sd-webui-train-toolsフォルダの中にある
requirements.txtを編集して、「huggingface-hub」に
バージョンを追記する

huggingface-hub==0.25.2

修正(2)

(参考: https://fedor-hidor.blog.jp/archives/26127416.html
stable-diffusion-webui\modules フォルダの中にある
sd_models.py 721~730行目を次のとおり修正

    #try:
    #    with sd_disable_initialization.DisableInitialization(disable_clip=clip_is_included_into_sd or shared.cmd_opts.do_not_download_clip):
    #        with sd_disable_initialization.InitializeOnMeta():
    #            sd_model = instantiate_from_config(sd_config.model)
    #
    #except Exception as e:
    #    errors.display(e, "creating model quickly", full_traceback=True)

    if sd_model is None:
        #print('Failed to create model quickly; will retry using slow method.', file=sys.stderr)
        print('Creating model using slow method.', file=sys.stderr)

修正(3)

(参考: https://github.com/Mikubill/sd-webui-controlnet/issues/2136
stable-diffusion-webui\venv\Lib\site-packages\gradio フォルダの中にある
blocks.py 286行目

修正前
            "inputs": [block._id for block in inputs],
修正後
            "inputs": [block._id for block in inputs if block is not None],

これで、webui-user.bat から Stable Diffusion Web UI を起動すると、無事「Train Tools」タブが増えています。

※ 過去の他の解説ページの方法が現在ではうまくいかなくなっているのと同様、この方法もいずれ時がたつにつれダメになるかもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?