This repository provides a Windows-focused Gradio GUI for Kohya's Stable Diffusion trainers https://github.com/bmaltais/kohya_ss
Go to file
bmaltais d37aa6efad v21.3.9 2023-04-01 06:59:59 -04:00
.github/workflows Add typos checker 2023-03-01 19:14:48 -05:00
.vscode Update Utilities logic 2022-12-15 18:34:54 -05:00
bitsandbytes_windows Merge latest kohya_ss code update 2023-01-01 13:10:32 -05:00
examples Fix missing macos requirements file 2023-03-26 06:47:26 -04:00
finetune v21.3.9 2023-04-01 06:59:59 -04:00
library v21.3.9 2023-04-01 06:59:59 -04:00
networks Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
presets Updates 2023-02-23 21:48:45 -05:00
tools Fix issue with LyCORIS version 2023-03-30 07:23:37 -04:00
v2_inference Adding example for SDv2 2022-11-27 16:07:26 -05:00
.gitignore v21.3.9 2023-04-01 06:59:59 -04:00
LICENSE.md Add support for new arguments: 2023-01-15 11:05:22 -05:00
README-ja.md Update to sd-script latest update 2023-03-09 11:06:59 -05:00
README.md v21.3.9 2023-04-01 06:59:59 -04:00
_typos.toml Add typos checker 2023-03-01 19:14:48 -05:00
activate.bat Adding activate script 2023-02-26 15:12:50 -05:00
activate.ps1 Adding activate script 2023-02-26 15:12:50 -05:00
config_README-ja.md Update to latest sd-script release 2023-03-06 19:15:02 -05:00
dreambooth_gui.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
fine_tune.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
fine_tune_README.md Merge latest kohya code release into GUI repo 2023-01-09 07:47:07 -05:00
fine_tune_README_ja.md Update to sd-script latest update 2023-03-09 11:06:59 -05:00
finetune_gui.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
gen_img_diffusers.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
gui.bat Add validation that all requirements are met 2023-03-12 10:11:41 -04:00
gui.ps1 Add support for custom user gui startup files 2023-03-24 13:26:29 -04:00
gui.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
gui_macos.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
kohya_gui.py Add support for LyCORIS LoCON extraction 2023-03-15 20:33:25 -04:00
lora_gui.py Merge pull request #471 from srndpty/feature/decimal-network-alpha 2023-03-28 11:57:59 -04:00
macos_setup.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
requirements.txt Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
requirements_macos.txt Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
setup.bat v21.3.9 2023-04-01 06:59:59 -04:00
setup.py Add support for custom user gui startup files 2023-03-24 13:26:29 -04:00
style.css Add new Utilities Tab 2022-12-15 18:19:35 -05:00
textual_inversion_gui.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_README-ja.md Update to sd-script dev code base 2023-03-10 11:44:52 -05:00
train_db - Copy.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_db.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_db_README-ja.md Update to sd-script latest update 2023-03-09 11:06:59 -05:00
train_db_README.md Merge latest kohya code release into GUI repo 2023-01-09 07:47:07 -05:00
train_network - Copy.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_network.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_network_README-ja.md Update to sd-script dev code base 2023-03-10 11:44:52 -05:00
train_network_README.md Merge latest kohya code release into GUI repo 2023-01-09 07:47:07 -05:00
train_textual_inversion - Copy.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_textual_inversion.py Merge new sd-scripts updates 2023-03-28 11:54:42 -04:00
train_ti_README-ja.md Update to sd-script latest update 2023-03-09 11:06:59 -05:00
train_ti_README.md Add TI training support 2023-01-26 16:22:58 -05:00
ubuntu_setup.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
upgrade.bat Add setup/upgrade batch files 2023-03-31 16:45:04 -06:00
upgrade.ps1 Upgrade upgrade.ps1 script to fix reported issue: 2023-02-14 17:42:36 -05:00
upgrade.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
upgrade_macos.sh Revert "Merge pull request #466 from jstayco/consolidated_install_scripts" 2023-04-01 06:29:45 -04:00
utilities.cmd Update GUI and Readme 2022-12-22 13:14:46 -05:00

