Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 8 min read Research mediumAdept

Training Stable Diffusion with Dreambooth using Diffusers

Dreambooth fine-tuning of Stable Diffusion overfits quickly, so learning rate and step count must be tuned together. Experiments on 2x A100s found low learning rates (2e-6 for objects at ~400 steps, 1e-6 to 2e-6 with 800-1200 steps for faces) work best. Prior preservation matters mainly for faces, and the DDIM scheduler with ~100 inference steps cleans up noise from overfit models. Fine-tuning the text encoder alongside the UNet gave the biggest quality gain but needs ~24 GB of GPU memory; 8-bit Adam, fp16 or gradient accumulation bring training down to 16 GB.

Assumes: diffusion model basicsfine-tuning hyperparametersStable Diffusion

Related posts

  • Using LoRA for Efficient Stable Diffusion Fine-Tuning

    Hugging Face mediumAdept

    LoRA freezes pretrained weights and trains small rank-decomposition matrices, and diffusers now supports applying it to Stable Diffusion's cross-attention layers for both full fine-tuning and Dreambooth. Training fits in 11 GB of VRAM (a 2080 Ti) without 8-bit optimizers, uses a much higher learning rate (1e-4 vs ~1e-6), and produces ~3 MB weight files, roughly 1000x smaller than the UNet. A walkthrough covers the training script on a Pokémon dataset, looking up the base model from Hub metadata, and loading LoRA weights at inference with load_attn_procs. LoRA is also compared with Textual Inversion and Pivotal Tuning.

  • LoRA training scripts of the world, unite!

    Hugging Face hardMaster

    Combining Pivotal Tuning (textual inversion of newly inserted tokens, then LoRA fine-tuning) with the adaptive Prodigy optimizer produces strong SDXL Dreambooth LoRA results, and both are now available in a diffusers training script. The guide covers the relevant flags and recommended values: stopping textual inversion halfway through training, Prodigy with learning_rate=1.0 and bias correction, and separate text encoder and UNet learning rates. It also covers custom BLIP captions, Min-SNR gamma of 5.0, image repeats, prior preservation loss and dataset curation tips for faces and objects. Experiments on a 31-image Huggy mascot dataset compare batch sizes, optimizers and text encoder training modes.

  • Stable Diffusion with 🧨 Diffusers

    Hugging Face mediumAdept

    Stable Diffusion is a latent diffusion model that denoises compressed 64×64 latents rather than pixels, combining a VAE, a text-conditioned U-Net with cross-attention, and a frozen CLIP text encoder. The Diffusers walkthrough covers running it in a few lines with StableDiffusionPipeline, including fp16 loading for GPUs under 10GB, seeded generators for determinism, and tuning num_inference_steps (50 recommended) and guidance_scale (7–8.5). It explains why the 8× VAE compression (3×512×512 to 4×64×64) makes generation feasible on 16GB GPUs. It then shows how to build a custom inference pipeline by loading components individually and swapping in schedulers such as K-LMS.

  • Diffusers welcomes Stable Diffusion 3

    Hugging Face mediumAdept

    Stable Diffusion 3 Medium (2B parameters) is now usable through Diffusers. Its architecture pairs three text encoders (two CLIP models and T5-XXL) with a Multimodal Diffusion Transformer that runs joint attention over text and image-patch sequences, and it is trained with rectified flow matching, served by a new FlowMatchEulerDiscreteScheduler (shift=3.0 recommended). Benchmarks on an A100 show the memory tradeoffs: CPU offloading cuts VRAM from 18.8GB to 12GB at roughly 6.8x latency, dropping T5 brings it to 4.3GB, and 8-bit T5 reaches 10.6GB with almost no slowdown. torch.compile delivers about a 4x speedup (0.585s), and a DreamBooth LoRA fine-tuning script is included.

  • Diffusers welcomes Stable Diffusion 3.5 Large

    Hugging Face mediumAdept

    Stable Diffusion 3.5 Large (8B) and a timestep-distilled Turbo variant are now usable in Diffusers. The architecture matches SD3 Medium except for QK normalization and dual attention layers in the MMDiT blocks. Code covers bf16 inference, few-step (4-8 step) Turbo generation without classifier-free guidance, NF4 quantization via bitsandbytes with CPU offload for consumer GPUs, and single-file checkpoint loading. LoRA fine-tuning on 24GB GPUs works with the existing SD3 DreamBooth script, combined with peft's k-bit training preparation.

The quest for software engineering knowledge.

Look:
Layout: