arrow_forwardGuides / AI Image Training
Updated April 2026 30 min read Beginners and advanced

Guide LoRA Training
Training models for characters and Styles

LoRA (Low-Rank Adaptation) lets you train an AI model on a character, art style or specific object — on just a 6GB GPU, within an hour, at a 3MB file size. The complete guide from Dataset to ComfyUI.

~15h
to prepare a full Dataset
6GB+
Required GPU RAM
3MB
LoRA vs 7GB Full Model

What is LoRA? Mode 2 — Beginner

LoRA, short for Low-Rank Adaptation, is a Fine-tuning technique that lets you train a huge AI model (like Stable Diffusion) on your images — without changing all of the model's weights. The result: a small 3–50MB file that you can "attach" to any base model and get images with the character, style, or object you trained.

The analogy — a book with margin notes

Imagine a huge 7GB book (the base model). Full Fine-tuning = writing a whole new book from scratch. LoRA = adding margin notes to the pages — a small file that says: "for this character, change the output like so". The original model stays intact, but now it "remembers" your character.

lightbulb
What did LoRA make possible?

Before LoRA, training a personal model required a $10,000+ GPU, a cloud server for weeks, and 100GB+ of storage. Today anyone with a graphics card starting at $300 can train a LoRA at home in an hour.

Why LoRA and not Full Fine-tuning?

Approach GPU RAM Training time File size
Full Fine-tuning 24GB+ 24+ hours 7GB
LoRA 6–8GB 1–3 hours 3–50MB
QLoRA (Quantized) 4–6GB 2–4 hours 3–20MB

What can you train with LoRA?

How does LoRA work? Mode 4 — Deep Concept

To understand LoRA you need to understand the idea of Low-Rank matrices. When an AI model learns, it stores the "knowledge" inside huge matrices of numbers (Weights). Full Fine-tuning = changing all of them. LoRA = changing a cheap approximation of those matrices.

The math behind LoRA — A × B instead of W

Instead of changing the full matrix W (very large), LoRA adds two small matrices: A and B. The product A × B approximates the desired change while keeping a low dimension (Low-Rank). The original W stays frozen — only A and B are updated.

Original Layer W (huge — tens of millions of parameters)
         ↓
W_frozen + (A × B) = W_new
        (only a 3MB LoRA)

A numeric example:
  W  = a 1024 × 1024 matrix = ~4,000,000 parameters
  A  = a 1024 × 16 matrix   =    16,384  parameters
  B  = a 16 × 1024 matrix   =    16,384  parameters
  LoRA total = 32,768 instead of 4,000,000 (less than 1%!)

Rank (r) — how "smart" is the LoRA?

The Rank parameter determines the dimension of the A and B matrices. Common values: 4, 8, 16, 32, 64. The larger the Rank — the more the LoRA can learn, but it's also larger and may overfit on the dataset.

Rank File size Best for Risk
r=4~3MBLight Style, Flux.1Underfitting
r=8~6MBMedium Style, objectsLow
r=16~12MBCharacter / complex StyleLow–medium
r=32~24MBA character with many detailsOverfits easily
r=64~48MBSpecial cases onlyHigh

Alpha — the learning ratio

The Alpha parameter determines how strongly the LoRA "affects" the model during training. The internal formula: weight = alpha / rank. A common best practice: alpha = rank / 2. For example with r=16, use alpha=8 (weight=0.5).

settings
Best Practice — r=16, alpha=8

This is the most common combination in the community. Rank=16 gives enough capacity to learn a detailed character, and Alpha=8 keeps the training stable. For art styles — r=8, alpha=4 is usually enough and saves time and disk.

Network Dimension vs Alpha — the practical difference

In Kohya SS, "Network Dimension" = Rank. "Network Alpha" = Alpha. Setting Alpha=Rank (e.g. r=16, alpha=16) gives weight=1.0 — stronger but less stable. An Alpha lower than the Rank (alpha=rank/2 to alpha=rank/4) is the more stable approach.

Where LoRA is applied — UNet Attention Layers

LoRA isn't applied to all the model's layers. It focuses on theAttention Layers of the UNet — the layers responsible for "understanding" the prompt and forming relationships between parts of the image. The reason it works: most of the generic visual information is already "ready" in the frozen convolution layers.