README.md

Kohya's GUI

This repository provides a Windows-focused Gradio GUI for Kohya's Stable Diffusion trainers. The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model.

If you run on Linux and would like to use the GUI, there is now a port of it as a docker container. You can find the project here.

Table of Contents

Tutorials

How to Create a LoRA Part 1: Dataset Preparation:

LoRA Part 1 Tutorial

How to Create a LoRA Part 2: Training the Model:

LoRA Part 2 Tutorial

Required Dependencies

Installation

Runpod

Follow the instructions found in this discussion: https://github.com/bmaltais/kohya_ss/discussions/379

MacOS

In the terminal, run

git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
bash macos_setup.sh

During the accelerate config screen after running the script answer "This machine", "None", "No" for the remaining questions.

Ubuntu

In the terminal, run

git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
bash ubuntu_setup.sh

then configure accelerate with the same answers as in the MacOS instructions when prompted.

Windows

In the terminal, run

git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
setup.bat

then configure accelerate with the same answers as in the MacOS instructions when prompted.

Optional: CUDNN 8.6

This step is optional but can improve the learning speed for NVIDIA 30X0/40X0 owners. It allows for larger training batch size and faster training speed.

Due to the file size, I can't host the DLLs needed for CUDNN 8.6 on Github. I strongly advise you download them for a speed boost in sample generation (almost 50% on 4090 GPU) you can download them here.

To install, simply unzip the directory and place the cudnn_windows folder in the root of the this repo.

Run the following commands to install:

.\venv\Scripts\activate

python .\tools\cudann_1.8_install.py

Upgrading MacOS

When a new release comes out, you can upgrade your repo with the following commands in the root directory:

upgrade_macos.sh

Once the commands have completed successfully you should be ready to use the new version. MacOS support is not tested and has been mostly taken from https://gist.github.com/jstayco/9f5733f05b9dc29de95c4056a023d645

Upgrading Windows

When a new release comes out, you can upgrade your repo with the following commands in the root directory:

upgrade.bat

Once the commands have completed successfully you should be ready to use the new version.

Launching the GUI using gui.bat or gui.ps1

The script can be run with several optional command line arguments:

--listen: the IP address to listen on for connections to Gradio. --username: a username for authentication. --password: a password for authentication. --server_port: the port to run the server listener on. --inbrowser: opens the Gradio UI in a web browser. --share: shares the Gradio UI.

These command line arguments can be passed to the UI function as keyword arguments. To launch the Gradio UI, run the script in a terminal with the desired command line arguments, for example:

gui.ps1 --listen 127.0.0.1 --server_port 7860 --inbrowser --share

or

gui.bat --listen 127.0.0.1 --server_port 7860 --inbrowser --share

Launching the GUI using kohya_gui.py

To run the GUI, simply use this command:

.\venv\Scripts\activate

python.exe .\kohya_gui.py

Dreambooth

You can find the dreambooth solution specific here: Dreambooth README

Finetune

You can find the finetune solution specific here: Finetune README

Train Network

You can find the train network solution specific here: Train network README

LoRA

Training a LoRA currently uses the train_network.py code. You can create a LoRA network by using the all-in-one gui.cmd or by running the dedicated LoRA training GUI with:

.\venv\Scripts\activate

python lora_gui.py

Once you have created the LoRA network, you can generate images via auto1111 by installing this extension.

Troubleshooting

Page File Limit

  • X error relating to page file: Increase the page file size limit in Windows.

No module called tkinter

FileNotFoundError

This is usually related to an installation issue. Make sure you do not have any python modules installed locally that could conflict with the ones installed in the venv:

  1. Open a new powershell terminal and make sure no venv is active.
  2. Run the following commands:
