Mengenal ComfyUI: Visual Node-Based Interface untuk Generasi AI

I Nyoman Donostia 1053 kata
Mengenal ComfyUI: Visual Node-Based Interface untuk Generasi AI

Apa Itu ComfyUI?

ComfyUI adalah interface visual berbasis node untuk menjalankan model Stable Diffusion dan generative AI lainnya. Alih-alih menulis kode Python, Anda "menyambung" node seperti patching di alat audio — load model → text prompt → generate latent → decode → save image.

Saya tertarik ComfyUI karena fleksibilitas: bisa render gambar, video pendek (AnimateDiff), dan bahkan upscale tanpa coding. Workflow bisa di-export sebagai JSON dan dibagikan ke komunitas.

Keunggulan ComfyUI vs WebUI Lainnya

Aspect ComfyUI AUTOMATIC1111 WebUI Other GUIs
Workflow flexibility Sangat tinggi (custom node graph) Sedang (toggle settings) Rendah
Visual pipeline ✅ Node-based ❌ Tab-based
Memory efficient ✅ Optimized untuk VRAM rendah Cukup Bergantung
Workflow reproducible ✅ JSON export
Custom node ekosistem 1000+ custom nodes Plugin terbatas Sedikit
Debugging Node inspectable Terbatas Tidak ada

1. Instalasi Lokal

Via Git (Windows/Linux/Mac)

git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
pip install -r requirements.txt

# Download model SD ke folder models/checkpoints/
# Contoh: SD 1.5, SDXL, atau SDXL Lightning

Via Portable Bundle (Windows)

  1. Download dari ComfyUI releases
  2. Extract ke folder, jalankan run_cpu.bat atau run_nvidia_gpu.bat
  3. Browser buka http://127.0.0.1:8188

Via Docker

# docker-compose.yml
services:
  comfyui:
    image: yanwkunle/comfyui:latest
    ports:
      - "8188:8188"
    volumes:
      - ./models:/app/ComfyUI/models
      - ./output:/app/ComfyUI/output
      - ./custom_nodes:/app/ComfyUI/custom_nodes
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: [gpu]

2. Anatomi Node ComfyUI

Setiap node memiliki input dan output slot — di-sambung dengan meng-drag dari output satu ke input lainnya.

[Load Checkpoint] → (MODEL, CLIP, VAE)
     ↓
[CLIP Text Encode (Positive)] → (CONDITIONING)
     +
[CLIP Text Encode (Negative)] → (CONDITIONING)
     +
[Empty Latent Image] → (LATENT)
     ↓
[KSampler] → (LATENT)
     ↓
[VAE Decode] → (IMAGE)
     ↓
[Save Image]

Node Inti yang Wajib Dipahami

  • Load Checkpoint: load model .safetensors (ter-load Model, CLIP, VAE)
  • CLIP Text Encode: konversi prompt text → conditioning tensor
  • Empty Latent Image: canvas kosong dengan dimensi tertentu
  • KSampler: inti sampler — jalankan denoising loop
  • VAE Decode: konversi latent space → RGB image
  • Save Image: write ke disk

3. Workflow Pertama: Text-to-Image Sederhana

Step-by-step

  1. Load Checkpoint node → pilih sd_xl_base_1.0.safetensors
  2. CLIP Text Encode (Positive) — isi prompt:
    masterpiece, best quality, cyberpunk cityscape at night, neon lights,
    cinematic lighting, ultra-detailed, 8k
    
  3. CLIP Text Encode (Negative) — isi:
    low quality, blurry, distorted, watermark, signature
    
  4. Empty Latent Image — width: 1024, height: 1024, batch_size: 1
  5. KSampler — konfigurasi:
    • seed: randomize
    • steps: 25
    • cfg: 7.5
    • sampler: dpmpp_2m
    • scheduler: karras
    • denoise: 1.0
  6. VAE Decode → hubungkan dari KSampler
  7. Save Image → hubungkan dari VAE

Klik Queue Prompt — gambar muncul setelah ~10-30 detik (tergantung GPU).

4. Advanced Workflow: SDXL Lightning (Fast Generation)

Untuk iterasi cepat, SDXL Lightning hanya 4-8 steps vs 25 default. Workflow sedikit different:

[Load Checkpoint (SDXL Lightning 4-step)] → MODEL
[ModelSamplingDiscrete] → gunakan cfg: 1.5
[KSampler]
  steps: 4
  cfg: 1.5
  sampler: euler
  scheduler: simple

Image di ~1-3 detik di RTX 4090. Trade-off: detail sedikit berkurang vs full 30-step.

