comfyui-workflow-builder

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ComfyUI Workflow Builder

ComfyUI 工作流构建器

Translates natural language requests into executable ComfyUI workflow JSON. Always validates against inventory before generating.
将自然语言请求转换为可执行的ComfyUI工作流JSON,生成前始终会基于资产清单进行校验。

Workflow Generation Process

工作流生成流程

Step 1: Understand the Request

步骤1:理解请求

Parse the user's intent into:
  • Output type: Image, video, or audio
  • Source material: Text-only, reference image(s), existing video
  • Identity method: None, zero-shot (InstantID/PuLID), LoRA, Kontext
  • Quality level: Draft (fast iteration) vs production (maximum quality)
  • Special requirements: ControlNet, inpainting, upscaling, lip-sync
将用户意图解析为以下维度:
  • 输出类型:图像、视频或音频
  • 源素材:仅文本、参考图像、现有视频
  • 身份保留方法:无、零样本(InstantID/PuLID)、LoRA、Kontext
  • 质量等级:草稿(快速迭代)vs 生产级(最高质量)
  • 特殊需求:ControlNet、局部重绘、超分辨率、唇形同步

Step 2: Check Inventory

步骤2:检查资产清单

Read
state/inventory.json
to determine:
  • Available checkpoints → select best match for task
  • Available identity models → determine which methods are possible
  • Available ControlNet models → enable pose/depth control if available
  • Custom nodes installed → verify all required nodes exist
  • VRAM available → optimize settings accordingly
读取
state/inventory.json
确认以下信息:
  • 可用检查点模型 → 选择最匹配任务的选项
  • 可用身份模型 → 确定可使用的实现方法
  • 可用ControlNet模型 → 存在则启用姿态/深度控制能力
  • 已安装自定义节点 → 验证所有所需节点均存在
  • 可用显存 → 对应优化参数设置

Step 3: Select Pipeline Pattern

步骤3:选择流水线模式

Based on request + inventory, choose from:
PatternWhenKey Nodes
Text-to-ImageSimple generationCheckpoint → CLIP → KSampler → VAE
Identity-Preserved ImageCharacter consistency+ InstantID/PuLID/IP-Adapter
LoRA CharacterTrained character+ LoRA Loader
Image-to-Video (Wan)High-quality videoDiffusion Model → Wan I2V → Video Combine
Image-to-Video (AnimateDiff)Fast video, motion control+ AnimateDiff Loader + Motion LoRAs
Talking HeadCharacter speaksImage → Video → Voice → Lip-Sync
UpscaleEnhance resolutionImage → UltimateSDUpscale → Save
InpaintingEdit regionsImage + Mask → Inpaint Model → KSampler
基于请求内容和资产清单,从以下模式中选择:
模式适用场景核心节点
文生图简单生成场景Checkpoint → CLIP → KSampler → VAE
身份保留图像生成角色一致性要求场景+ InstantID/PuLID/IP-Adapter
LoRA角色生成训练过的自定义角色生成+ LoRA Loader
图生视频(Wan)高质量视频生成Diffusion Model → Wan I2V → Video Combine
图生视频(AnimateDiff)快速视频生成、运动控制场景+ AnimateDiff Loader + Motion LoRAs
数字人生成角色说话场景Image → Video → Voice → Lip-Sync
超分辨率提升分辨率场景Image → UltimateSDUpscale → Save
局部重绘编辑图像指定区域Image + Mask → Inpaint Model → KSampler

Step 4: Generate Workflow JSON

步骤4:生成工作流JSON

ComfyUI workflow format:
json
{
  "{node_id}": {
    "class_type": "{NodeClassName}",
    "inputs": {
      "{param_name}": "{value}",
      "{connected_param}": ["{source_node_id}", {output_index}]
    }
  }
}
Rules:
  • Node IDs are strings (typically "1", "2", "3"...)
  • Connected inputs use array format:
    ["source_node_id", output_index]
  • Output index is 0-based integer
  • Filenames must match exactly what's in inventory
  • Seed values: use random large integer or fixed for reproducibility
