← All projects
ML research project

Character-consistent generation

How well does SDXL keep one character recognizable across scenes, and how much does a LoRA add?

A DreamBooth LoRA fine-tune on Stable Diffusion XL, measured with a fixed character, fixed scenes, fixed seeds and one shared set of metrics.

Six scenes generated from the text description only, one fixed seed: the woman's face shape, age and hair length drift between images
Text only · identity 0.545
The same six scenes with text plus the LoRA: the same woman is recognizable in a coffee shop, rainy street, mountain trail, spacesuit, armor and picnic
Text + LoRA · identity 0.809
StackPython · PyTorch · SDXL · Diffusers · LoRA / DreamBooth
MetricsSFace identity, DINOv2, CLIP-I, CLIP-T scene fidelity
TrainingRank 16, 800 steps, about 20 minutes on an L4
ResultIdentity up 0.15 to 0.26 in every setting
01

Headline result

Same prompts, with and without the adapter, so the difference isolates the LoRA. Identity is SFace similarity on detected, aligned faces; higher is more similar.

SettingText onlyLoRA token onlyText + LoRA
prompt_only · varied seed, CFG 70.5250.6130.751
fixed_seed · one seed, CFG 70.5450.6790.809
high_cfg · one seed, CFG 120.6480.6750.798

It removes failures

The worst pair of images improved by 0.12 to 0.32, not just the average.

The token alone carries identity

The LoRA token by itself beats the full text description in every setting.

Scene fidelity barely moves

CLIP-T fell by 0.025 in one setting and was flat in the other two.

02

Adapter strength buys identity cheaply

Sweeping the LoRA scale from 0 to 1.0 raises identity steadily in every setting while scene fidelity stays roughly flat.

Scale sweep chart: identity rises steadily with LoRA strength from 0 to 1.0 in all three settings while scene fidelity stays roughly flat

A metric answers the question it was trained on, not the one you're asking.

Scored on whole frames, the fine-tune looked worse: DINOv2 fell from 0.24 to 0.16, because the compositions changed, not the faces. Cropping to faces fixed that but still said the token alone underperformed the description.

A face-recognition embedding, SFace, aligns the face and ignores everything else, and it reversed that conclusion too. The more identity-specific metric was right all three times. And CLIP couldn't tell these faces apart at all: any auburn-haired, freckled woman scores alike.

Training set0.722 SFace
Text + LoRA0.809 SFace
Takeawaythe adapter is more consistent than its own training data
04

Engineering notes

fp16 needed a fixed VAE

SDXL's stock VAE produces NaNs in fp16, so every pipeline loads a patched VAE. On a T4, which has no bf16, that's what makes training possible at all.

Training loss isn't a quality signal

Per-step diffusion loss mostly reflects which noise level was sampled, so evaluation uses generated images on held-out scenes instead.

CLIP has to stay in its own space

transformers 5 changed what CLIP's feature functions return. The harness applies the projections explicitly; otherwise it would compare 768-dim text against 1024-dim image states.

Runs on a T4 or an L4

Two training scripts share steps, learning rate and schedule, and differ only in hardware flags: resolution, precision and 8-bit Adam.

05 · Limitations
  • Six images per setting, so gaps under about 0.05 are inconclusive
  • SFace was trained on real photos; synthetic faces are out of distribution
  • All twelve training images are frontal portraits with the same clothing
  • One training run, one seed schedule, one base model
06 · Next
  • Push the scale sweep above 1.0 and train past 800 steps
  • Measure attribute leakage, like training clothing appearing in unrelated scenes
  • A more diverse training set with multi-view generation or pose conditioning
  • Add prior preservation and measure class drift