Preparing the Dataset Mode 3 — Curriculum

Dataset quality is the most important factor for a LoRA's success. Bad images = a bad LoRA, even with the best settings. The preparation stage is usually the hardest.

How many images do you need?

Image requirements

warning
What to avoid in the Dataset

Don't include blurry images, partially cropped ones, images with heavy filters (Snapchat/Instagram filters), images where the character appears with other prominent people in the background, or low-contrast images. Every "problematic" image teaches the LoRA undesirable things.

Caption Writing — describing each image

Each image in the Dataset needs a matching TXT file with an accurate caption. The Caption teaches the LoRA what to associate with your trigger word and what is already known from the base model. The more accurate the caption, the more cleanly the LoRA learns.

Tools for Auto-Captioning

Trigger Word — the key to your character

The Trigger Word is a unique word in the prompt that activates the LoRA. It's important that it be rare and not a word the model already knows and associates with something else.

Dataset folder structure

dataset/
├── 20_ohwx_man/                   ← "20" = repeats, "ohwx_man" = class name
│   ├── photo001.jpg
│   ├── photo001.txt               ← "ohwx man, portrait, white background, looking at camera"
│   ├── photo002.jpg
│   ├── photo002.txt               ← "ohwx man, outdoor, smiling, casual clothing, sunny day"
│   ├── photo003.jpg
│   ├── photo003.txt               ← "ohwx man, side profile, studio lighting, dark background"
│   └── ... (20-30 pairs in total)
└── regularization/                ← optional — images of "some man" to prevent drift
    ├── reg001.jpg
    ├── reg001.txt                 ← "a man, portrait, photorealistic"
    └── ...
folder
The folder name determines the Repeats

The number before the class name (20_ohwx_man) determines how many times each image is counted per epoch. With 25 images and 20 repeats = 500 steps per epoch. With 10 epochs = 5,000 steps. Rule of thumb: 1,500–3,000 total steps for a character.

Training with Kohya SS Mode 4 — Technical

Kohya SS is the most common tool for training LoRA. It has a convenient GUI and support for SDXL, SD 1.5, and Flux.1. You can run it locally or on Google Colab.

Installation options

Important settings in the Kohya GUI

Setting Recommended value (character) Explanation
Base ModelSDXL 1.0 / Flux.1-devThe model you're training on
LoRA Rank (network_dim)16The size of the A,B matrices
Alpha8LoRA strength (rank/2)
Learning Rate (UNet)1e-40.0001 — the UNet learning rate
Learning Rate (Text Encoder)5e-50.00005 — more conservative
Epochs10–15The number of passes over the Dataset
Batch Size1–2images in parallel (1 for a 6GB GPU)
Noise Offset0.1improving contrast and color in the output
OptimizerAdamW8bitGPU-memory efficient
LR Schedulercosine_with_restartsa smooth decay in the learning rate
Save every N epochs5saving checkpoints for testing

Running directly with the Kohya Script

accelerate launch train_network.py \
  --pretrained_model_name_or_path="stabilityai/stable-diffusion-xl-base-1.0" \
  --dataset_config=dataset.toml \
  --output_dir="./lora_output" \
  --output_name="my_character" \
  --network_module=networks.lora \
  --network_dim=16 \
  --network_alpha=8 \
  --learning_rate=1e-4 \
  --unet_lr=1e-4 \
  --text_encoder_lr=5e-5 \
  --optimizer_type="AdamW8bit" \
  --lr_scheduler="cosine_with_restarts" \
  --lr_warmup_steps=100 \
  --noise_offset=0.1 \
  --max_train_epochs=15 \
  --save_every_n_epochs=5 \
  --save_model_as=safetensors \
  --mixed_precision=fp16 \
  --gradient_checkpointing \
  --xformers

The dataset.toml file

[general]
shuffle_caption = true
caption_extension = ".txt"
keep_tokens = 1          # the trigger word is always first

