Skip to content

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

Hugging Face 9 min read How-to mediumAdept

Train your ControlNet with diffusers

Training a custom ControlNet for Stable Diffusion comes down to three steps: choose a condition that an existing model can extract from ordinary images, build a dataset of image/conditioning-image/caption triples, and run the diffusers train_controlnet.py script. The worked example builds a facial-landmark ControlNet from Microsoft's 100K FaceSynthetics images, using SPIGA to produce iBUG 68-point landmark masks and BLIP to generate captions, then trains on Stable Diffusion 2.1 base with a single A100. Three epochs at batch size 4 overfit and the model lost concepts and styles. About one epoch (pose following began around 15K steps and matured near 25K) worked, though the synthetic data produced uncanny 3D-looking faces. Memory tips for 16GB and 12GB GPUs include gradient accumulation, gradient checkpointing, 8-bit Adam and set_grads_to_none.

Assumes: Stable Diffusion basicsPyTorch model trainingHugging Face datasets

Related posts

  • ControlNet in 🧨 Diffusers

    Hugging Face mediumAdept

    ControlNet conditions Stable Diffusion on spatial inputs such as Canny edges, segmentation maps, scribbles or OpenPose keypoints. It does this by training a copy of the UNet that is linked to the frozen original through zero-convolution layers, so swapping conditionings only means swapping ControlNet weights (about 700M extra parameters for SD 1.5). The Diffusers StableDiffusionControlNetPipeline makes this practical with fp16 weights, the UniPCMultistepScheduler (cutting steps from 50 to 20), model CPU offloading and xformers attention for fast, memory-efficient inference. Worked examples cover Canny edge control, DreamBooth fine-tuned models, pose transfer with OpenPose, and combining multiple ControlNets with masked conditionings and per-condition scales.

  • How Diffusion Controller unifies and simplifies AI image generation

    Google Research hardMaster

    Diffusion Controller reframes diffusion denoising as a continuous control problem, unifying inference-time guidance and fine-tuning methods such as LoRA, reward-weighted regression and policy gradients under one framework. A lightweight trainable side network attached to a frozen backbone adds small corrections to the base model's score using the intermediate reverse mean, so it also works with gray-box, access-restricted models. On a Stable Diffusion v1.4 backbone across SFT, reward-weighted loss and PPO regimes, the gray-box controller beat LoRA on HPS-v2 win rates while touching fewer layers. The white-box variants reached about a 90% win rate over the baseline, and a single inference-time guidance-strength parameter dials alignment up or down.

  • Efficient Controllable Generation for SDXL with T2I-Adapters

    Hugging Face mediumAdept

    T2I-Adapter-SDXL drives the 2.6B-parameter SDXL model with a 79M-parameter adapter that runs once per generation, unlike ControlNet, which runs alongside the UNet at every denoising step. That makes it about 94% smaller than ControlNet-SDXL (158 MB vs 2.5 GB in fp16). Checkpoints for sketch, canny, lineart, depth and openpose conditioning were trained on 3M LAION-Aesthetics pairs at batch size 128, learning rate 1e-5, for 20k–35k steps. They are usable through the diffusers StableDiffusionXLAdapterPipeline, with adapter_conditioning_scale and adapter_conditioning_factor controlling how strongly and for how many steps the condition applies.

  • Training Stable Diffusion with Dreambooth using Diffusers

    Hugging Face mediumAdept

    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.

  • 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.

The quest for software engineering knowledge.

Look:
Layout: