LoRA training
How to train a character LoRA: a practical start-to-finish guide
A character LoRA is not a zip file full of selfies plus a magic step count. It is a small adapter learning the difference between a base model and a carefully described subject. Most disappointing LoRAs fail before training starts: the wrong base, repetitive images, lazy captions, or no validation plan. This workflow fixes those parts first.
Based on official documentation, public benchmarks where relevant, and corroborated practitioner reports where useful. No placement in these guides is paid.
The short answer
What I would pick
For a new local character project, I would start with FLUX.2 Klein 4B Base and AI Toolkit. It is a manageable, trainable local base with permissive terms, and its small size makes iteration realistic for a solo creator. Begin with 20–30 strong, varied images, sample fixed prompts every 100–200 steps, and expect to choose an earlier checkpoint rather than the final one.
Use Z-Image Base with Diffusers when Z-Image is already your production ecosystem. Do not train against a distilled Turbo checkpoint just because it is your favorite inference model; use the model family’s documented training target.
On this page
Skip to the part you need
- Choose the base before anything else
- Hardware and software prerequisites
- Build a small, deliberate dataset
- Write captions and choose a trigger
- A FLUX.2 Klein starting configuration
- Run, sample, and save checkpoints
- Validate instead of admiring one cherry-pick
- Training a Z-Image LoRA instead
- Export and test in ComfyUI
- Diagnose failures, consent, and rights
Choose the base before anything else
A LoRA does not replace its base model. It steers it. The adapter learns efficiently because the base already knows faces, cameras, fabrics, lighting, and composition. That also means the base model’s anatomy, prompting language, license, and visual bias come along for the ride.
Start by generating ten untrained images close to the work you want to make. If the base cannot produce the age range, photographic style, body framing, or skin rendering you need, training identity into it will not repair the foundation. Choose another base now, before paying a GPU to memorize your workarounds.
| Base | Good reason to choose it | Check before training |
|---|---|---|
| FLUX.2 Klein 4B Base | Lean local training, editing support, Apache 2.0 release | Use the Base checkpoint, not the speed-focused distilled checkpoint |
| Z-Image Base | Your generation stack already uses Z-Image and its prompt behavior | Follow the Z-Image-specific Diffusers script and current model license |
| SDXL family | Existing production graph, mature tools, broad community knowledge | The exact checkpoint license and whether its defaults suit your subject |
Do not assume adapters transfer between families. A LoRA trained for FLUX.2 Klein is not a Z-Image or SDXL LoRA. Store the exact base model ID, revision, hash, license, training tool commit, and configuration beside every output.
Hardware and software prerequisites
FLUX.2 Klein 4B is small by current standards, not small in ordinary-laptop terms. A modern NVIDIA GPU with 24GB of VRAM is the comfortable local starting point for this guide. Memory-saving options can reduce that requirement, but they usually trade speed, setup simplicity, or optimizer choices. If your machine cannot hold a stable training run, rent a GPU for a few hours instead of spending a weekend fighting out-of-memory errors.
Before opening the training UI, prepare:
- A current NVIDIA driver and a CUDA/PyTorch combination supported by the training tool.
- A clean Python environment dedicated to AI Toolkit or Diffusers.
- Enough fast disk for model weights, cached latents, previews, and several checkpoints.
- The official Base checkpoint and any access agreement required by its host.
- A dataset folder, a separate validation file, and a project folder for configs and notes.
Install from the current AI Toolkit repository and start with its FLUX.2 Klein example, because dependency and configuration names change faster than editorial guides. Save the repository commit and your package lock or environment export. “It worked last month” is not a reproducibility strategy.
Run one official sample configuration before modifying it. That separates installation problems from dataset problems. If a known-good example cannot train and produce a sample, your captions are not the issue yet.
Build a small, deliberate dataset
For a first character LoRA, 20–30 excellent images is a useful working set. Fifteen can be enough for a simple, distinctive identity. Forty may help when the subject needs more hairstyles, angles, expressions, and full-body coverage. Those are starting ranges, not a law: twenty near-duplicates contain less information than twelve deliberate photographs.
Use only images of a fictional character or a consenting adult for whom you have clear training rights. Remove minors, private photographs, leaked material, watermarked images, and photos you merely found through search. Permission to view or repost an image is not automatically permission to train a model on a person’s identity.
A balanced character set usually needs:
- Close, medium, three-quarter, and full-body framing.
- Front, three-quarter, and side angles, plus a modest high/low camera variation.
- Neutral, smiling, serious, and mid-expression faces.
- Several locations, light directions, and camera distances.
- Different outfits and hairstyles unless one is intentionally part of the character.
- Clean hands and body geometry in the frames where they are visible.
Keep five useful conditions out of training. They can be prompts, reference images, or both. A holdout is how you learn whether the LoRA understands the identity instead of recalling the dataset. The dedicated dataset guide goes deeper on shot lists, culling, aspect buckets, and captions.
Write captions and choose a trigger
Give the identity a rare, readable trigger such as rfgmara. Avoid a common word, a celebrity name, or a token that the base already associates with a visual concept. The trigger is a handle for the learned identity; it is not security and it does not make an unauthorized dataset ethical.
Caption what you want to remain controllable. If every image contains a black leather jacket but none of the captions mention it, the trainer has no reason to separate jacket from identity. The same applies to a studio background, heavy makeup, direct flash, or one hairstyle.
A useful caption is plain and factual:
photo of rfgmara, adult woman, medium shot, looking to the side,
short wavy brown hair, blue cotton shirt, overcast window light,
neutral apartment interiorDo not caption stable facial geometry as if you need to prompt it every time. The adapter should learn the identity. Do caption transient attributes: clothes, glasses, expression, pose, framing, light, background, and photographic treatment. Automatic captioning can produce a first draft, but inspect every file. Captioners confidently invent eye color, age, ethnicity, camera gear, and emotions.
Use one caption format consistently. Place a same-name text file beside each image if that is the dataset convention selected in AI Toolkit. Confirm the tool is actually reading those sidecars in the training log; a perfect caption folder ignored by the loader is an uncaptioned dataset.
A FLUX.2 Klein starting configuration
Start from the current official FLUX.2 Klein Base example in AI Toolkit. The table below is a conservative first experiment for a 20–30 image character set, not a preset that wins every subject. Keep the official model-specific optimizer, scheduler, and target modules unless the repository says otherwise.
| Setting | Starting point | Reason to change it |
|---|---|---|
| Checkpoint | FLUX.2 Klein 4B Base | Change only if you intentionally choose another model family |
| Resolution | Aspect buckets centered around 1024px | Lower for memory; raise only when the official recipe and hardware support it |
| LoRA rank / alpha | 16 / 16 | Try 32 only when a varied identity consistently lacks capacity |
| Network learning rate | 5e-5 to 1e-4 test range | Lower if identity arrives abruptly with texture burn-in or instability |
| Total optimizer steps | 800–1,600 | Dataset repetition and learning rate change what a “step” means |
| Preview interval | Every 100–200 steps | More often for a small dataset where the useful window may be brief |
| Checkpoint interval | Every 200–250 steps | Storage is cheaper than discovering the final checkpoint overfit |
| Precision | BF16 where the GPU and official recipe support it | Use the tool’s documented fallback; do not improvise mixed precision |
Effective batch size, gradient accumulation, caching, and optimizer state have a large memory impact. Adjust those with the tool’s current memory guidance rather than copying a config from a different architecture. Change one meaningful variable per run and name the experiment accordingly: klein4b-r16-lr5e5-v01 is more useful thanfinal_final_good.
Run, sample, and save checkpoints
Before the full run, train for enough steps to create one preview and one checkpoint. Confirm that loss is finite, images and captions are being counted, samples use the expected seed, and output files land on persistent storage. This ten-minute check is the cheapest failure you will ever buy on a cloud GPU.
Use four to six fixed sample prompts throughout training. Keep seeds, dimensions, guidance, sampler, and negative prompt stable. Include one easy portrait, one side angle, one full-body scene, one different hairstyle or outfit, one difficult light, and one prompt that does not contain common training backgrounds.
Watch the previews as a sequence, not individually. The useful checkpoint is often the first one that carries identity into unseen conditions while still obeying the prompt. Past that point, resemblance may look stronger because the adapter is pulling every scene toward the training set.
Save four things together after every experiment:
- The LoRA checkpoint and exact base-model identifier.
- The complete training configuration and tool commit.
- The dataset manifest or hashes, without redistributing private source images.
- The fixed validation prompts, seeds, images, and a short decision note.
Validate instead of admiring one cherry-pick
A good LoRA should add identity and give control back to the prompt. Test at several adapter strengths—such as 0.6, 0.8, and 1.0—using the same seeds. If the LoRA only resembles the subject at an extreme strength that destroys clothing, lighting, or composition, training has not really succeeded.
| Validation test | Healthy behavior | Warning sign |
|---|---|---|
| Unseen background | Identity holds; new place follows the prompt | Training room or color palette keeps returning |
| Unseen outfit | Clothing changes without losing the face | One jacket or neckline appears in every output |
| Side and full-body views | Proportions remain plausible across framing | Only close front-facing portraits resemble the subject |
| Low adapter strength | Some identity signal remains around 0.6–0.8 | Nothing happens until the model is overpowered |
| Prompt obedience | Expression, light, camera, and pose still change | Every image converges on a dataset pose or beauty treatment |
Compare checkpoints in a contact sheet with labels hidden, then reveal them after scoring. Keep the earliest checkpoint that meets the brief. Training longer because the loss is still moving is how a useful adapter becomes a costume it cannot take off.
Training a Z-Image LoRA instead
If Z-Image is your target ecosystem, use the official Diffusers train_dreambooth_lora_z_image.py workflow and the non-distilled Z-Image Base checkpoint documented with it. Do not assume the FLUX.2 target modules, text-encoder behavior, or memory flags map across by changing a model path.
- Install the Diffusers example dependencies from the Z-Image DreamBooth README.
- Run
accelerate configfor the actual GPU or cloud instance. - Point the script at Z-Image Base and your captioned instance-data directory.
- Begin from the README’s current learning-rate, precision, and memory recipe.
- Add fixed validation prompts and save intermediate LoRA checkpoints.
- Test the adapter with the same Z-Image pipeline and prompt language used in production.
The data principles do carry across: varied images, explicit transient captions, holdout conditions, and early checkpoints. The architecture-specific training knobs do not. Read the model card and training script at the pinned revision you actually run, especially before commercial use.
Export and test in ComfyUI
Export the selected adapter as a .safetensors file with a name that includes the base family and version. Copy it into the ComfyUI LoRA model folder expected by your installation, refresh model paths, and load it after the matching base model. A LoRA appearing in the menu does not prove compatibility.
Build a clean acceptance graph before adding production tricks:
- Matching base checkpoint, text encoders, and VAE.
- One LoRA loader with separate, visible strength controls where supported.
- Fixed sampler settings appropriate to that base.
- Six validation prompts and seeds saved in the workflow.
- No face detailer, style LoRA, ControlNet, upscale, or post-processing.
Generate a contact sheet at several weights, then add your normal production nodes one at a time. If identity collapses only after a style LoRA or detailer is restored, retraining the character is the wrong fix. You have found a workflow conflict.
Preserve the clean graph with the adapter. ComfyUI embeds workflow metadata in supported image outputs, which makes a known-good sample far more useful than a loose file named “best settings.”
Diagnose failures, consent, and rights
| Symptom | Likely cause | First fix |
|---|---|---|
| Same outfit or room every time | Under-captioned repeated attributes | Caption them explicitly and diversify or remove duplicates |
| Excellent close-up, weak full body | Dataset framing imbalance | Add a few high-quality medium and full-body views |
| Face looks burnt or over-sharpened | Overtraining, high learning rate, or source enhancement | Compare an earlier checkpoint and inspect source images at 100% |
| Identity changes with expression | Too little expression and angle diversity | Improve the dataset before adding rank or steps |
| Prompt stops controlling the image | Overfitting or excessive adapter weight | Use an earlier checkpoint and test lower strength |
| Training is unstable or produces noise | Wrong architecture recipe, precision, LR, or corrupt data | Return to the unmodified official example and a tiny known-good subset |
More steps are the last fix, not the first. Dataset repair has the highest leverage: remove duplicates, rebalance angles, correct captions, and replace low-quality or filtered images. Then change one training parameter.
Finally, document consent and permitted uses beside the model. Train fictional characters you own or adults who explicitly agreed to this use. Do not create identity adapters from minors, private people, former partners, leaked images, or a public figure scraped from the web. Do not use the output to impersonate a person, bypass platform rules, or imply their endorsement. A technically successful LoRA can still be a project you had no right to make.
Research notes
Primary sources and further reading
Model names, licenses, limits, and prices move quickly. These are the sources used for the dated market check above; confirm live pricing and terms before spending money.
- Hugging Face: fine-tune FLUX.2 Klein with a LoRACurrent official walkthrough for a FLUX.2 Klein LoRA using AI Toolkit.
- AI ToolkitTraining code, supported models, configuration examples, dataset layout, and active setup notes.
- Black Forest Labs: FLUX.2Official model variants, Base versus distilled releases, hardware notes, and license links.
- Diffusers: LoRA trainingHow LoRA adapters work in Diffusers and the parameters exposed by official training scripts.
- Diffusers: Z-Image DreamBooth LoRAOfficial Z-Image-specific setup, training script, memory options, and inference notes.
- Diffusers: Z-Image LoRA training scriptThe implementation and current command-line options behind the Z-Image recipe.
- ComfyUI: LoRA workflowOfficial instructions for placing, loading, and applying LoRA files in a graph.
