Projects / Faster sampling with DDIM, and LoRA fine-tuning of Stable Diffusion
Faster sampling with DDIM, and LoRA fine-tuning of Stable Diffusion
Image and Video Generation, National Yang Ming Chiao Tung University
Abstract
The second lab builds on the first. I implement DDIM sampling [1], which reuses a trained diffusion model with 50 steps instead of 1,000, on 2D Swiss-roll data and on images, and measure FID across 20 combinations of step count and stochasticity. Then I fine-tune Stable Diffusion v1.4 with LoRA [2], once to learn an artistic style and once, with DreamBooth [3], to learn a character’s identity. Fifty DDIM steps give FID 12.6 against 8.7 with all 1,000, a 20× faster sampler for a moderate loss of quality.
DDIM: the same model in 50 steps
DDIM replaces the Markovian reverse process with one that can skip steps: it samples on an evenly spaced subset of the training timesteps (with 50 steps, 980, 960, …, 0), and a parameter sets how much fresh noise each step adds ( is deterministic). On the Swiss roll, 50 DDIM steps reach a Chamfer distance of 26.92, under the assignment’s target of 40 (Figure 1).

DDIM samples with 50 steps (orange) against the Swiss-roll data, Chamfer distance 26.92.
DDIM on images: FID by number of steps and stochasticity η (best value per row in bold).
| Steps | η = 0 | η = 0.2 | η = 0.5 | η = 1 |
|---|---|---|---|---|
| 10 | 23.99 | 22.40 | 26.67 | 38.76 |
| 20 | 16.45 | 17.71 | 17.34 | 23.03 |
| 50 | 13.57 | 12.64 | 13.14 | 14.79 |
| 100 | 13.71 | 12.00 | 11.53 | 10.58 |
| 1000 | 11.70 | 11.15 | 8.84 | 8.69 |
With few steps a little or no noise works best, and with many steps full stochasticity does. Fifty steps with give FID 12.64, a 20× faster sampler for a moderate loss of quality, which is the configuration I would use in practice.

The same results as a chart (drawn from Table 1): with few steps, deterministic or nearly deterministic sampling () is best; with many steps, full stochasticity () is.
LoRA and DreamBooth on Stable Diffusion
LoRA trains small low-rank matrices inside Stable Diffusion v1.4 instead of the whole model. I used it twice, on datasets I collected and captioned myself (BLIP-2 captions, corrected by hand), both from the Berserk manga and anime.
A style from 39 images
The first LoRA learns the series’ dark-fantasy castles from 39 images: exteriors, interiors, bridges and night scenes (Figure 3). With the same prompts and seeds, the base model draws generic fantasy castles, while the fine-tuned model picks up the style’s stone architecture, dramatic lighting and atmosphere (Figures 4 and 5).

Six of the 39 training images.

“Colossal castle on fire, smoke billowing into the night sky, embers flying, chaos and destruction, dark fantasy art”: the base model (top) and after LoRA training, epoch 120 (bottom), with the same seeds.

“Gothic forgotten castle covered in snow, intricate architecture, glowing windows, eerie atmosphere, volumetric light, masterpiece”: the base model (top) and after LoRA training, epoch 110 (bottom).

New scenes from the LoRA model (50 steps, guidance 7.5, 512 × 512). Top: “a castle interior, with flickering torches”; “a huge castle on a cliff at night, with a full moon in the sky”; “an ancient castle bridge over a river, surrounded by snow”. Bottom: “epic fantasy castle, perched on a jagged mountain peak, cinematic lighting, dramatic dark clouds”; “a colossal castle on fire …”; “castle ruins in a dark forest”.
A character’s identity with DreamBooth
The second model binds the protagonist, Guts, to a rare token (“sks guts”) from 20 images that vary the angle, expression, pose and background, so that the model learns the identity rather than one picture (Figure 7). Among checkpoints from 1,500 to 4,000 steps, the last kept the identity best without losing flexibility, and 200 sampling steps instead of 50 removed artifacts in the faces. The character stays recognizable in scenes that never appear in the training data (Figure 8).

Six of the 20 training images.

“Portrait of sks guts …” (top: as a portrait, studying in the library, in a dark forest; bottom: eating breakfast, fishing, standing in a battlefield), each followed by “detailed anime character, high quality, sharp focus, clean lines” (200 steps, guidance 7.5).
Findings
- DDIM trades steps for quality smoothly: 50 steps keep most of the quality of 1,000, and 20 steps are still usable (FID 16.5).
- The best stochasticity depends on the step count: or 0.2 with 10 to 50 steps, with 100 or more.
- LoRA adapts Stable Diffusion with a few dozen images and a small fraction of its parameters, for a style as well as for a character’s identity.
- For identity, the data and the sampler mattered: varied training views, the last checkpoint and 200 sampling steps were what kept the character’s face consistent.
References
- J. Song, C. Meng and S. Ermon. Denoising diffusion implicit models. ICLR, 2021.
- E. J. Hu et al. LoRA: Low-rank adaptation of large language models. ICLR, 2022.
- N. Ruiz et al. DreamBooth: Fine tuning text-to-image diffusion models for subject-driven generation. CVPR, 2023.