[[datasets]]
resolution = 1024        # for SDXL (512 for SD 1.5)
batch_size = 1

  [[datasets.subsets]]
  image_dir = "./dataset/20_ohwx_man"
  class_tokens = "ohwx man"
  num_repeats = 20

  # Regularization — optional
  [[datasets.subsets]]
  image_dir = "./dataset/regularization"
  class_tokens = "a man"
  num_repeats = 1
  is_reg = true
schedule
Check Checkpoints, not just the Final

Set save_every_n_epochs=5 to save checkpoints. Compare epoch 5, 10, 15 — the last epoch isn't always the best. Sometimes epoch 10 gives a more correct character than 15 if there's overfitting.

Using LoRA Mode 4 — Practical

After training finishes, you get a .safetensorsfile. Now you can load it in any interface and start generating images.

Loading in ComfyUI

In ComfyUI you add a Load LoRA node between the Checkpoint Loader and the KSampler:

Checkpoint Loader
      ↓ model + clip
 Load LoRA Node
  ├── lora_name: my_character.safetensors
  ├── strength_model: 0.8
  └── strength_clip:  0.8
      ↓ model + clip
CLIP Text Encode → KSampler → VAE Decode → image

Loading in Automatic1111 (A1111)

In the Prompt field, add the LoRA syntax directly:

# Basic syntax:
<lora:LoRA_filename_without_extension:strength>

# character example:
ohwx man wearing a spacesuit, professional photo, 4k <lora:my_character:0.8>

# art-style example:
a serene landscape <lora:monet_style:0.6>

# combining two LoRAs:
ohwx man in anime style, vibrant colors <lora:my_character:0.7> <lora:anime_xl:0.5>

LoRA strength — Strength Guide

LoRA type Recommended range Note
Character (Face)0.7–1.0Higher than 1.0 = distortions
Style0.3–0.7Low = a subtle blend with the style
Object0.6–0.9Depends on the object's prominence
A second LoRA (Stack)About 0.1 lower than the firstto prevent a conflict between LoRAs

Python with diffusers

from diffusers import StableDiffusionXLPipeline
import torch

# loading the base model
pipe = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    use_safetensors=True
).to("cuda")

# loading the LoRA
pipe.load_lora_weights(
    "./loras/my_character.safetensors",
    adapter_name="character"
)

# setting the strength
pipe.set_adapters(["character"], adapter_weights=[0.8])

# generating an image
image = pipe(
    prompt="ohwx man wearing a spacesuit, professional photo, 4k, detailed",
    negative_prompt="blurry, low quality, distorted face, extra limbs",
    num_inference_steps=30,
    guidance_scale=7.5,
    width=1024,
    height=1024,
).images[0]

image.save("output.png")
print("Saved successfully!")

Stacking LoRAs — combining several LoRAs together

# Python — loading two LoRAs together
pipe.load_lora_weights("./loras/character.safetensors", adapter_name="char")
pipe.load_lora_weights("./loras/style.safetensors",     adapter_name="style")

# setting the strength for each
pipe.set_adapters(["char", "style"], adapter_weights=[0.8, 0.5])

# a prompt with the trigger words of both:
# "ohwx man in style_myname artstyle, ..."

Common troubleshooting

Overfitting — the character breaks proportions

Symptoms: images look too "locked" onto the training data, strange recurring backgrounds, distorted faces at non-frontal angles, a lack of flexibility in the prompt.

Underfitting — the character doesn't look right

Symptoms: the trigger word doesn't produce the character, the face differs from the original, the LoRA looks "weak" even at high strength.

Style Bleeding — the LoRA "sticks" to every image

Symptoms: even without the trigger word, the model produces images that look like the training. The style/character "leaks" into all the outputs.

OOM — Out of Memory

Symptoms: A CUDA out of memory error right at the start of training. The GPU can't hold everything it needs in memory.

memory
Gradient Checkpointing — almost always worth it

Enabling --gradient_checkpointing reduces VRAM consumption by 30–40% in exchange for a slight ~10–20% slowdown in training time. If your GPU is 8GB or less — always enable it. Even at 12GB it's usually worth it.

Projects Mode 5 — Hands-On

Four projects in increasing order of difficulty — from an easy start to a complex Workflow. Each builds on the previous.

1
Beginner — green

