Skip to content

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

Hugging Face 11 min read How-to mediumAdept

ControlNet in 🧨 Diffusers

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.

Assumes: Stable Diffusion basicsPyTorchPython

Related posts

  • Train your ControlNet with diffusers

    Hugging Face mediumAdept

    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.

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

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

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

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