ComfyUI Tutorial: Node-Based Workflows for Stable Diffusion

# ComfyUI: Workflow Berbasis Node untuk Stable Diffusion ComfyUI adalah lingkungan grafis berbasis node untuk menjalankan Stable Diffusion dan model difusi terkait. Alih-alih menyembunyikan pipeline...

By Ruby Abdullah · · tutorial
ComfyUIStable DiffusionImage GenerationGenerative AIWorkflowPython

ComfyUI: Node-Based Workflows for Stable Diffusion

ComfyUI is a graphical, node-based environment for running Stable Diffusion and related diffusion models. Instead of hiding the generation pipeline behind a single "Generate" button, it exposes every step as a node you can wire together, inspect, and reuse. This tutorial explains how the graph works, how to build the common workflows, and how to drive ComfyUI programmatically through its HTTP API.

Table of Contents

  • What ComfyUI Is and Why a Graph Helps
  • Installation
  • The Default Text-to-Image Workflow
  • How Latents Flow Through the Graph
  • Image-to-Image and Inpainting
  • LoRA and ControlNet Nodes
  • Upscaling Workflows
  • ComfyUI Manager and Custom Nodes
  • Saving and Loading Workflows
  • Driving ComfyUI from the HTTP API
  • SDXL vs SD1.5 Notes
  • Best Practices and Tips
  • Conclusion and Key Takeaways
  • What ComfyUI Is and Why a Graph Helps

    A diffusion image generation pipeline is a sequence of distinct operations: load a model, encode text prompts, prepare an empty latent, run the sampling loop, decode the latent back to pixels, and save the result. Most tools wrap all of this into a form with sliders. ComfyUI instead represents each operation as a node, and you connect the outputs of one node to the inputs of the next.

    This design has practical advantages over a form-driven UI like Automatic1111:

    • Transparency. You can see exactly which model, which conditioning, and which sampler produced an image. There are no hidden defaults applied behind the scenes.
    • Reproducibility. The graph itself is the recipe. Sharing the workflow JSON shares the complete, runnable pipeline, not a screenshot of settings someone has to re-enter.
    • Complex pipelines. Multi-stage flows, such as a base pass followed by a refiner and then an upscale, are awkward to express with a single form. In a graph they are just more nodes wired in sequence.
    • Caching. ComfyUI caches the output of every node. If you change only the seed, it re-runs the sampler but reuses the already-loaded model and encoded prompts, so iteration is fast.

    Automatic1111 is friendly for quick single-image generation and has a large extension ecosystem. ComfyUI trades some of that immediacy for control and is the better fit when the pipeline matters as much as the output, or when you intend to automate it.

    Installation

    ComfyUI runs on Windows, Linux, and macOS. You need Python 3.10 or newer and, for reasonable speed, an NVIDIA GPU with at least 6 GB of VRAM for SD1.5 or 10 GB for SDXL. CPU-only operation works but is slow.

    Manual installation with git

    git clone https://github.com/comfyanonymous/ComfyUI.git
    

    cd ComfyUI

    Create an isolated environment

    python -m venv venv

    source venv/bin/activate # On Windows: venv\Scripts\activate

    Install PyTorch matching your CUDA version first

    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

    Then the remaining dependencies

    pip install -r requirements.txt

    Start the server:

    python main.py
    

    By default it serves the web interface at http://127.0.0.1:8188. Useful flags include --listen 0.0.0.0 to expose it on the network, --port 8000 to change the port, and --lowvram or --cpu for constrained hardware.

    Portable build (Windows)

    For Windows users who do not want to manage Python, the project ships a portable archive containing an embedded Python and all dependencies. Download it from the releases page, extract it, and launch with runnvidiagpu.bat or runcpu.bat. This is the lowest-friction way to get started.

    Placing models

    ComfyUI does not download checkpoints for you. Place your model files in the appropriate subdirectory under models/:

    Related Articles

    Stable Diffusion Tutorial: Generative AI for Image Generation

    Stable Diffusion: Tutorial Komprehensif Daftar Isi Pendahuluan Prasyarat Memahami Arsitektur Stable Diffusion 4....

    Reflex Tutorial: Building Full-Stack Web Apps in Pure Python

    Reflex: Membangun Aplikasi Web Full-Stack dengan Python Murni Reflex memungkinkan Anda membangun aplikasi web lengkap — ...

    ColBERT & RAGatouille Tutorial: Late-Interaction Retrieval for RAG

    ColBERT & RAGatouille: Retrieval Late-Interaction untuk RAG yang Lebih Baik Sebagian besar sistem RAG mengandalkan dense...

    SGLang Tutorial: Fast LLM Serving and Structured Generation

    SGLang: Serving LLM yang Cepat dan Model Pemrograman untuk Generasi Terstruktur SGLang adalah dua hal dalam satu paket: ...