This repository contains training, generation and utility scripts for Stable Diffusion.
[__Change History__](#change-history) is moved to the bottom of the page.
更新履歴は[ページ末尾](#change-history)に移しました。
[日本語版READMEはこちら](./README-ja.md)
For easier use (GUI and PowerShell scripts etc...), please visit [the repository maintained by bmaltais](https://github.com/bmaltais/kohya_ss). Thanks to @bmaltais!
This repository contains the scripts for:
* DreamBooth training, including U-Net and Text Encoder
* Fine-tuning (native training), including U-Net and Text Encoder
* LoRA training
* Textual Inversion training
* Image generation
* Model conversion (supports 1.x and 2.x, Stable Diffision ckpt/safetensors and Diffusers)
## About requirements.txt
The file does not contain requirements for PyTorch. Because the version of PyTorch depends on the environment, it is not included in the file. Please install PyTorch first according to the environment. See installation instructions below.
The scripts are tested with Pytorch 2.1.2. 2.0.1 and 1.12.1 is not tested but should work.
## Links to usage documentation
Most of the documents are written in Japanese.
[English translation by darkstorm2150 is here](https://github.com/darkstorm2150/sd-scripts#links-to-usage-documentation). Thanks to darkstorm2150!
* [Training guide - common](./docs/train_README-ja.md) : data preparation, options etc...
* [Chinese version](./docs/train_README-zh.md)
* [SDXL training](./docs/train_SDXL-en.md) (English version)
* [Dataset config](./docs/config_README-ja.md)
* [English version](./docs/config_README-en.md)
* [DreamBooth training guide](./docs/train_db_README-ja.md)
* [Step by Step fine-tuning guide](./docs/fine_tune_README_ja.md):
* [Training LoRA](./docs/train_network_README-ja.md)
* [Training Textual Inversion](./docs/train_ti_README-ja.md)
* [Image generation](./docs/gen_img_README-ja.md)
* note.com [Model conversion](https://note.com/kohya_ss/n/n374f316fe4ad)
## Windows Required Dependencies
Python 3.10.6 and 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
Give unrestricted script access to powershell so venv can work:
- Open an administrator powershell window
- Type `Set-ExecutionPolicy Unrestricted` and answer A
- Close admin powershell window
## Windows Installation
Open a regular Powershell terminal and type the following inside:
```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.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118
pip install --upgrade -r requirements.txt
pip install xformers==0.0.23.post1 --index-url https://download.pytorch.org/whl/cu118
accelerate config
```
If `python -m venv` shows only `python`, change `python` to `py`.
__Note:__ Now `bitsandbytes==0.43.0`, `prodigyopt==1.0` and `lion-pytorch==0.0.6` are included in the requirements.txt. If you'd like to use the another version, please install it manually.
This installation is for CUDA 11.8. If you use a different version of CUDA, please install the appropriate version of PyTorch and xformers. For example, if you use CUDA 12, please install `pip install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu121` and `pip install xformers==0.0.23.post1 --index-url https://download.pytorch.org/whl/cu121`.
<!--
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
-->
Answers to accelerate config:
```txt
- This machine
- No distributed training
- NO
- NO
- NO
- all
- fp16
```
If you'd like to use bf16, please answer `bf16` to the last question.
Note: Some user reports ``ValueError: fp16 mixed precision requires a GPU`` is occurred in training. In this case, answer `0` for the 6th question:
``What GPU(s) (by id) should be used for training on this machine as a comma-separated list? [all]:``
(Single GPU with id `0` will be used.)
## Upgrade
When a new release comes out you can upgrade your repo with the following command:
```powershell
cd sd-scripts
git pull
.\venv\Scripts\activate
pip install --use-pep517 --upgrade -r requirements.txt
```
Once the commands have completed successfully you should be ready to use the new version.
### Upgrade PyTorch
If you want to upgrade PyTorch, you can upgrade it with `pip install` command in [Windows Installation](#windows-installation) section. `xformers` is also required to be upgraded when PyTorch is upgraded.
## Credits
The implementation for LoRA is based on [cloneofsimo's repo](https://github.com/cloneofsimo/lora). Thank you for great work!
The LoRA expansion to Conv2d 3x3 was initially released by cloneofsimo and its effectiveness was demonstrated at [LoCon](https://github.com/KohakuBlueleaf/LoCon) by KohakuBlueleaf. Thank you so much KohakuBlueleaf!
## License
The majority of scripts is licensed under ASL 2.0 (including codes from Diffusers, cloneofsimo's and LoCon), however portions of the project are available under separate license terms:
[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
## Change History
### Sep 13, 2024 / 2024-09-13:
- `sdxl_merge_lora.py` now supports OFT. Thanks to Maru-mee for the PR [#1580](https://github.com/kohya-ss/sd-scripts/pull/1580).
- `svd_merge_lora.py` now supports LBW. Thanks to terracottahaniwa. See PR [#1575](https://github.com/kohya-ss/sd-scripts/pull/1575) for details.
- `sdxl_merge_lora.py` also supports LBW.
- See [LoRA Block Weight](https://github.com/hako-mikan/sd-webui-lora-block-weight) by hako-mikan for details on LBW.
- These will be included in the next release.
- `sdxl_merge_lora.py` が OFT をサポートされました。PR [#1580](https://github.com/kohya-ss/sd-scripts/pull/1580) Maru-mee 氏に感謝します。
- `svd_merge_lora.py` で LBW がサポートされました。PR [#1575](https://github.com/kohya-ss/sd-scripts/pull/1575) terracottahaniwa 氏に感謝します。
- `sdxl_merge_lora.py` でも LBW がサポートされました。
- LBW の詳細は hako-mikan 氏の [LoRA Block Weight](https://github.com/hako-mikan/sd-webui-lora-block-weight) をご覧ください。
- 以上は次回リリースに含まれます。
### Jun 23, 2024 / 2024-06-23:
- Fixed `cache_latents.py` and `cache_text_encoder_outputs.py` not working. (Will be included in the next release.)
- `cache_latents.py` および `cache_text_encoder_outputs.py` が動作しなくなっていたのを修正しました。(次回リリースに含まれます。)
### Apr 7, 2024 / 2024-04-07: v0.8.7
- The default value of `huber_schedule` in Scheduled Huber Loss is changed from `exponential` to `snr`, which is expected to give better results.
- Scheduled Huber Loss の `huber_schedule` のデフォルト値を `exponential` から、より良い結果が期待できる `snr` に変更しました。
### Apr 7, 2024 / 2024-04-07: v0.8.6
#### Highlights
- The dependent libraries are updated. Please see [Upgrade](#upgrade) and update the libraries.
- Especially `imagesize` is newly added, so if you cannot update the libraries immediately, please install with `pip install imagesize==1.4.1` separately.
- `bitsandbytes==0.43.0`, `prodigyopt==1.0`, `lion-pytorch==0.0.6` are included in the requirements.txt.
- `bitsandbytes` no longer requires complex procedures as it now officially supports Windows.
- Also, the PyTorch version is updated to 2.1.2 (PyTorch does not need to be updated immediately). In the upgrade procedure, PyTo
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Downloading sd-scripts-main.zip (108个子文件)
libbitsandbytes_cuda118.dll 13.38MB
libbitsandbytes_cuda116.dll 4.51MB
libbitsandbytes_cpu.dll 75KB
.gitignore 71B
med_config.json 527B
train_README-ja.md 66KB
train_README-zh.md 47KB
gen_img_README-ja.md 35KB
README.md 30KB
train_network_README-ja.md 28KB
config_README-ja.md 24KB
train_network_README-zh.md 22KB
config_README-en.md 20KB
LICENSE.md 11KB
train_lllite_README-ja.md 11KB
fine_tune_README_ja.md 10KB
train_db_README-ja.md 10KB
train_lllite_README.md 10KB
train_db_README-zh.md 7KB
README-ja.md 7KB
train_ti_README-ja.md 7KB
wd14_tagger_README-ja.md 6KB
train_SDXL-en.md 5KB
wd14_tagger_README-en.md 5KB
train_util.py 228KB
gen_img_diffusers.py 172KB
gen_img.py 141KB
sdxl_gen_img.py 137KB
original_unet.py 69KB
sdxl_lpw_stable_diffusion.py 64KB
lpw_stable_diffusion.py 59KB
model_util.py 54KB
train_network.py 54KB
lora.py 50KB
lora_fa.py 50KB
sdxl_original_unet.py 44KB
med.py 41KB
train_textual_inversion.py 37KB
sdxl_train.py 36KB
train_textual_inversion_XTI.py 30KB
sdxl_train_control_net_lllite.py 28KB
sdxl_train_control_net_lllite_old.py 26KB
lora_diffusers.py 25KB
config_util.py 25KB
train_controlnet.py 25KB
slicing_vae.py 24KB
train_db.py 23KB
fine_tune.py 23KB
sdxl_model_util.py 22KB
tag_images_by_wd14_tagger.py 22KB
custom_train_functions.py 21KB
control_net_lllite_for_train.py 21KB
sdxl_merge_lora.py 20KB
control_net_lllite.py 19KB
dylora.py 18KB
svd_merge_lora.py 17KB
diffusers.py 15KB
merge_lora.py 14KB
oft.py 14KB
resize_lora.py 14KB
vit.py 14KB
extract_lora_from_models.py 14KB
sdxl_train_util.py 14KB
sdxl_minimal_inference.py 14KB
hijacks.py 13KB
original_control_net.py 13KB
latent_upscaler.py 12KB
prepare_buckets_latents.py 12KB
blip.py 11KB
detect_face_rotate.py 10KB
utils.py 10KB
__init__.py 10KB
sai_model_spec.py 9KB
attention.py 9KB
gradscaler.py 8KB
sdxl_train_network.py 8KB
make_captions.py 8KB
XTI_hijack.py 8KB
cache_latents.py 8KB
cache_text_encoder_outputs.py 8KB
attention_processors.py 8KB
make_captions_by_git.py 7KB
merge_lora_old.py 7KB
convert_diffusers20_original_sd.py 7KB
clean_captions_and_tags.py 7KB
hypernetwork.py 7KB
merge_models.py 6KB
resize_images_to_resolution.py 6KB
main.py 6KB
lora_interrogator.py 6KB
deepspeed_utils.py 5KB
sdxl_train_textual_inversion.py 5KB
extract_lora_from_dylora.py 4KB
merge_captions_to_metadata.py 4KB
merge_dd_tags_to_metadata.py 4KB
hypernetwork_nai.py 3KB
huggingface_util.py 3KB
cextension.py 2KB
device_utils.py 2KB
check_lora_weights.py 1KB
共 108 条
- 1
- 2
资源评论
rain699
- 粉丝: 98
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功