View all articles
ComfyUIControlNetimage generationtutorial

ComfyUI ControlNet Tutorial: Guided Image Generation

JG
Jacobo González Jaspe
|

Reviewed:

Abstract illustration: wavy cut-paper layers in navy with glowing amber edges. Creators
Illustration generated with AI on our own machine.
This article is also available in Spanish:ComfyUI ControlNet: generación guiada de imágenes

If you need an image to follow the exact structure of a reference photo, ControlNet is the tool. It extracts edges, poses, or depth to guide the generation process.

This tutorial shows you how to set it up in ComfyUI. It is simpler than it looks.

ComfyUI image generation workflow

What You’ll Build

A workflow that:

  1. Loads a reference image (e.g., a product photo, architectural sketch, or portrait)
  2. Extracts edge structure using Canny edge detection
  3. Generates a new image guided by those edges + your text prompt
  4. Runs 100% locally: no cloud, no API costs

Use cases: Product visualization, architectural rendering, brand-consistent content, style transfer.

Prerequisites

flowchart LR
    INPUT["Input Image"] --> CN["ControlNet<br/>Preprocessor"]
    CN --> COND["Conditioning"]
    PROMPT["Text Prompt"] --> COND
    COND --> SAMPLER["KSampler"]
    SAMPLER --> OUTPUT["Generated Image"]
    
    style INPUT fill:#1E293B,color:#FAFAFA
    style CN fill:#F5A623,color:#0B1628
    style OUTPUT fill:#059669,color:#FAFAFA
Diagram

The Workflow (11 Nodes)

text
Reference Image → Canny Edge Detection → ControlNet Apply
                                              ↓
Text Prompt → CLIP Encode ──────────────→ KSampler → VAE Decode → Save Image
                                              ↑
Checkpoint → Model + VAE ─────────────────────┘

Node-by-Node Setup

#NodeSettings
1CheckpointLoaderSimpleSelect your SDXL or SD 1.5 checkpoint
2ControlNetLoaderLoad control-lora-canny-rank256.safetensors
3LoadImageUpload your reference image
4CannyEdgePreprocessorlow_threshold: 100, high_threshold: 200, resolution: 1024
5CLIPTextEncode (positive)Your prompt: “professional product photo, studio lighting”
6CLIPTextEncode (negative)“blurry, low quality, watermark, text”
7ControlNetApplyAdvancedstrength: 0.8, start_percent: 0, end_percent: 1.0
8EmptyLatentImagewidth: 1024, height: 1024, batch_size: 1
9KSamplersteps: 25, cfg: 7.5, sampler: euler_ancestral, scheduler: normal
10VAEDecodeConnect to KSampler output
11SaveImagefilename_prefix: “controlnet_“

Key Parameters

ParameterWhat it doesRecommended
strength (ControlNet)How strictly to follow the edge guide0.7-0.9 for structure, 0.3-0.5 for loose guidance
low_threshold (Canny)Minimum edge sensitivity100 (default)
high_threshold (Canny)Maximum edge sensitivity200 (default)
cfg (KSampler)How closely to follow the text prompt7-8 for balanced, 10+ for strict

Tips for Best Results

  1. Start with strong ControlNet (0.8+) and reduce if results look rigid
  2. Use line art or architectural photos as references: clean edges work best
  3. Match resolution: if your reference is 1024x1024, set EmptyLatentImage to 1024x1024
  4. Experiment with ControlNet types: Canny (edges), Depth (3D), Pose (human), Scribble (sketches)
  5. SDXL models produce higher quality than SD 1.5 but need more VRAM (6+ GB)

Download the Workflow

Ready-to-import JSON file:

Download vorlux_controlnet_canny_guided.json →

Import in ComfyUI: Load Workflow → Upload File.

Hardware Requirements

HardwareVRAMSpeedQuality
Mac Mini M4 (24GB)24GB unified~30s/imageExcellent
RTX 4060 Ti (16GB)16GB~15s/imageExcellent
RTX 3090 (24GB)24GB~10s/imageExcellent
Mac M3 Pro (32GB)32GB unified~25s/imageExcellent

Common Issues and Fixes

Even experienced users run into problems with ControlNet. Here are the most frequent issues and their solutions:

ProblemCauseFix
Output ignores reference imageControlNet strength too low or node not connected properlyVerify the ControlNet Apply node is wired between the CLIP encode and KSampler. Set strength to 0.8+ as a starting point.
Output looks like a blurry copyStrength too high combined with low CFGReduce ControlNet strength to 0.6-0.7 and raise CFG to 8-10 to give the text prompt more influence.
Black or blank output imageMismatched model types (SD 1.5 ControlNet with SDXL checkpoint)Ensure your ControlNet model matches your base checkpoint version. SDXL checkpoints need SDXL-compatible ControlNet models.
”ControlNet model not found” errorModel file in wrong directoryPlace .safetensors ControlNet files in ComfyUI/models/controlnet/, not in the checkpoints folder.
Canny edges too noisy or too sparseThreshold values not tuned for your imageFor photos with lots of detail, raise low_threshold to 150. For sketches or simple outlines, lower high_threshold to 150. Preview the Canny output node to check before generating.
Very slow generation (60s+)Resolution mismatch or model loaded on CPUMatch EmptyLatentImage resolution to your reference image. Check ComfyUI console output to confirm the model loaded on GPU, not CPU.

Tip: Always preview the Canny edge detection output before running the full generation. If the edges do not clearly capture the structure you want to preserve, adjust thresholds first. Generating with bad edges wastes compute time and produces unusable results.


Next steps

  • Check your hardware requirements to ensure your VRAM can handle the generation.
  • Follow the node-by-node setup to configure your CheckpointLoaderSimple and ControlNetLoader.
  • Download the JSON workflow file to import the complete setup into ComfyUI.
  • Review the tips for best results to match your reference resolution with your EmptyLatentImage settings.

Sources:


Work with us

We size the model and the machine by measuring, not by guessing. If you want to see your own task running on real hardware, book a 15-minute call or see how we work in consulting.

Diagram
Share: LinkedIn X
Veredicto semanal

Get new guides before anyone else

Subscribe and we tell you when new guides, templates and workflows go up. One email a week, no spam.

Already published: 69 guides and 25 templates. All free, no signup.

Bonus: the local-AI starter pack PDF when you subscribe
Once a week No spam Unsubscribe anytime

See what you get

The EU AI Act now applies: a checklist you can complete

Tell us what you want to run

Tell us what you want to run and on what budget. We will tell you which hardware you need, which model fits, and what to expect from it, before you spend anything.

First call free, 15 min Local-first: your data stays on your network Open tools and guides

69 free guides · 17 compliance templates