comfyui-workflow-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseComfyUI 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 to determine:
state/inventory.json- 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:
| Pattern | When | Key Nodes |
|---|---|---|
| Text-to-Image | Simple generation | Checkpoint → CLIP → KSampler → VAE |
| Identity-Preserved Image | Character consistency | + InstantID/PuLID/IP-Adapter |
| LoRA Character | Trained character | + LoRA Loader |
| Image-to-Video (Wan) | High-quality video | Diffusion Model → Wan I2V → Video Combine |
| Image-to-Video (AnimateDiff) | Fast video, motion control | + AnimateDiff Loader + Motion LoRAs |
| Talking Head | Character speaks | Image → Video → Voice → Lip-Sync |
| Upscale | Enhance resolution | Image → UltimateSDUpscale → Save |
| Inpainting | Edit regions | Image + 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:
- Every exists in inventory's node list
class_type - Every model filename exists in inventory's model list
- All required connections are present (no dangling inputs)
- VRAM estimate doesn't exceed available VRAM
- Resolution is compatible with chosen model (512 for SD1.5, 1024 for SDXL/FLUX)
提交给用户前需完成以下校验:
- 所有均存在于资产清单的节点列表中
class_type - 所有模型文件名均存在于资产清单的模型列表中
- 所有所需连接均已配置(无悬空输入)
- 显存估算值不超过可用显存
- 分辨率与所选模型兼容(SD1.5为512,SDXL/FLUX为1024)
Step 6: Output
步骤6:输出
If online mode: Queue via skill
If offline mode: Save JSON to with descriptive name
comfyui-apiprojects/{project}/workflows/在线模式:通过 skill加入执行队列
离线模式:将JSON保存到路径下,使用描述性文件名
comfyui-apiprojects/{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 for complete node settings.
references/workflows.md在基础模板上扩展添加以下内容:
- 加载参考图像节点
- InstantID Model Loader + Apply InstantID
- IPAdapter Unified Loader + Apply IPAdapter
- FaceDetailer 后处理
完整节点设置请参考。
references/workflows.mdVideo 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 Workflow 4 for complete settings.
references/workflows.md使用不同的加载链路:
- 加载扩散模型(而非LoadCheckpoint)
- Wan I2V 条件处理
- EmptySD3LatentImage(支持帧数配置)
- 视频合并(VHS)
完整设置请参考的工作流4。
references/workflows.mdVRAM Estimation
显存估算
| Component | Approximate VRAM |
|---|---|
| FLUX FP16 | 16GB |
| FLUX FP8 | 8GB |
| SDXL | 6GB |
| SD1.5 | 4GB |
| InstantID | +4GB |
| IP-Adapter | +2GB |
| ControlNet (each) | +1.5GB |
| Wan 14B | 20GB |
| Wan 1.3B | 5GB |
| AnimateDiff | +3GB |
| FaceDetailer | +2GB |
| 组件 | 预估显存占用 |
|---|---|
| FLUX FP16 | 16GB |
| FLUX FP8 | 8GB |
| SDXL | 6GB |
| SD1.5 | 4GB |
| InstantID | +4GB |
| IP-Adapter | +2GB |
| ControlNet(单模型) | +1.5GB |
| Wan 14B | 20GB |
| Wan 1.3B | 5GB |
| AnimateDiff | +3GB |
| FaceDetailer | +2GB |
Common Mistakes to Avoid
需避免的常见错误
- Wrong output index: CheckpointLoader outputs at indices
[model, clip, vae][0, 1, 2] - CFG too high for InstantID: Use 4-5, not default 7-8
- Wrong resolution for model: FLUX/SDXL=1024, SD1.5=512
- Missing VAE: FLUX needs explicit VAE ()
ae.safetensors - Wrong model in wrong loader: Diffusion models need , not
LoadDiffusionModelLoadCheckpoint
- 输出索引错误:CheckpointLoader的输出对应索引为
[model, clip, vae][0, 1, 2] - InstantID的CFG值过高:建议使用4-5,而非默认的7-8
- 模型分辨率不匹配:FLUX/SDXL适配1024分辨率,SD1.5适配512分辨率
- 缺失VAE:FLUX需要显式指定VAE()
ae.safetensors - 模型与加载器不匹配:扩散模型需使用,而非
LoadDiffusionModelLoadCheckpoint
Reference Files
参考文件
- - Detailed node-by-node templates
references/workflows.md - - Model files and paths
references/models.md - - Model-specific prompts
references/prompt-templates.md - - Current inventory cache
state/inventory.json
- - 逐节点详细模板
references/workflows.md - - 模型文件与路径
references/models.md - - 模型专属提示词模板
references/prompt-templates.md - - 当前资产清单缓存
state/inventory.json