文件最后提交记录最后更新时间
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!6121 【built-in】[Pytorch][sd-scripts-xl] Replace sdxl-scripts-xl text encoder with the MT5 model. Merge pull request !6121 from mhh001/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!6121 【built-in】[Pytorch][sd-scripts-xl] Replace sdxl-scripts-xl text encoder with the MT5 model. Merge pull request !6121 from mhh001/master 2 年前
!6160 【bugfix】[Pytorch][sdxl-scripts-xl] fix sdxl gatherv2 error Merge pull request !6160 from mhh001/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!7376 optimize public_address_statement.md Merge pull request !7376 from 王凯宇/master 8 个月前
!6165 【built-in】[Pytorch][SDXL] Modify the readme file. Merge pull request !6165 from mhh001/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!6312 【Fix】[Pytorch][SDXL] Fix bugs about dataloader Merge pull request !6312 from 王仕虓/master 2 年前
!6545 [Pytorch][built-in][SDXL] Adapt to auto profiling for sdxl mt5 Merge pull request !6545 from liuqiyuan/master 1 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
!5915 [built-in][PyTorch][sd-scripts-xl]Submit sd-scripts-xl source code Merge pull request !5915 from 肖雅敏/master 2 年前
README.md

SDXLがサポートされました。sdxlブランチはmainブランチにマージされました。リポジトリを更新したときにはUpgradeの手順を実行してください。また accelerate のバージョンが上がっていますので、accelerate config を再度実行してください。

SDXL学習についてはこちらをご覧ください(英語です)。

リポジトリについて

Stable Diffusionの学習、画像生成、その他のスクリプトを入れたリポジトリです。

README in English ←更新情報はこちらにあります

GUIやPowerShellスクリプトなど、より使いやすくする機能がbmaltais氏のリポジトリで提供されています(英語です)のであわせてご覧ください。bmaltais氏に感謝します。

以下のスクリプトがあります。

  • DreamBooth、U-NetおよびText Encoderの学習をサポート
  • fine-tuning、同上
  • LoRAの学習をサポート
  • 画像生成
  • モデル変換(Stable Diffision ckpt/safetensorsとDiffusersの相互変換)

使用法について

Windowsでの動作に必要なプログラム

Python 3.10.6およびGitが必要です。

PowerShellを使う場合、venvを使えるようにするためには以下の手順でセキュリティ設定を変更してください。 (venvに限らずスクリプトの実行が可能になりますので注意してください。)

  • PowerShellを管理者として開きます。
  • 「Set-ExecutionPolicy Unrestricted」と入力し、Yと答えます。
  • 管理者のPowerShellを閉じます。

Windows環境でのインストール

スクリプトはPyTorch 2.0.1でテストしています。PyTorch 1.12.1でも動作すると思われます。

以下の例ではPyTorchは2.0.1/CUDA 11.8版をインストールします。CUDA 11.6版やPyTorch 1.12.1を使う場合は適宜書き換えください。

(なお、python -m venv~の行で「python」とだけ表示された場合、py -m venv~のようにpythonをpyに変更してください。)

PowerShellを使う場合、通常の(管理者ではない)PowerShellを開き以下を順に実行します。

git clone https://github.com/kohya-ss/sd-scripts.git
cd sd-scripts

python -m venv venv
.\venv\Scripts\activate

pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu118
pip install --upgrade -r requirements.txt
pip install xformers==0.0.20

accelerate config

コマンドプロンプトでも同一です。

(注:python -m venv venv のほうが python -m venv --system-site-packages venv より安全そうなため書き換えました。globalなpythonにパッケージがインストールしてあると、後者だといろいろと問題が起きます。)

accelerate configの質問には以下のように答えてください。(bf16で学習する場合、最後の質問にはbf16と答えてください。)

※0.15.0から日本語環境では選択のためにカーソルキーを押すと落ちます(……)。数字キーの0、1、2……で選択できますので、そちらを使ってください。

- This machine
- No distributed training
- NO
- NO
- NO
- all
- fp16

※場合によって ValueError: fp16 mixed precision requires a GPU というエラーが出ることがあるようです。この場合、6番目の質問( What GPU(s) (by id) should be used for training on this machine as a comma-separated list? [all]:)に「0」と答えてください。(id 0のGPUが使われます。)

オプション:bitsandbytes(8bit optimizer)を使う

bitsandbytesはオプションになりました。Linuxでは通常通りpipでインストールできます(0.41.1または以降のバージョンを推奨)。

Windowsでは0.35.0または0.41.1を推奨します。

  • bitsandbytes 0.35.0: 安定しているとみられるバージョンです。AdamW8bitは使用できますが、他のいくつかの8bit optimizer、学習時のfull_bf16オプションは使用できません。
  • bitsandbytes 0.41.1: Lion8bit、PagedAdamW8bit、PagedLion8bitをサポートします。full_bf16が使用できます。

注:bitsandbytes 0.35.0から0.41.0までのバージョンには問題があるようです。 https://github.com/TimDettmers/bitsandbytes/issues/659

以下の手順に従い、bitsandbytesをインストールしてください。

0.35.0を使う場合

PowerShellの例です。コマンドプロンプトではcpの代わりにcopyを使ってください。

cd sd-scripts
.\venv\Scripts\activate
pip install bitsandbytes==0.35.0

cp .\bitsandbytes_windows\*.dll .\venv\Lib\site-packages\bitsandbytes\
cp .\bitsandbytes_windows\cextension.py .\venv\Lib\site-packages\bitsandbytes\cextension.py
cp .\bitsandbytes_windows\main.py .\venv\Lib\site-packages\bitsandbytes\cuda_setup\main.py

0.41.1を使う場合

jllllll氏の配布されているこちら または他の場所から、Windows用のwhlファイルをインストールしてください。

python -m pip install bitsandbytes==0.41.1 --prefer-binary --extra-index-url=https://jllllll.github.io/bitsandbytes-windows-webui

アップグレード

新しいリリースがあった場合、以下のコマンドで更新できます。

cd sd-scripts
git pull
.\venv\Scripts\activate
pip install --use-pep517 --upgrade -r requirements.txt

コマンドが成功すれば新しいバージョンが使用できます。

謝意

LoRAの実装はcloneofsimo氏のリポジトリを基にしたものです。感謝申し上げます。

Conv2d 3x3への拡大は cloneofsimo氏 が最初にリリースし、KohakuBlueleaf氏が LoCon でその有効性を明らかにしたものです。KohakuBlueleaf氏に深く感謝します。

ライセンス

スクリプトのライセンスはASL 2.0ですが(Diffusersおよびcloneofsimo氏のリポジトリ由来のものも同様)、一部他のライセンスのコードを含みます。

Memory Efficient Attention Pytorch: MIT

bitsandbytes: MIT

BLIP: BSD-3-Clause