ComfyUI工作流格式:
json
{
  "{node_id}": {
    "class_type": "{NodeClassName}",
    "inputs": {
      "{param_name}": "{value}",
      "{connected_param}": ["{source_node_id}", {output_index}]
    }
  }
}
规则:
  • 节点ID为字符串(通常为 "1", "2", "3"...)
  • 连接型输入使用数组格式:
    ["source_node_id", output_index]
  • 输出索引为从0开始的整数
  • 文件名必须与资产清单中的内容完全匹配
  • 种子值:使用随机大整数或固定值保证可复现性

Step 5: Validate

步骤5:校验

Before presenting to user:
  1. Every
    class_type
    exists in inventory's node list
  2. Every model filename exists in inventory's model list
  3. All required connections are present (no dangling inputs)
  4. VRAM estimate doesn't exceed available VRAM
  5. Resolution is compatible with chosen model (512 for SD1.5, 1024 for SDXL/FLUX)
提交给用户前需完成以下校验:
  1. 所有
    class_type
    均存在于资产清单的节点列表中
  2. 所有模型文件名均存在于资产清单的模型列表中
  3. 所有所需连接均已配置(无悬空输入)
  4. 显存估算值不超过可用显存
  5. 分辨率与所选模型兼容(SD1.5为512,SDXL/FLUX为1024)

Step 6: Output

步骤6:输出

If online mode: Queue via
comfyui-api
skill If offline mode: Save JSON to
projects/{project}/workflows/
with descriptive name
在线模式:通过
comfyui-api
skill加入执行队列 离线模式:将JSON保存到
projects/{project}/workflows/
路径下,使用描述性文件名

Workflow Templates

工作流模板

Basic Text-to-Image (FLUX)

基础文生图(FLUX)

json
{
  "1": {
    "class_type": "LoadCheckpoint",
    "inputs": {"ckpt_name": "flux1-dev.safetensors"}
  },
  "2": {
    "class_type": "CLIPTextEncode",
    "inputs": {"text": "{positive_prompt}", "clip": ["1", 1]}
  },
  "3": {
    "class_type": "CLIPTextEncode",
    "inputs": {"text": "{negative_prompt}", "clip": ["1", 1]}
  },
  "4": {
    "class_type": "EmptyLatentImage",
    "inputs": {"width": 1024, "height": 1024, "batch_size": 1}
  },
  "5": {
    "class_type": "KSampler",
    "inputs": {
      "seed": 42,
      "steps": 25,
      "cfg": 3.5,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1.0,
      "model": ["1", 0],
      "positive": ["2", 0],
      "negative": ["3", 0],
      "latent_image": ["4", 0]
    }
  },
  "6": {
    "class_type": "VAEDecode",
    "inputs": {"samples": ["5", 0], "vae": ["1", 2]}
  },
  "7": {
    "class_type": "SaveImage",
    "inputs": {"filename_prefix": "output", "images": ["6", 0]}
  }
}
json
{
  "1": {
    "class_type": "LoadCheckpoint",
    "inputs": {"ckpt_name": "flux1-dev.safetensors"}
  },
  "2": {
    "class_type": "CLIPTextEncode",
    "inputs": {"text": "{positive_prompt}", "clip": ["1", 1]}
  },
  "3": {
    "class_type": "CLIPTextEncode",
    "inputs": {"text": "{negative_prompt}", "clip": ["1", 1]}
  },
  "4": {
    "class_type": "EmptyLatentImage",
    "inputs": {"width": 1024, "height": 1024, "batch_size": 1}
  },
  "5": {
    "class_type": "KSampler",
    "inputs": {
      "seed": 42,
      "steps": 25,
      "cfg": 3.5,
      "sampler_name": "euler",
      "scheduler": "normal",
      "denoise": 1.0,
      "model": ["1", 0],
      "positive": ["2", 0],
      "negative": ["3", 0],
      "latent_image": ["4", 0]
    }
  },
  "6": {
    "class_type": "VAEDecode",
    "inputs": {"samples": ["5", 0], "vae": ["1", 2]}
  },
  "7": {
    "class_type": "SaveImage",
    "inputs": {"filename_prefix": "output", "images": ["6", 0]}
  }
}