A character LoRA — training on your own face

The classic project — a LoRA that trains the model to produce your face in any scene and pose. A good start for anyone who wants to learn LoRA.

  • Take 20–30 selfies from different angles — outdoors, indoors, day and night
  • Use BLIP2 or Florence-2 for automatic captions
  • Set a trigger word: ohwx man / ohwx woman
  • Train with a Kohya Colab Notebook — r=16, alpha=8, 15 epochs, SDXL
  • Check: ohwx man as an astronaut, professional photo <lora:me:0.8>
  • Compare epochs 5, 10, 15 and pick the best

Estimated time: 3–4 hours total including image preparation

2
Intermediate — yellow

A style LoRA — a specific artist or Aesthetic

Train a LoRA that reproduces a specific art style — watercolor, anime, neon noir, sweet pastel, 70s vintage and more.

  • Collect 50–100 images in the desired style (WikiArt, Pinterest, Civitai)
  • Use WD14 Tagger for illustrations, CLIP Interrogator for paintings
  • Set a trigger word: style_myname artstyle
  • Train with r=8, alpha=4 — a style doesn't need a high rank
  • Check: a cat in style_myname artstyle <lora:mystyle:0.6>
  • Try different strengths: 0.3, 0.5, 0.7 and see the difference

Estimated time: 5–6 hours including collecting and editing images

3
Intermediate–advanced — yellow

A LoRA for Flux.1 — the next generation

Black Forest Labs' Flux.1 is the most powerful diffusion model today (2026). Training a LoRA for it produces stunning realistic results, especially for faces and hands.

  • Download Flux.1-dev from Hugging Face (23GB — a license approval is required)
  • Use Kohya SS with the --flux_train flag
  • Flux settings: rank=4 is enough, lr=1e-4, 8–10 epochs (Flux learns fast)
  • The Text Encoder in Flux: T5-XXL — don't train it (only the UNet)
  • Training time: ~2 hours on an RTX 4090, ~5 hours on an RTX 3080
  • Compare the face quality to SDXL — you'll see a clear difference

Estimated time: 6–8 hours including downloading the model, preparation and training

4
Advanced — red

Consistent Characters — LoRA + ComfyUI Workflow

Building a full ComfyUI Workflow to produce a consistent character in different scenes — for stories, comics, storyboards, and advertising.

  • Train a Character LoRA on the character (Project 1 as a base)
  • Build a ComfyUI Workflow with IPAdapter to keep face consistency from a reference image
  • Add ControlNet Pose to control poses in each image
  • Create an automatic batch of 10+ images in different scenes
  • Option: add LCM-LoRA to produce quick drafts in seconds
  • Save the Workflow as JSON for reuse

Estimated time: 8–10 hours (including learning ComfyUI Nodes)

Cheat sheet — LoRA Quick Reference Mode 7 — Reference

Recommended settings by goal

Goal Rank Alpha UNet LR TE LR Epochs Images
Character (SDXL) 16 8 1e-4 5e-5 15 20–30
Style (SDXL) 8 4 5e-5 2e-5 10 50–100
Character (Flux.1) 4 2 1e-4 10 20–25
Style (Flux.1) 4 4 5e-5 8 40–60
Object (SDXL) 8 8 1e-4 5e-5 12 15–25

Trigger Word Best Practices

Dataset Checklist before training

Recommended tools — Ecosystem

Tool Use Price
Kohya SSLoRA training — the main toolFree (Open Source)
ComfyUIRunning LoRA + WorkflowsFree (Open Source)
Automatic1111A simple interface for using LoRAFree (Open Source)
CivitaiA LoRA marketplace + community sharingFree + premium
RunPodA cloud GPU for training$0.20–0.80/h
Google ColabFree training with limitsFree / Pro $9.99/mo
Florence-2Accurate Auto-captioningFree (HuggingFace)
WD14 TaggerAuto-captioning for illustrationsFree (HuggingFace)
rocket_launch

The next step — start training

Go to Google Colab, choose a ready-made Notebook for Kohya SDXL LoRA, and train your first LoRA within two hours — for free. You'll find up-to-date Notebooks on Civitai and GitHub.