---
title: "Train your ControlNet with diffusers"
description: "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."
url: "https://swe.quest/articles/train-your-controlnet-with-diffusers-0fe323cd4b532fe5"
canonical: "https://huggingface.co/blog/train-your-controlnet"
source: "Hugging Face"
published: "2023-03-24"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["model-training","computer-vision","machine-learning","python"]
---

# Train your ControlNet with diffusers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-03-24, 9 min read, How-to. Original: [https://huggingface.co/blog/train-your-controlnet](https://huggingface.co/blog/train-your-controlnet)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Stable Diffusion basics
- PyTorch model training ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- Hugging Face datasets

## Keywords

ControlNet, diffusers, Stable Diffusion, FaceSynthetics, SPIGA, BLIP, accelerate, bitsandbytes

## Related posts

- [ControlNet in 🧨 Diffusers](https://swe.quest/articles/controlnet-in-diffusers-2c39bfe039d68caf.md): Hugging Face · 2023-03-03 · Medium · 11 min read · Computer vision, Inference & serving, Python, Machine learning
  ControlNet conditions Stable Diffusion on spatial inputs such as Canny edges, segmentation maps, scribbles or OpenPose keypoints.
- [How Diffusion Controller unifies and simplifies AI image generation](https://swe.quest/articles/how-diffusion-controller-unifies-and-simplifies-ai-image-generation-261f5c78987e6b2e.md): Google Research · 2026-09-29 · Hard · 7 min read · Model training, Computer vision, Machine learning
  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.
- [Efficient Controllable Generation for SDXL with T2I-Adapters](https://swe.quest/articles/efficient-controllable-generation-for-sdxl-with-t2i-adapters-4ef46153eee1c0c4.md): Hugging Face · 2023-09-08 · Medium · 5 min read · Computer vision, Model training, Inference & serving, Python
  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.
- [Training Stable Diffusion with Dreambooth using Diffusers](https://swe.quest/articles/training-stable-diffusion-with-dreambooth-using-diffusers-498f7d039b45823b.md): Hugging Face · 2022-11-07 · Medium · 8 min read · Model training, Computer vision
  Dreambooth fine-tuning of Stable Diffusion overfits quickly, so learning rate and step count must be tuned together.
- [Diffusers welcomes Stable Diffusion 3](https://swe.quest/articles/diffusers-welcomes-stable-diffusion-3-f6ced777e2fcbd47.md): Hugging Face · 2024-06-12 · Medium · 7 min read · Computer vision, Inference & serving, Model training, Python
  Stable Diffusion 3 Medium (2B parameters) is now usable through Diffusers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