With Identity Preservation (InstantID + IP-Adapter)

带身份保留(InstantID + IP-Adapter)

Extends basic template by adding:
  • Load reference image node
  • InstantID Model Loader + Apply InstantID
  • IPAdapter Unified Loader + Apply IPAdapter
  • FaceDetailer post-processing
See
references/workflows.md
for complete node settings.
在基础模板上扩展添加以下内容:
  • 加载参考图像节点
  • InstantID Model Loader + Apply InstantID
  • IPAdapter Unified Loader + Apply IPAdapter
  • FaceDetailer 后处理
完整节点设置请参考
references/workflows.md

Video Generation (Wan I2V)

视频生成(Wan I2V)

Uses different loader chain:
  • Load Diffusion Model (not LoadCheckpoint)
  • Wan I2V Conditioning
  • EmptySD3LatentImage (with frame count)
  • Video Combine (VHS)
See
references/workflows.md
Workflow 4 for complete settings.
使用不同的加载链路:
  • 加载扩散模型(而非LoadCheckpoint)
  • Wan I2V 条件处理
  • EmptySD3LatentImage(支持帧数配置)
  • 视频合并(VHS)
完整设置请参考
references/workflows.md
的工作流4。

VRAM Estimation

显存估算

ComponentApproximate VRAM
FLUX FP1616GB
FLUX FP88GB
SDXL6GB
SD1.54GB
InstantID+4GB
IP-Adapter+2GB
ControlNet (each)+1.5GB
Wan 14B20GB
Wan 1.3B5GB
AnimateDiff+3GB
FaceDetailer+2GB
组件预估显存占用
FLUX FP1616GB
FLUX FP88GB
SDXL6GB
SD1.54GB
InstantID+4GB
IP-Adapter+2GB
ControlNet(单模型)+1.5GB
Wan 14B20GB
Wan 1.3B5GB
AnimateDiff+3GB
FaceDetailer+2GB

Common Mistakes to Avoid

需避免的常见错误

  1. Wrong output index: CheckpointLoader outputs
    [model, clip, vae]
    at indices
    [0, 1, 2]
  2. CFG too high for InstantID: Use 4-5, not default 7-8
  3. Wrong resolution for model: FLUX/SDXL=1024, SD1.5=512
  4. Missing VAE: FLUX needs explicit VAE (
    ae.safetensors
    )
  5. Wrong model in wrong loader: Diffusion models need
    LoadDiffusionModel
    , not
    LoadCheckpoint
  1. 输出索引错误:CheckpointLoader的输出
    [model, clip, vae]
    对应索引为
    [0, 1, 2]
  2. InstantID的CFG值过高:建议使用4-5,而非默认的7-8
  3. 模型分辨率不匹配:FLUX/SDXL适配1024分辨率,SD1.5适配512分辨率
  4. 缺失VAE:FLUX需要显式指定VAE(
    ae.safetensors
  5. 模型与加载器不匹配:扩散模型需使用
    LoadDiffusionModel
    ,而非
    LoadCheckpoint

Reference Files

参考文件

  • references/workflows.md
    - Detailed node-by-node templates
  • references/models.md
    - Model files and paths
  • references/prompt-templates.md
    - Model-specific prompts
  • state/inventory.json
    - Current inventory cache
  • references/workflows.md
    - 逐节点详细模板
  • references/models.md
    - 模型文件与路径
  • references/prompt-templates.md
    - 模型专属提示词模板
  • state/inventory.json
    - 当前资产清单缓存