5. Image-to-Image (img2img)

Untuk modifikasi gambar existing:

[Load Image] → (IMAGE)
     ↓
[VAE Encode] → (LATENT)  // encode ke latent space
     ↓
[KSampler] (denoise: 0.6)  // denoise = strength transform
     ↓
[VAE Decode] → (IMAGE)

Denoise 0.3 = ringan edit, 0.7 = transform total, 1.0 = sama dengan text-to-image.

6. Upscaling dengan Custom Nodes

Tambahkan ComfyUI Manager untuk install custom nodes dengan UI.

  1. Clone ke custom_nodes/:
    git clone https://github.com/ltdrdata/ComfyUI-Manager custom_nodes/ComfyUI-Manager
    
  2. Restart ComfyUI
  3. Klik Manager di menu → pilih custom node yang ingin install

Workflow Upscale 4x

[KSampler output] → [Latent Upscale (2x)] → [KSampler (denoise: 0.4)] → [VAE Decode] → [Save Image]

Atau pakai ControlNet Tile untuk upscaling lebih detail:

[Load ControlNet Tile Model] → [ControlNet Apply]
[Image] → [Upscale Image (4x)] → control_image → KSampler

7. Save & Load Workflow (JSON)

ComfyUI menyimpan graph sebagai JSON. Untuk share workflow:

  • Drag file JSON ke canvas ComfyUI, atau
  • Menu → Load → pilih file

Cari workflow gratis di comfyworkflows.com atau CivitAI.

Contoh: Saved Workflow Structure

{
  "3": {
    "inputs": { "ckpt_name": "sd_xl_base_1.0.safetensors" },
    "class_type": "CheckpointLoaderSimple"
  },
  "6": {
    "inputs": {
      "text": "cyberpunk cityscape",
      "clip": ["3", 1]
    },
    "class_type": "CLIPTextEncode"
  }
}

8. Memori Optimization untuk GPU Low-End

  • Tiled VAE Decode: pecah image jadi tile kecil → VRAM usage turun 80%
  • fp8 quantization: model pakai fp8 (8-bit) → VRAM separuh
  • CPU offload: layer yang tidak dipakai di-offload ke RAM
  • Sequential batch: generate 4 image 1-by-1, bukan 4 batch parallel

9. AnimateDiff untuk Video Pendek

Workflow AnimateDiff menghasilkan video 16-32 frame dari prompt text.

[Load Checkpoint (SD 1.5)]
[AnimateDiff Loader] → motion_module: mm_sd_v15_v2.ckpt
[CLIP Text Encode (animated prompt)]
[KSampler with AnimateDiff-Lora]
[Save Image Sequence] → output folder image_00001.png, image_00002.png...

Gabungkan jadi video via ffmpeg:

ffmpeg -framerate 8 -pattern_type glob -i 'image_*.png' -c:v libx264 output.mp4

10. API Automation

ComfyUI ada API HTTP untuk integrate ke aplikasi Anda.

import json
import urllib.request
import uuid

server_address = "127.0.0.1:8188"
client_id = str(uuid.uuid4())

with open('workflow.json', 'r') as f:
    workflow = json.load(f)

# Replace placeholders
workflow["6"]["inputs"]["text"] = "epic landscape, masterpiece"

prompt_data = {
    "prompt": workflow,
    "client_id": client_id,
}

data = json.dumps(prompt_data).encode('utf-8')
req = urllib.request.Request(f"http://{server_address}/prompt", data=data)
response = urllib.request.urlopen(req).read().decode('utf-8')
print(response)

Saya pakai ini untuk batch generate 1000 image otomatis untuk dataset training di proyek AI.

11. Troubleshooting Umum

CUDA out of memory

  • Kurangi batch_size ke 1
  • Kurangi resolusi (1024 → 768)
  • Aktifkan Tiled VAE
  • Pakai fp8 model

Model not found

  • Cek file ada di folder models/checkpoints/ (case-sensitive di Linux)
  • Restart ComfyUI setelah nambah model

Node not found

  • Custom node butuh dependency tambah
  • Manager → Install via Git URL
  • Restart ComfyUI

Kesimpulan

ComfyUI adalah tool terbuka untuk eksplorasi AI generation. Saya pakai untuk generasi asset game, ilustrasi konten, dan batch processing dataset. Dengan workflow custom, Anda mendapat kontrol yang tidak mungkin di WebUI biasa. Invest 1-2 hari belajar node dasar, sehingga otomatisasi generasi AI jadi skill praktis.

I Nyoman Donostia

I Nyoman Donostia

Fullstack Developer - Bali, Indonesia

Artikel Terkait