This long-form Chinese tutorial introduces ComfyUI, the node-based visual workflow tool for Stable Diffusion image generation. Below is a structured English summary preserving the original's technical content.
Core Philosophy
ComfyUI makes AI image generation transparent and modular: instead of a black-box interface, every step (loading models, encoding prompts, sampling, decoding) is a draggable node connected into a visible data flow, letting you pinpoint exactly where problems occur.
Key points
1. Installation (three options)
- Desktop app: official one-click installer for Windows/macOS, auto-updates, built-in model manager
- Portable build (Windows): download from
https://github.com/comfyanonymous/ComfyUI/releases, unzip and run; models go underComfyUI/models/(checkpoints, loras, controlnet, vae, upscale_models) - Manual install:
git clonethe repo,pip install -r requirements.txt, install PyTorch for your hardware (CUDA / ROCm / Apple Silicon), launch withpython main.py; UI runs athttp://127.0.0.1:8188 - Nodes have inputs (left), parameters (middle), outputs (right)
- Color-coded data types: MODEL (purple), CLIP (yellow), VAE (rose), CONDITIONING (orange), LATENT (pink), IMAGE (blue), MASK (green)
- Latent space is a compressed representation AI works in; VAE decodes it back to pixels
- seed: same seed + parameters = same image
- steps: denoising iterations; 20–30 is typical
- cfg: prompt adherence; 7–8 is common, too high causes oversaturation
- sampler/scheduler: Euler, DPM++, UniPC, etc.
- Base resolution 512×512 for SD1.5, 1024×1024 for SDXL; larger sizes need more VRAM
- Img2img replaces Empty Latent with a real image; the denoise parameter controls change: 0.2–0.4 for style transfer, 0.5–0.7 for major changes, 0.8–1.0 for near-total repaint
- Inpainting uses Set Latent Noise Mask; right-click a loaded image → Open in MaskEditor to paint the region to regenerate
- Hi-Res Fix: generate at 512×512, upscale latent, re-sample with denoise ~0.5 for detail
- Area composition: Conditioning (Set Area) nodes assign prompts to specific regions
- Upscaling: latent upscale, AI models (ESRGAN, SwinIR via Load Upscale Model), or Ultimate SD Upscale for 4K/8K tiled output
- Character consistency: character LoRA + OpenPose + IP-Adapter
- Product rendering: Canny + Depth + inpainting
- Architecture: MLSD + style LoRAs
- Animation: AnimateDiff + OpenPose + IP-Adapter
- ComfyUI GitHub
- ComfyUI Examples
- Official docs
- Civitai, Hugging Face
2. Node fundamentals
3. Text-to-image workflow
Load Checkpoint → CLIP Text Encode (positive/negative prompts) → Empty Latent Image → KSampler → VAE Decode → Save ImageKey KSampler parameters:
4. Img2img and inpainting
5. ControlNet
Pipeline:Load Image → Preprocessor → Load ControlNet Model → Apply ControlNet → KSampler| Preprocessor | Use case | |---|---| | Canny | edge/structure preservation | | OpenPose | human pose control | | Depth | spatial layering | | MLSD | straight lines (architecture) | | Scribble | sketch-to-image | | Segmentation | region control |
Multiple ControlNets can be stacked (e.g., OpenPose + Depth + Canny).
6. LoRA
LoRA (Low-Rank Adaptation) files are small fine-tuning add-ons (tens of MB) applied between Checkpoint and CLIP encoding via the Load LoRA node. The strength_model parameter scales effect (1.0 = full; negative values invert). Multiple LoRAs can be chained; lower strength if characters degrade.7. Advanced techniques
8. Custom nodes and ComfyUI-Manager
Install Manager intocustom_nodes (https://github.com/ltdrdata/ComfyUI-Manager.git). Its key feature: Install Missing Custom Nodes automatically detects and installs nodes required by downloaded workflows. Recommended packs: Impact-Pack (face fixing), ControlNet-Aux, Custom-Scripts, Efficiency-Nodes, WAS Node Suite.9. Practical case studies
Quick troubleshooting
| Error | Fix |
|---|---|
| CUDA Out of Memory | smaller image, lower batch, --lowvram |
| Model not found | check folder placement |
| Node not found | install via Manager |
| Connection type mismatch | verify wire colors match |
| Invalid latent | latent dimensions must be multiples of 8 |
Useful shortcuts
Ctrl+Enter run, Ctrl+Z/Y undo/redo, Ctrl+M mute node, Ctrl+B bypass node, double-click to search nodes, Space+drag pan canvas.