Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v22.1.0 #1594

Merged
merged 50 commits into from
Oct 11, 2023
Merged

v22.1.0 #1594

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ef7bf31
Initial Intel ARC support with IPEX
Disty0 Sep 7, 2023
f8fa3f3
Fix SDP
Disty0 Sep 8, 2023
f2b6c46
Fix finetune
Disty0 Sep 11, 2023
15186d5
fix diffusers 0.21 lazy import
Disty0 Sep 14, 2023
c1a454f
Update SDPA slice rate
Disty0 Sep 17, 2023
97d60da
Fix SDPA
Disty0 Sep 18, 2023
912c9d0
Remove non GUI changes
Disty0 Sep 24, 2023
c8fcfd4
Add "venv" to extend-exclude
shirayu Oct 1, 2023
27f9b6f
updated typos to v1.16.15 and fix typos
shirayu Oct 1, 2023
13d8b22
Add dependabot
shirayu Oct 1, 2023
56ebef3
Merge pull request #848 from shirayu/update_typos
kohya-ss Oct 1, 2023
2d87bb6
Merge pull request #850 from kohya-ss/dev
kohya-ss Oct 1, 2023
6d06b21
Bump actions/checkout from 3 to 4
dependabot[bot] Oct 1, 2023
59789b1
"Chinese User.bat and useful readme"
boombbo Oct 2, 2023
5065194
Merge remote-tracking branch 'upstream/master'
Disty0 Oct 2, 2023
b07f780
Fix typo
Disty0 Oct 2, 2023
fd92e1c
Fix typo warning
Disty0 Oct 2, 2023
76473d0
Update IPEX index
Disty0 Oct 2, 2023
4c2f476
Merge pull request #1564 from boombbo/master
bmaltais Oct 3, 2023
f4667e5
Update lora_gui.py
sangoi-exe Oct 4, 2023
5920149
Support JPEG-XL on windows
Isotr0py Oct 4, 2023
90406d9
Merge pull request #1572 from DevArqSangoi/dev2
bmaltais Oct 4, 2023
1deb505
Merge pull request #1499 from Disty0/master
bmaltais Oct 4, 2023
93a181f
Remove torch 1 support from code
bmaltais Oct 4, 2023
a756f0a
More torch 1 code cleanup
bmaltais Oct 4, 2023
5216e6f
Move localization files to the library folder
bmaltais Oct 4, 2023
a4857fa
Add append_captions feature to wd14 tagger
a-l-e-x-d-s-9 Oct 5, 2023
9378da3
Fix comment
a-l-e-x-d-s-9 Oct 5, 2023
70fe7e1
add onnx to wd14 tagger
Isotr0py Oct 8, 2023
b8b8402
fix a typo
Isotr0py Oct 8, 2023
d6f458f
fix dependency
Isotr0py Oct 8, 2023
8b247a3
Merge pull request #851 from kohya-ss/dependabot/github_actions/actio…
kohya-ss Oct 9, 2023
5fe52ed
Merge pull request #856 from Isotr0py/jxl
kohya-ss Oct 9, 2023
025368f
may work dropout in LyCORIS #859
kohya-ss Oct 9, 2023
8a7509d
Merge branch 'dev' of https://github.com/kohya-ss/sd-scripts into dev
kohya-ss Oct 9, 2023
0faa350
Merge pull request #865 from kohya-ss/dev
kohya-ss Oct 9, 2023
1d7c5c2
Merge pull request #858 from a-l-e-x-d-s-9/main
kohya-ss Oct 9, 2023
0d4e8b5
change option to append_tags, minor update
kohya-ss Oct 9, 2023
07d297f
Merge branch 'dev' into onnx
kohya-ss Oct 9, 2023
8a2d68d
Merge pull request #864 from Isotr0py/onnx
kohya-ss Oct 9, 2023
406511c
add error message if model.onnx doesn't exist
kohya-ss Oct 9, 2023
66741c0
add OFT
kohya-ss Oct 9, 2023
cf49e91
update readme
kohya-ss Oct 9, 2023
8b79e3b
fix typos
kohya-ss Oct 9, 2023
33ee0ac
Merge pull request #867 from kohya-ss/dev
kohya-ss Oct 9, 2023
72494a6
fix: linting, spelling
sammcj Oct 10, 2023
e4419b2
Merge branch 'main' of https://github.com/kohya-ss/sd-scripts into dev2
bmaltais Oct 10, 2023
155fa42
Add GUI support for ONNX in WD 14
bmaltais Oct 11, 2023
9619a82
Merge branch 'dev2' into cleanup
bmaltais Oct 11, 2023
4b90b2f
Merge pull request #1589 from sammcj/cleanup
bmaltais Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
4 changes: 2 additions & 2 deletions .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: typos-action
uses: crate-ci/typos@v1.13.10
uses: crate-ci/typos@v1.16.15
113 changes: 64 additions & 49 deletions README.md

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions README_中文教程.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
嗨!我把日语 README 文件的主要内容翻译成中文如下:

## 关于这个仓库

这个是用于Stable Diffusion模型训练、图像生成和其他脚本的仓库。

[英文版 README](./README.md) <-- 更新信息在这里

GUI和PowerShell脚本等使其更易用的功能在[bmaltais的仓库](https://github.com/bmaltais/kohya_ss)(英语)中提供,一并参考。感谢bmaltais。

包含以下脚本:

* 支持DreamBooth、U-Net和文本编码器的训练
* fine-tuning的支持
* 图像生成
* 模型转换(Stable Diffusion ckpt/safetensors 和 Diffusers之间的相互转换)

## 使用方法 (中国用户只需要按照这个安装教程操作)
- 进入kohya_ss文件夹根目录下,点击 setup.bat 启动安装程序 *(需要科学上网)
- 根据界面上给出的英文选项:
Kohya_ss GUI setup menu:

1. Install kohya_ss gui
2. (Optional) Install cudann files (avoid unless you really need it)
3. (Optional) Install specific bitsandbytes versions
4. (Optional) Manually configure accelerate
5. (Optional) Start Kohya_ss GUI in browser
6. Quit

Enter your choice: 1

1. Torch 1 (legacy, no longer supported. Will be removed in v21.9.x)
2. Torch 2 (recommended)
3. Cancel

Enter your choice: 2

开始安装环境依赖,接着再出来的选项,按照下列选项操作:
```txt
- This machine
- No distributed training
- NO
- NO
- NO
- all
- bf16
```
--------------------------------------------------------------------
这里都选择完毕,即可关闭终端窗口,直接点击 gui.bat或者 kohya中文启动器.bat 即可运行kohya


当仓库内和note.com有相关文章,请参考那里。(未来可能全部移到这里)

* [关于训练,通用篇](./docs/train_README-ja.md): 数据准备和选项等
* [数据集设置](./docs/config_README-ja.md)
* [DreamBooth训练指南](./docs/train_db_README-ja.md)
* [fine-tuning指南](./docs/fine_tune_README_ja.md)
* [LoRA训练指南](./docs/train_network_README-ja.md)
* [文本反转训练指南](./docs/train_ti_README-ja.md)
* [图像生成脚本](./docs/gen_img_README-ja.md)
* note.com [模型转换脚本](https://note.com/kohya_ss/n/n374f316fe4ad)

## Windows环境所需程序

需要Python 3.10.6和Git。

- Python 3.10.6: https://www.python.org/ftp/python/3.10.6/python-3.10.6-amd64.exe
- git: https://git-scm.com/download/win

如果要在PowerShell中使用venv,需要按以下步骤更改安全设置:
(不仅仅是venv,使脚本可以执行。请注意。)

- 以管理员身份打开PowerShell
- 输入"Set-ExecutionPolicy Unrestricted",选择Y
- 关闭管理员PowerShell

## 在Windows环境下安装

下例中安装的是PyTorch 1.12.1/CUDA 11.6版。如果要使用CUDA 11.3或PyTorch 1.13,请适当修改。

(如果只显示"python",请将下例中的"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==1.12.1+cu116 torchvision==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
pip install --upgrade -r requirements.txt
pip install -U -I --no-deps https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl

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

accelerate config
```

在命令提示符中:

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

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

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
pip install --upgrade -r requirements.txt
pip install -U -I --no-deps https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl

copy /y .\bitsandbytes_windows\*.dll .\venv\Lib\site-packages\bitsandbytes\
copy /y .\bitsandbytes_windows\cextension.py .\venv\Lib\site-packages\bitsandbytes\cextension.py
copy /y .\bitsandbytes_windows\main.py .\venv\Lib\site-packages\bitsandbytes\cuda_setup\main.py

accelerate config
```

accelerate config的问题请按以下回答:
(如果要用bf16训练,最后一个问题选择bf16)

```
- 此计算机
- 不进行分布式训练
- 否
- 否
- 否
- 所有
- fp16
```

### PyTorch和xformers版本注意事项

在其他版本中训练可能失败。如果没有特殊原因,请使用指定版本。


### 可选:使用Lion8bit

如果要使用Lion8bit,需要将`bitsandbytes`升级到0.38.0以上。首先卸载`bitsandbytes`,然后在Windows中安装适合Windows的whl文件,例如[这里的](https://github.com/jllllll/bitsandbytes-windows-webui)。例如:

```powershell
pip install https://github.com/jllllll/bitsandbytes-windows-webui/raw/main/bitsandbytes-0.38.1-py3-none-any.whl
```

升级时用`pip install .`更新这个仓库,并视情况升级其他包。

### 可选:使用PagedAdamW8bit和PagedLion8bit

如果要使用PagedAdamW8bit和PagedLion8bit,需要将`bitsandbytes`升级到0.39.0以上。首先卸载`bitsandbytes`,然后在Windows中安装适合Windows的whl文件,例如[这里的](https://github.com/jllllll/bitsandbytes-windows-webui)。例如:

```powershell
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.39.1-py3-none-win_amd64.whl
```

升级时用`pip install .`更新这个仓库,并视情况升级其他包。

## 升级

如果有新版本,可以用以下命令更新:

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

如果命令成功,就可以使用新版本了。

## 致谢

LoRA实现基于[cloneofsimo的仓库](https://github.com/cloneofsimo/lora)。表示感谢。

将Conv2d 3x3扩展到所有层起初由 [cloneofsimo](https://github.com/cloneofsimo/lora) 发布, [KohakuBlueleaf](https://github.com/KohakuBlueleaf/LoCon) 证明了其有效性。深深感谢 KohakuBlueleaf。

## 许可

脚本遵循 ASL 2.0 许可,但包含其他许可的代码部分(Diffusers和cloneofsimo的仓库)。

[Memory Efficient Attention Pytorch](https://github.com/lucidrains/memory-efficient-attention-pytorch): MIT

[bitsandbytes](https://github.com/TimDettmers/bitsandbytes): MIT

[BLIP](https://github.com/salesforce/BLIP): BSD-3-Clause
20 changes: 19 additions & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,25 @@ parms="parms"
nin="nin"
extention="extention" # Intentionally left
nd="nd"
shs="shs"
sts="sts"
scs="scs"
cpc="cpc"
coc="coc"
cic="cic"
msm="msm"
usu="usu"
ici="ici"
lvl="lvl"
dii="dii"
muk="muk"
ori="ori"
hru="hru"
rik="rik"
koo="koo"
yos="yos"
wn="wn"


[files]
extend-exclude = ["_typos.toml"]
extend-exclude = ["_typos.toml", "venv"]
2 changes: 1 addition & 1 deletion converted_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ US&client=webapp&u=https://d.hatena.ne.jp/keyword/%25A5%25CB%25A5%25E5%25A1%25BC

このパラメータ値は常に25個の数字を指定しなければいけませんが、LoRAはAttentionブロックを学習対象としているので、Attentionブロックの存在しないIN0、IN3、IN6、IN9、IN10、IN11、OUT0、IN1、IN2に対する設定(1、4、7、11、12、14、15、16番目の数字)は学習時は無視されます。

※上級者向け設定です。こだわりがないなら空欄のままで構いません。ここを指定しない場合は「Network Rank(Dimention)」値と「Network
※上級者向け設定です。こだわりがないなら空欄のままで構いません。ここを指定しない場合は「Network Rank(Dimension)」値と「Network
Alpha」値がすべてのブロックに適応されます。


Expand Down
2 changes: 1 addition & 1 deletion dreambooth_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from library.class_sample_images import SampleImages, run_cmd_sample

from library.custom_logging import setup_logging
from localization_ext import add_javascript
from library.localization_ext import add_javascript

# Set up logging
log = setup_logging()
Expand Down
6 changes: 3 additions & 3 deletions fine_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def train(args):

current_epoch = Value("i", 0)
current_step = Value("i", 0)
ds_for_collater = train_dataset_group if args.max_data_loader_n_workers == 0 else None
collater = train_util.collater_class(current_epoch, current_step, ds_for_collater)
ds_for_collator = train_dataset_group if args.max_data_loader_n_workers == 0 else None
collator = train_util.collator_class(current_epoch, current_step, ds_for_collator)

if args.debug_dataset:
train_util.debug_dataset(train_dataset_group)
Expand Down Expand Up @@ -208,7 +208,7 @@ def fn_recursive_set_mem_eff(module: torch.nn.Module):
train_dataset_group,
batch_size=1,
shuffle=True,
collate_fn=collater,
collate_fn=collator,
num_workers=n_workers,
persistent_workers=args.persistent_data_loader_workers,
)
Expand Down
Loading