controlnet
**ControlNet** is a **neural network architecture that adds precise spatial conditioning to pretrained diffusion models** — enabling users to control image generation with structural inputs like edge maps (Canny), depth maps, human poses (OpenPose), segmentation masks, and normal maps, so that generated images follow exact spatial layouts while the text prompt controls style and content, solving the fundamental controllability problem of text-to-image systems where text alone cannot specify precise spatial composition.
**What Is ControlNet?**
- **Definition**: A trainable copy of a diffusion model's encoder blocks connected to the original model via zero-convolution layers — the ControlNet branch processes a conditioning image (edge map, depth map, pose skeleton) and injects spatial control signals into the diffusion process without modifying the pretrained model's weights.
- **Zero Convolution**: ControlNet connects to the base model through convolution layers initialized to zero weights and zero biases — this ensures the ControlNet has no effect at the start of training, preserving the pretrained model's quality while gradually learning to incorporate the conditioning signal.
- **Architecture**: The pretrained diffusion model (Stable Diffusion) is locked/frozen — a trainable copy of its encoder processes the conditioning image, and the outputs are added to the decoder of the original model at each resolution level, creating a residual connection that injects spatial information.
- **Training**: Each ControlNet variant is trained on paired data (conditioning image + target image + text prompt) — for example, Canny ControlNet trains on (Canny edge map, original image, caption) triplets, learning to generate images that match both the edge structure and text description.
**ControlNet Conditioning Types**
| Condition Type | Input | What It Controls | Use Case |
|---------------|-------|-----------------|----------|
| Canny Edge | Edge detection map | Object boundaries, shapes | Precise outline control |
| Depth | Monocular depth map | 3D spatial layout | Scene composition |
| OpenPose | Human skeleton keypoints | Body pose, hand position | Character posing |
| Segmentation | Semantic seg mask | Region layout, object placement | Scene design |
| Normal Map | Surface normal vectors | 3D surface orientation | Material/lighting control |
| Scribble | Hand-drawn sketch | Rough shape guidance | Quick concept art |
| M-LLIe/Line Art | Clean line drawing | Detailed line structure | Illustration, manga |
| HED | Soft edge detection | Soft boundary guidance | Artistic style transfer |
| Tile | Low-res or tiled image | Upscaling, detail enhancement | Super-resolution |
**Why ControlNet Matters**
- **Spatial Precision**: Text prompts cannot specify exact pixel-level composition — "a person standing on the left with a dog on the right" is ambiguous, but a pose skeleton + depth map precisely defines the layout.
- **Production Workflows**: Professional artists and designers need reproducible spatial control — ControlNet enables using reference sketches, 3D renders, or existing photos as structural guides while AI handles rendering and style.
- **Composability**: Multiple ControlNets can be combined — use OpenPose for character pose + depth for scene layout + Canny for architectural details, each controlling different aspects of the generation.
- **Preservation of Base Model**: The frozen base model retains all its learned knowledge — ControlNet adds control without degrading image quality or requiring full model retraining.
**ControlNet in Practice**
- **ComfyUI**: Node-based workflow editor with native ControlNet support — chain multiple ControlNets, adjust conditioning strength per step, and combine with LoRA adapters.
- **Automatic1111**: Web UI with ControlNet extension — preprocessor integration (automatic Canny/depth/pose extraction), multi-ControlNet support, and per-step weight scheduling.
- **Diffusers (HuggingFace)**: Python API with `ControlNetModel` and `StableDiffusionControlNetPipeline` — programmatic control for batch processing and application integration.
- **ControlNet 1.1**: Improved versions with better training data and additional conditioning types — reference-only mode, IP-Adapter integration, and improved temporal consistency for video.
**ControlNet is the breakthrough architecture that made diffusion models practically useful for professional creative work** — adding precise spatial conditioning through edge maps, depth, pose, and segmentation inputs that guide image generation with pixel-level control while preserving the quality and diversity of the pretrained diffusion model.