Training your own LoRA sounds hard, but with the Kohya GUI it comes down to three jobs: collect good images, caption them, and press Start with sensible settings. Kohya_ss is the free, open-source Gradio interface for kohya’s sd-scripts, and it is still the most widely used way to train LoRAs on your own PC.
This guide shows how to train a LoRA with the Kohya GUI from scratch in 2026: the Windows install with uv, the dataset folder format that confuses everyone, captioning, safe starting settings for SD 1.5, SDXL and Flux, how to read the results, how to test your LoRA in ComfyUI, and fixes for the usual errors.
- Install (Windows): Python 3.11.9, CUDA 12.8, Git and VC++ redist, then
git clone --recursive https://github.com/bmaltais/kohya_ss.gitand run.\gui-uv.bat. - Opens at:
http://127.0.0.1:7860in your browser. - Dataset: 15 to 40 good images in a folder named
REPEATS_trigger class, for example10_mychar woman, with one.txtcaption per image. - Starting settings (SDXL): 1024 resolution, network dim 16 to 32, alpha 8 to 16, learning rate 1e-4, AdamW8bit, batch 1 to 2, 10 epochs, bf16, gradient checkpointing on.
- Models supported: SD 1.5/2.x, SDXL, SD3, Flux.1, Lumina Image 2.0, Anima and HunyuanImage-2.1, plus LoHa, LoKr, DreamBooth, fine-tune and Textual Inversion.
- Use it: copy the
.safetensorsoutput toComfyUI/models/loras/.
What Kohya_ss Is (and What It Trains)
Kohya_ss (by bmaltais) is a browser-based GUI built with Gradio on top of kohya-ss’s sd-scripts. The GUI writes the training command for you, so you fill in fields instead of typing long command lines.
According to the project README it supports:
- Training types: LoRA, LoHa, LoKr, DreamBooth, full fine-tuning and Textual Inversion.
- Base models: Stable Diffusion 1.5 and 2.x, SDXL, SD3, Flux.1, Lumina Image 2.0, Anima and HunyuanImage-2.1.
- Extras: masked loss, captioning tools (BLIP, WD14 tagger), LoRA resize and merge tools, and TOML config files for default paths.
The upcoming v26.0.0 release (listed in the README change history) moves to sd-scripts v0.11.1 and adds Lumina and Anima LoRA training, native LoHa/LoKr for SDXL and Anima, HunyuanImage-2.1 LoRA, LECO concept erasure and inpainting model training.
Windows is the main platform. Linux is maintained by the community, and macOS support “may vary”, in the README’s own words.
Hardware and VRAM You Need
The README only says an NVIDIA GPU is required and “VRAM needs vary”. The figures below are typical community starting points with memory-saving options on (gradient checkpointing, 8-bit optimizer, cached latents), so treat them as a guide, not a promise.
| Base model | Resolution | Comfortable VRAM | Possible with tricks |
|---|---|---|---|
| SD 1.5 | 512 to 768 | 8 GB | 6 GB |
| SDXL / Pony / Illustrious | 1024 | 12 to 16 GB | 8 to 10 GB (slow) |
| Flux.1 dev | 512 to 1024 | 24 GB | 12 to 16 GB with FP8 base and block swap |
| Newer DiT models (Lumina, Anima, HunyuanImage) | 1024 | 16 to 24 GB | Check model notes |
You also want 32 GB of system RAM or more and a fast SSD with 30 GB or more free for models, cached latents and outputs. Not sure your card is enough? Our RTX 5060 Ti 16GB for AI and RTX 3060 12GB for AI reviews cover training headroom.
Step 1: Install Kohya_ss on Windows
The README recommends the uv method for most Windows users. It is faster and keeps dependencies isolated.
- Install Python 3.11.9 (64-bit) from python.org. Tick Add to PATH during setup.
- Install CUDA Toolkit 12.8 from NVIDIA’s archive page.
- Install Git for Windows.
- Install the Visual Studio Redistributables (
vc_redist.x64.exe). Optional, but it avoids DLL errors. - Clone the repo with submodules. Open PowerShell in the folder where you want it (a short path like
C:\AI\is best) and run:git clone --recursive https://github.com/bmaltais/kohya_ss.git cd kohya_ss - Start the GUI:
.\gui-uv.batIf uv is not installed, the script asks you. Press Y to install it automatically.
- Wait for the first run. It downloads PyTorch and all dependencies, which can take 10 to 20 minutes.
- Open the GUI at
http://127.0.0.1:7860, or add--inbrowserso it opens by itself.
Useful launch flags from the docs:
.\gui-uv.bat --listen 127.0.0.1 --server_port 7860 --inbrowser
--server_portchanges the port (handy if ComfyUI or another app uses 7860).--headlesshides local file pickers for remote or SSH use; type paths instead.--username/--passwordadd a login if you expose the GUI on your network.--sharecreates a public Gradio link. Avoid it unless you need it, since anyone with the link can reach the GUI.
To update later, run git pull and git submodule update --init --recursive inside the folder, then start gui-uv.bat again; uv syncs the dependencies.
Linux, Mac and Cloud Options
| Platform | Method | Start command |
|---|---|---|
| Windows | uv (recommended) or pip | .\gui-uv.bat or gui.bat |
| Linux | uv (recommended) or pip | ./gui-uv.sh or ./gui.sh |
| macOS | pip | ./gui.sh (support varies, Apple Silicon is slow for training) |
| Runpod / Novita | Ready-made templates | Launch with --listen 0.0.0.0 --headless |
| Docker | Container | See the repo’s Docker doc |
| Google Colab | Community notebook (camenduru) | Run the notebook cells |
Renting a GPU can be cheaper than upgrading if you only train now and then. If you are weighing a bigger local box instead, our NVIDIA DGX Spark review covers what 128 GB of unified memory can and cannot do.
Step 2: Prepare Your Dataset
Your dataset matters more than any setting. Twenty great images beat two hundred average ones.
Pick your images
- Character or person-like mascot: 15 to 40 images with different poses, angles, outfits, lighting and backgrounds.
- Style: 30 to 100 images that share the style but show different subjects.
- Object or product: 15 to 30 images from many angles.
- Quality: sharp, no watermarks or text, no heavy filters. Crop out other people and clutter.
- Resolution: at least 1024 px on the short side for SDXL and Flux, 512 px for SD 1.5. Kohya’s bucketing handles mixed aspect ratios.
The folder structure
Kohya reads the number of repeats and the concept from the folder name. The format is REPEATS_trigger class:
C:\AI\train\mychar\
├── img\
│ └── 10_mychar woman\
│ ├── 001.png
│ ├── 001.txt
│ ├── 002.png
│ └── 002.txt
├── model\ (output LoRA files go here)
└── log\ (training logs)
- 10 = how many times each image is repeated per epoch.
- mychar = your trigger word. Use a rare made-up word so it does not clash with words the model knows.
- woman = the class (what kind of thing it is: woman, man, dog, car, style).
- Point the GUI’s Image folder to
img, not to the10_...folder inside it.
The official folder doc notes that if a .txt or .caption file with the same name as an image exists, its contents are used instead of the folder name. So captions take priority.
Optional: a reg folder of regularisation images (for example 1_woman) helps stop the class from drifting, but most people skip it for simple LoRAs.
Step 3: Caption Your Images
Captions tell the model what is not part of your concept, so it learns the concept itself cleanly.
- Open the Utilities tab in the Kohya GUI and choose Captioning.
- Pick a captioner. Use BLIP (or a newer VLM captioner) for natural sentences on SD 1.5, SDXL and Flux; use the WD14 tagger for anime-style tags on Pony and Illustrious models.
- Set the folder to your
10_mychar womanfolder and add a prefix with your trigger word, for examplemychar woman,. - Run it. A
.txtfile appears next to each image. - Edit by hand. Open a few files and fix mistakes. Describe clothes, background, pose and lighting, but not the core features you want the LoRA to learn.
Example caption for a character: mychar woman, standing in a park, wearing a green jacket and jeans, smiling, soft daylight. The face and hairstyle are left out so the trigger word learns them.
Prefer a local vision model for captions? You can caption with a VLM in Ollama, see our Ollama guide.
Step 4: Configure the LoRA Tab
Click the LoRA tab at the top (not DreamBooth). Then work through the sections.
- Model: pick the base model type and set the path to your checkpoint
.safetensors. Train on the base model you plan to generate with (or its parent, such as SDXL base for most SDXL fine-tunes). - Folders: set Image folder (
img), Output folder (model) and Logging folder (log). Give the model an output name, such asmychar_sdxl_v1. - Parameters, Basic: choose LoRA type Standard, set epochs, batch size, learning rate, network dim and alpha (see the table below).
- Parameters, Advanced: turn on Gradient checkpointing, Cache latents (and cache to disk), set mixed precision and save precision to bf16 (RTX 30 series and newer; use fp16 on older cards).
- Samples: add a sample prompt and “sample every N epochs” so you can see progress.
- Save your config with the Configuration file section at the top, so you can reload it next time.
Sample prompt lines accept flags from sd-scripts: --n negative prompt, --w and --h width and height, --d seed, --l CFG scale and --s steps. Example:
mychar woman, portrait, smiling, studio light --n blurry, lowres --w 1024 --h 1024 --d 42 --l 6 --s 28
Recommended Settings by Model
These are common community starting points that work for most character and style LoRAs. Change one thing at a time.
| Setting | SD 1.5 | SDXL | Flux.1 dev |
|---|---|---|---|
| Resolution | 512 or 768 | 1024 | 512 to 1024 |
| Network dim (rank) | 16 to 32 | 16 to 32 | 16 |
| Network alpha | 8 to 16 | 8 to 16 | 16 |
| Learning rate | 1e-4 | 1e-4 | 1e-4 to 4e-4 |
| Optimizer | AdamW8bit | AdamW8bit or Adafactor | AdamW8bit or Adafactor |
| Scheduler | cosine | constant or cosine | constant |
| Batch size | 2 to 4 | 1 to 2 | 1 |
| Epochs | 10 | 10 | 10 to 16 |
| Target steps | 1,000 to 2,000 | 1,000 to 2,000 | 1,000 to 2,500 |
| Precision | bf16 / fp16 | bf16 | bf16, FP8 base on smaller GPUs |
| Text encoder training | On, lower LR | Often off | Off |
Higher rank makes bigger files and can memorise more detail, but it also overfits faster. Rank 16 is enough for most characters.
Step 5: Start Training and Watch the Loss
- Click Start training. The console shows caching, then a progress bar with steps and loss.
- Check speed. The it/s (or s/it) value tells you how long it will take. An SDXL LoRA of 1,000 steps often takes 30 to 90 minutes on a mid-range card.
- Look at samples in the
model\samplefolder after each epoch. - Open TensorBoard from the GUI button to see the loss graph. Loss going down slowly and then flattening is normal.
- Keep several epochs. Set “save every N epochs” to 1 or 2, so you can pick the best one later instead of the last one.
Step 6: Test Your LoRA in ComfyUI
- Copy the files from the
modelfolder (for examplemychar_sdxl_v1-000006.safetensors) toComfyUI/models/loras/. - Add a Load LoRA node between Load Checkpoint and the sampler. Our guide to using LoRAs in ComfyUI shows the wiring.
- Use your trigger word in the prompt, with a fixed seed.
- Compare epochs at strength 0.8 and 1.0. Pick the one that looks right and still follows new prompts (new outfits, new places).
- Test flexibility. If every image has the same background or pose as your dataset, the LoRA is overfit; use an earlier epoch or train with fewer steps.
Tips for Better LoRAs
- Variety beats volume. Different angles, light and backgrounds stop the LoRA from learning the wrong thing.
- Caption what changes. Clothes, backgrounds and props should be in captions so they stay changeable.
- Rare trigger words. Use something like
zxq_mychar, not a real word. - Underfit is easier to fix than overfit: you can raise strength, but you cannot remove baked-in backgrounds.
- Masked loss (supported in each training script with
--masked_loss) lets you train only on the subject using mask images. - Resize big LoRAs with the Resize LoRA tool to make smaller files with little quality loss.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| “No data found” or 0 images | Image folder points to the wrong level or folder name lacks the repeat number | Point to img; name the subfolder like 10_mychar woman |
| CUDA out of memory | Batch or resolution too high | Batch 1, gradient checkpointing on, cache latents, AdamW8bit, lower resolution |
| Windows page file error | Page file too small | Increase the Windows page file size, as the README advises |
| “tkinter not found” | Python installed without Tcl/Tk | Reinstall Python with tcl/tk ticked (the README suggests reinstalling Python) |
| uv or torch install fails | Network drop or wrong Python | Re-run gui-uv.bat; check .python-version; fall back to the pip method |
| Samples look like noise | Learning rate too high or wrong base model type | Lower LR to 5e-5; make sure SDXL/Flux is selected for those checkpoints |
| LoRA has no effect in ComfyUI | Trigger word missing or wrong base model family | Add the trigger; use a checkpoint from the same family |
| Every image looks like the dataset | Overfit | Use an earlier epoch, fewer repeats, more varied images |
| Port 7860 already in use | Another Gradio app is running | Start with --server_port 7861 |
Kohya vs Other LoRA Trainers
| Trainer | Interface | Best for |
|---|---|---|
| Kohya_ss | Gradio GUI, many options | SD 1.5, SDXL, Flux and newer image models; full control |
| ZenTrainer | Inside ComfyUI | Training without leaving ComfyUI, live samples |
| Fizgig | Simple app | Fast MOSS-Image LoRAs |
| Unsloth | Python / notebooks | LLM (text model) fine-tuning, not images |
See our ZenTrainer guide and Fizgig 9.2 guide if Kohya feels like too much.
My Take
Kohya_ss is not the prettiest trainer, but it is the most complete and the best documented. Once you get the folder format right, the rest is filling in a handful of fields.
Start small: 20 varied images, rank 16, learning rate 1e-4, about 1,000 steps, and save every epoch. Test in ComfyUI, pick the best epoch, and only then start tweaking.
FAQ
Is Kohya_ss free?
Yes. It is open source under the Apache 2.0 licence. You only pay for your own hardware or a rented GPU.
How many images do I need to train a LoRA?
15 to 40 good, varied images is enough for a character or object. Styles benefit from 30 to 100.
How long does LoRA training take?
An SD 1.5 LoRA can take 15 to 30 minutes and an SDXL LoRA 30 to 90 minutes on a mid-range GPU, depending on steps and resolution. Flux takes longer.
Can I train a LoRA with 8 GB VRAM?
Yes for SD 1.5. SDXL is possible on 8 to 10 GB with gradient checkpointing, batch 1 and an 8-bit optimizer, but it is slow.
What does the number in the folder name mean?
It is the repeat count. 10_mychar woman means each image is used 10 times per epoch, with trigger word “mychar” and class “woman”.
Which Python version does Kohya_ss need?
The Windows uv guide asks for Python 3.11.9. The uv environment uses the version in the repo’s .python-version file.
Can Kohya train Flux LoRAs?
Yes. Flux.1 is supported, along with SD3, Lumina Image 2.0, Anima and HunyuanImage-2.1.
Where do I put the trained LoRA?
Copy the .safetensors file to ComfyUI/models/loras/ (or your Forge/A1111 Lora folder) and load it with a Load LoRA node.




