This is a GUI and CLI for training diffusion models.
This project provides a user-friendly Gradio-based Graphical User Interface (GUI) for Kohya's Stable Diffusion training scripts. Stable Diffusion training empowers users to customize image generation models by fine-tuning existing models, creating unique artistic styles, and training specialized models like LoRA (Low-Rank Adaptation).
Key features of this GUI include:
Support for Linux and macOS is also available. While Linux support is actively maintained through community contributions, macOS compatibility may vary.
You can run kohya_ss either locally on your machine or via cloud-based solutions like Colab or Runpod.
uv or pip.You can install kohya_ss locally using either the uv or pip method. Choose one depending on your platform and preferences:
| Platform | Recommended Method | Instructions |
|---|---|---|
| Linux | uv | uv_linux.md |
| Linux or Mac | pip | pip_linux.md |
| Windows | uv | uv_windows.md |
| Windows | pip | pip_windows.md |
uv is faster and isolates dependencies more cleanly, ideal if you want minimal setup hassle.pip is more traditional, easier to debug if issues arise, and works better with some IDEs or Python tooling.uv. If it doesn't work for you, fall back to pip.For browser-based training without local setup, use this Colab notebook:
https://github.com/camenduru/kohya_ss-colab
| Colab | Info |
|---|---|
| kohya_ss_gui_colab |
💡 If you encounter issues, please report them on camenduru’s repo.
Special thanks
I would like to express my gratitude to camenduru for their valuable contribution.
These options are for users running training on hosted GPU infrastructure or containers.
The GUI supports a configuration file named config.toml that allows you to set default paths for many of the input fields. This is useful for avoiding repetitive manual selection of directories every time you start the GUI.
Purpose of config.toml:
How to Use and Customize:
kohya_ss repository, you'll find a file named config example.toml.config.toml. This config.toml file will be automatically loaded when the GUI starts.config.toml:
config.toml with a text editor.key = "value" pairs.C:/Users/YourName/StableDiffusion/Models or /home/yourname/sd-models).kohya_ss root directory./) for paths, even on Windows, as this is generally more compatible with TOML and Python.Structure of config.toml:
The config.toml file can have several sections, typically corresponding to different training modes or general settings. Common keys you might want to set include:
model_dir: Default directory for loading base Stable Diffusion models.lora_model_dir: Default directory for saving and loading LoRA models.output_dir: Default base directory for training outputs (images, logs, model checkpoints).dataset_dir: A general default if you store all your datasets in one place.db_model_dir, ft_source_model_name_or_path).Example Configurations:
Here's an example snippet of what your config.toml might look like:
# General settings
model_dir = "C:/ai_stuff/stable-diffusion-webui/models/Stable-diffusion"
lora_model_dir = "C:/ai_stuff/stable-diffusion-webui/models/Lora"
vae_dir = "C:/ai_stuff/stable-diffusion-webui/models/VAE"
output_dir = "C:/ai_stuff/kohya_ss_outputs"
logging_dir = "C:/ai_stuff/kohya_ss_outputs/logs"
# Dreambooth specific paths
db_model_dir = "C:/ai_stuff/stable-diffusion-webui/models/Stable-diffusion"
db_reg_image_dir = "C:/ai_stuff/datasets/dreambooth_regularization_images"
# Add other db_... paths as needed
# Finetune specific paths
ft_model_dir = "C:/ai_stuff/stable-diffusion-webui/models/Stable-diffusion"
# Add other ft_... paths as needed
# LoRA / LoCon specific paths
lc_model_dir = "C:/ai_stuff/stable-diffusion-webui/models/Stable-diffusion" # Base model for LoRA training
lc_output_dir = "C:/ai_stuff/kohya_ss_outputs/lora"
lc_dataset_dir = "C:/ai_stuff/datasets/my_lora_project"
# Add other lc_... paths as needed
# You can find a comprehensive list of all available keys in the `config example.toml` file.
# Refer to it to customize paths for all supported options in the GUI.
Using a Custom Config File Path:
If you prefer to name your configuration file differently or store it in another location, you can specify its path using the --config command-line argument when launching the GUI:
gui.bat --config D:/my_configs/kohya_settings.toml./gui.sh --config /home/user/my_configs/kohya_settings.tomlBy effectively using config.toml, you can significantly speed up your training setup process. Always refer to the config example.toml for the most up-to-date list of configurable paths.
To train a LoRA, you can currently use the train_network.py code. You can create a LoRA network by using the all-in-one GUI.
Once you have created the LoRA network, you can generate images using auto1111 by installing this extension.
For more detailed information on LoRA training options and advanced configurations, please refer to our LoRA documentation:
A prompt file might look like this, for example:
# prompt 1 masterpiece, best quality, (1girl), in white shirts, upper body, looking at viewer, simple background --n low quality, worst quality, bad anatomy, bad composition, poor, low effort --w 768 --h 768 --d 1 --l 7.5 --s 28 # prompt 2 masterpiece, best quality, 1boy, in business suit, standing at street, looking back --n (low quality, worst quality), bad anatomy, bad composition, poor, low effort --w 576 --h 832 --d 2 --l 5.5 --s 40
Lines beginning with # are comments. You can specify options for the generated image with options like --n after the prompt. The following options can be used:
--n: Negative prompt up to the next option.--w: Specifies the width of the generated image.--h: Specifies the height of the generated image.--d: Specifies the seed of the generated image.--l: Specifies the CFG scale of the generated image.--s: Specifies the number of steps in the generation.The prompt weighting such as ( ) and [ ] is working.
If you encounter any issues, refer to the troubleshooting steps below.
If you encounter an X error related to the page file, you may need to increase the page file size limit in Windows.
If you encounter an error indicating that the module tkinter is not found, try reinstalling Python 3.10 on your system.
See Troubleshooting LORA Training on TESLA V100 for details.
For detailed guidance on SDXL training, please refer to the official sd-scripts documentation and relevant sections in our LoRA Training Guide.
The masked loss is supported in each training script. To enable the masked loss, specify the --masked_loss option.
WARNING
The feature is not fully tested, so there may be bugs. If you find any issues, please open an Issue.
ControlNet dataset is used to specify the mask. The mask images should be the RGB images. The pixel value 255 in R channel is treated as the mask (the loss is calculated only for the pixels with the mask), and 0 is treated as the non-mask. The pixel values 0-255 are converted to 0-1 (i.e., the pixel value 128 is treated as the half weight of the loss). See details for the dataset specification in the LLLite documentation.
The following are guides extracted from issues discussions
Accelerate launch tabnohup ./gui.sh --listen 0.0.0.0 --server_port <port> --headless > log.log 2>&1 &.tmux or screen.For more details, visit the GitHub issue.
To finetune HunyuanDiT models or create LoRAs, visit this fork
Contributions are welcome! If you'd like to contribute to this project, please consider the following:
SECURITY.md file.This project is licensed under the Apache License 2.0. See the LICENSE.md file for details.
v24.1.7.
git checkout v24.1.7