pip freeze > uninstall.txt
pip uninstall -r uninstall.txt

This will store your a backup file with your current locally installed pip packages and then uninstall them. Then, redo the installation instructions within the kohya_ss venv.

Change History

  • 2023/04/01 (v21.3.9)

    • Update how setup is done on Windows by introducing a setup.bat script. This will make it easier to install/re-install on Windows if needed. Many thanks to @missionfloyd for his PR: https://github.com/bmaltais/kohya_ss/pull/496
  • 2023/03/30 (v21.3.8)

  • 2023/03/29 (v21.3.7)

  • 2023/03/28 (v21.3.6)

    • Fix issues when --persistent_data_loader_workers is specified.
      • The batch members of the bucket are not shuffled.
      • --caption_dropout_every_n_epochs does not work.
      • These issues occurred because the epoch transition was not recognized correctly. Thanks to u-haru for reporting the issue.
    • Fix an issue that images are loaded twice in Windows environment.
    • Add Min-SNR Weighting strategy. Details are in #308. Thank you to AI-Casanova for this great work!
      • Add --min_snr_gamma option to training scripts, 5 is recommended by paper.
      • The Min SNR gamma fiels can be found unser the advanced training tab in all trainers.
    • Fixed the error while images are ended with capital image extensions. Thanks to @kvzn. https://github.com/bmaltais/kohya_ss/pull/454
  • 2023/03/26 (v21.3.5)

  • 2023/03/25 (v21.3.4)

    Let me know how this work. From the look of it it appear to be well tought out. I modified a few things to make it fit better with the rest of the code in the repo.

  • 2023/03/24 (v21.3.3)

    • Add support for custom user gui files. THey will be created at installation time or when upgrading is missing. You will see two files in the root of the folder. One named gui-user.bat and the other gui-user.ps1. Edit the file based on your prefered terminal. Simply add the parameters you want to pass the gui in there and execute it to start the gui with them. Enjoy!
  • 2023/03/23 (v21.3.2)

  • 2023/03/23 (v21.3.1)

    • Merge PR to fix refactor naming issue for basic captions. Thank @zrma
  • 2023/03/22 (v21.3.0)

    • Add a function to load training config with .toml to each training script. Thanks to Linaqruf for this great contribution!
      • Specify .toml file with --config_file. .toml file has key=value entries. Keys are same as command line options. See #241 for details.
      • All sub-sections are combined to a single dictionary (the section names are ignored.)
      • Omitted arguments are the default values for command line arguments.
      • Command line args override the arguments in .toml.
      • With --output_config option, you can output current command line options to the .toml specified with--config_file. Please use as a template.
    • Add --lr_scheduler_type and --lr_scheduler_args arguments for custom LR scheduler to each training script. Thanks to Isotr0py! #271
      • Same as the optimizer.
    • Add sample image generation with weight and no length limit. Thanks to mio2333! #288
      • ( ), (xxxx:1.2) and [ ] can be used.
    • Fix exception on training model in diffusers format with train_network.py Thanks to orenwang! #290
    • Add warning if you are about to overwrite an existing model: https://github.com/bmaltais/kohya_ss/issues/404
    • Add --vae_batch_size for faster latents caching to each training script. This batches VAE calls.
      • Please start with2 or 4 depending on the size of VRAM.
    • Fix a number of training steps with --gradient_accumulation_steps and --max_train_epochs. Thanks to tsukimiya!
    • Extract parser setup to external scripts. Thanks to robertsmieja!
    • Fix an issue without .npz and with --full_path in training.
    • Support extensions with upper cases for images for not Windows environment.
    • Fix resize_lora.py to work with LoRA with dynamic rank (including conv_dim != network_dim). Thanks to toshiaki!
    • Fix issue: https://github.com/bmaltais/kohya_ss/issues/406
    • Add device support to LoRA extract.