kohya_ss
Описание
Языки
- Python94,3%
- Shell3,1%
- CSS0,9%
- Dockerfile0,7%
- JavaScript0,5%
- Batchfile0,4%
- Остальные0,1%
Kohya's GUI
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:
- Easy-to-use interface for setting a wide range of training parameters.
- Automatic generation of the command-line interface (CLI) commands required to run the training scripts.
- Support for various training methods, including LoRA, Dreambooth, fine-tuning, and SDXL training.
Support for Linux and macOS is also available. While Linux support is actively maintained through community contributions, macOS compatibility may vary.
Table of Contents
- Installation Options
- Custom Path Defaults
- SDXL training
- Masked loss
- Guides
- Interesting Forks
- Contributing
- License
- Change History
Installation Options
You can run either locally on your machine or via cloud-based solutions like Colab or Runpod.
- If you have a GPU-equipped PC and want full control: install it locally using
oruv.pip - If your system doesn’t meet requirements or you prefer a browser-based setup: use Colab or a paid GPU provider like Runpod or Novita.
- If you are a developer or DevOps user, Docker is also supported.
Local Installation Overview
You can install locally using either the or method. Choose one depending on your platform and preferences:
| Platform | Recommended Method | Instructions |
|---|---|---|
| Linux | | uv_linux.md |
| Linux or Mac | | pip_linux.md |
| Windows | | uv_windows.md |
| Windows | | pip_windows.md |
uv vs pip – What's the Difference?
is faster and isolates dependencies more cleanly, ideal if you want minimal setup hassle.uvis more traditional, easier to debug if issues arise, and works better with some IDEs or Python tooling.pip- If unsure: try
. If it doesn't work for you, fall back touv.pip
Cloud Installation Overview
🦒 Colab
For browser-based training without local setup, use this Colab notebook:
https://github.com/camenduru/kohya_ss-colab
- No installation required
- Free to use (GPU availability may vary)
- Maintained by camenduru, not the original author
💡 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.
Runpod, Novita, Docker
These options are for users running training on hosted GPU infrastructure or containers.
- Runpod setup – Ready-made GPU background training via templates.
- Novita setup – Similar to Runpod, but integrated into the Novita UI.
- Docker setup – For developers/sysadmins using containerized environments.
Custom Path Defaults with config.toml
The GUI supports a configuration file named 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 :
- Pre-fill default directory paths for pretrained models, datasets, output folders, LoRA models, etc.
- Streamline your workflow by having the GUI remember your preferred locations.
How to Use and Customize:
- Create your configuration file:
- In the root directory of the
repository, you'll find a file namedkohya_ss.config example.toml - Copy this file and rename the copy to
. Thisconfig.tomlfile will be automatically loaded when the GUI starts.config.toml
- In the root directory of the
- Edit
:config.toml- Open
with a text editor.config.toml - The file uses TOML (Tom's Obvious, Minimal Language) format, which consists of
pairs.key = "value" - Modify the paths for the keys according to your local directory structure.
- Important:
- Use absolute paths (e.g.,
orC:/Users/YourName/StableDiffusion/Models)./home/yourname/sd-models - Alternatively, you can use paths relative to the
root directory.kohya_ss - Ensure you use forward slashes (
) for paths, even on Windows, as this is generally more compatible with TOML and Python./ - Make sure the specified directories exist on your system.
- Use absolute paths (e.g.,
- Open
Structure of :
The file can have several sections, typically corresponding to different training modes or general settings. Common keys you might want to set include:
: Default directory for loading base Stable Diffusion models.model_dir: Default directory for saving and loading LoRA models.lora_model_dir: Default base directory for training outputs (images, logs, model checkpoints).output_dir: A general default if you store all your datasets in one place.dataset_dir- Specific input paths for different training tabs like Dreambooth, Finetune, LoRA, etc. (e.g.,
,db_model_dir).ft_source_model_name_or_path
Example Configurations:
Here's an example snippet of what your might look like:
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 command-line argument when launching the GUI:
- On Windows: gui.bat --config D:/my_configs/kohya_settings.toml
- On Linux/macOS: ./gui.sh --config /home/user/my_configs/kohya_settings.toml
By effectively using , you can significantly speed up your training setup process. Always refer to the for the most up-to-date list of configurable paths.
LoRA
To train a LoRA, you can currently use the 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:
Sample image generation during training
A prompt file might look like this, for example:
Lines beginning with are comments. You can specify options for the generated image with options like after the prompt. The following options can be used:
: Negative prompt up to the next option.--n: Specifies the width of the generated image.--w: Specifies the height of the generated image.--h: Specifies the seed of the generated image.--d: Specifies the CFG scale of the generated image.--l: Specifies the number of steps in the generation.--s
The prompt weighting such as and is working.
Troubleshooting
If you encounter any issues, refer to the troubleshooting steps below.
Page File Limit
If you encounter an X error related to the page file, you may need to increase the page file size limit in Windows.
No module called tkinter
If you encounter an error indicating that the module is not found, try reinstalling Python 3.10 on your system.
LORA Training on TESLA V100 - GPU Utilization Issue
See Troubleshooting LORA Training on TESLA V100 for details.
SDXL training
For detailed guidance on SDXL training, please refer to the official sd-scripts documentation and relevant sections in our LoRA Training Guide.
Masked loss
The masked loss is supported in each training script. To enable the masked loss, specify the 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.
Guides
The following are guides extracted from issues discussions
Using Accelerate Lora Tab to Select GPU ID
Starting Accelerate in GUI
- Open the kohya GUI on your desired port.
- Open the
tabAccelerate launch - Ensure the Multi-GPU checkbox is unchecked.
- Set GPU IDs to the desired GPU (like 1).
Running Multiple Instances (linux)
- For tracking multiple processes, use separate kohya GUI instances on different ports (e.g., 7860, 7861).
- Start instances using
.nohup ./gui.sh --listen 0.0.0.0 --server_port <port> --headless > log.log 2>&1 &
Monitoring Processes
- Open each GUI in a separate browser tab.
- For terminal access, use SSH and tools like
ortmux.screen
For more details, visit the GitHub issue.
Interesting Forks
To finetune HunyuanDiT models or create LoRAs, visit this fork
Contributing
Contributions are welcome! If you'd like to contribute to this project, please consider the following:
- For bug reports or feature requests, please open an issue on the GitHub Issues page.
- If you'd like to submit code changes, please open a pull request. Ensure your changes are well-tested and follow the existing code style.
- For security-related concerns, please refer to our
file.SECURITY.md
License
This project is licensed under the Apache License 2.0. See the LICENSE.md file for details.
Change History
v25.0.3
- Upgrade Gradio, diffusers and huggingface-hub to latest release to fix issue with ASGI.
- Add a new method to setup and run the GUI. You will find two new script for both Windows (gui-uv.bat) and Linux (gui-uv.sh). With those scripts there is no need to run setup.bat or setup.sh anymore.
v25.0.2
- Force gradio to 5.14.0 or greater so it is updated.
v25.0.1
- Fix issue with requirements version causing huggingface download issues
v25.0.0
- Major update: Introduced support for flux.1 and sd3, moving the GUI to align with more recent script functionalities.
- Users preferring the pre-flux.1/sd3 version can check out tag
.v24.1.7 - For details on new flux.1 and sd3 parameters, refer to the sd-scripts README.