- Regularization
- Class images
- Prior preservation
- Kohya
- Flux
- SDXL
Do You Need Regularization (Class) Images for Flux and SDXL LoRAs?
What regularization (class) images do, how prior preservation works in Kohya, and when Flux and SDXL LoRAs actually benefit from them.
What Regularization (Class) Images Actually Do
Regularization images, also called class images, were introduced with DreamBooth (Ruiz et al., 2022). When you fine-tune a model on a few photos of one subject with a prompt like 'a photo of sks dog', the model tends to forget what a generic dog looks like and starts drawing your dog for every dog prompt. The paper calls this language drift and fixes it with a class-specific prior preservation loss.
Prior preservation works by generating or collecting many images of the class ('a photo of a dog') and training on them alongside your instance images. The loss on those class images pulls the model back toward its original idea of the class while the instance images teach the new subject.
In Kohya sd-scripts this is the reg_data_dir option (or is_reg = true subsets in a dataset TOML), weighted by prior_loss_weight, which defaults to 1.0.
How Kohya sd-scripts Uses Regularization Images
Kohya pairs regularization images with training images step for step. In the sd-scripts dataset code, one epoch contains training images times their repeats, and regularization images are matched to that count: if you have more, Kohya logs that some reg images are not used; if you have fewer, it repeats them until the counts match. Because each training step now also processes a class image, an epoch takes roughly twice as long.
Regularization folders use the same repeats_class naming as training folders, for example 1_woman, and their captions should describe only the class, never the trigger word. Read what ohwx means in Kohya folder names and the full Kohya folder layout if the naming is new to you.
When You Need Them and When You Do Not
| Situation | Use reg images? | Why |
|---|---|---|
| Single character or person LoRA on SDXL or Flux | Usually no | Short LoRA runs rarely overwrite the whole class; cost is about 2x training time |
| Generic prompts (a woman, a man) start looking like your subject | Yes | This is exactly the class drift prior preservation targets |
| Full DreamBooth fine-tune of the base model | Recommended | Many more weights change, so drift is more likely; this is the setting the paper studied |
| Style LoRA | Rarely | There is no single class to preserve; diverse subjects in the dataset do more |
| Only low-quality or off-model reg images available | No | The model also learns from reg images, so bad ones degrade output |
If You Use Them: How to Pick Good Class Images
- 01
Match the class word exactly
If captions say woman, generate or collect woman images and caption them woman. Mismatched classes give no protection. - 02
Prefer real or base-model images
DreamBooth generated class images with the frozen base model itself, so they represent its existing prior. Images from a different model or style pull outputs toward that look. - 03
Match resolution and framing
Use the same training resolution and a similar mix of portraits and full-body shots so buckets line up; see aspect ratio bucketing. - 04
Have enough of them
Provide at least as many reg images as training images times repeats; with fewer, Kohya repeats the same reg images to fill the epoch. - 05
Lower prior_loss_weight if identity weakens
If the subject becomes less recognizable, reduce prior_loss_weight below 1.0 before abandoning regularization.
What Usually Works Better Than Regularization for LoRAs
- Stop earlier: pick the checkpoint before drift appears using a sample grid, as in overfitting vs undertraining.
- Lower the LoRA strength at inference (for example 0.7 to 0.9) instead of retraining.
- Use a rare trigger token and caption variable details, as in LoRA trigger words and captions.
- Build a varied, consistent dataset in LoRA Dataset Studio so the model learns the subject, not one pose or background.
Frequently asked questions
Do I need regularization images for a Flux LoRA?
Usually not. Most Flux character LoRAs are trained without them. Add them only if generic class prompts start producing your subject, and use high-quality images of the same class.
What is prior preservation loss?
It is the DreamBooth technique of training on generic class images alongside your subject so the model keeps its original understanding of the class. In Kohya it is controlled by reg_data_dir or is_reg subsets and prior_loss_weight.
How many regularization images do I need in Kohya?
At least the number of training images multiplied by their repeats. Kohya uses that many reg images per epoch and ignores the rest for that epoch.
Should regularization captions include the trigger word?
No. Reg captions should contain only the class description, such as woman, so the class stays generic while the trigger word carries your subject.
Can bad regularization images hurt my LoRA?
Yes. The model trains on them too, so blurry or off-style class images can pull outputs toward that look and weaken identity.
Sources and further reading
- Ruiz et al., DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation (arXiv 2208.12242)
- kohya-ss/sd-scripts: Dataset config README (is_reg, class_tokens)
- kohya-ss/sd-scripts: library/args.py (--prior_loss_weight default 1.0, --reg_data_dir)
- Hugging Face Diffusers: DreamBooth training with prior preservation



