ERNIE-Image ComfyUI 完整工作流搭建:从零到生产级管线
手把手教你搭建 ERNIE-Image 的 ComfyUI 工作流,从环境配置到高级节点,一步到位。
一、环境准备
系统要求
| 组件 | 最低要求 | 推荐配置 |
|---|---|---|
| GPU | 12GB VRAM | 24GB VRAM (RTX 4090) |
| RAM | 32GB | 64GB |
| 存储 | 50GB 可用 | SSD 200GB+ |
| OS | Ubuntu 22.04 / Windows 11 | Linux 首选 |
安装 ComfyUI
# 克隆 ComfyUI
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
创建虚拟环境
python -m venv venv
source venv/bin/activate
安装依赖
pip install -r requirements.txt
安装 ERNIE-Image 相关插件
# ComfyUI 管理
pip install comfyui-manager
下载插件
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack.git custom_nodes/ComfyUI-Impact-Pack
git clone https://github.com/FizzleDorf/ComfyUI_fizz_nodes.git custom_nodes/ComfyUI_fizz_nodes
二、模型下载与配置
模型文件结构
ComfyUI/
├── models/
│ ├── checkpoints/
│ │ └── ERNIE-Image/
│ │ ├── ernie-image-8b.safetensors
│ │ └── ernie-image-turbo.safetensors
│ ├── vae/
│ │ └── sdxl-vae-fp16-fix.safetensors
│ ├── clip/
│ │ └── clip-vit-large-patch14/
│ └── ipadapter/
│ └── ip-adapter-ernie.bin
下载命令
# 下载 ERNIE-Image 8B
huggingface-cli download baidu/ERNIE-Image --local-dir ./models/checkpoints/ERNIE-Image
三、基础工作流搭建
节点连接
[CheckPointLoader] → ERNIE-Image 8B
↓
[CLIPTextEncode] → Prompt
↓
[EmptyLatentImage] → 1024x1024
↓
[KSampler] → 采样生成
↓
[VAEDecode] → 解码
↓
[SaveImage] → 输出
核心参数配置
| 节点 | 参数 | 推荐值 |
|---|---|---|
| KSampler | steps | 28 (Standard) / 8 (Turbo) |
| KSampler | cfg | 7.0 |
| KSampler | sampler | euler_ancestral |
| KSampler | scheduler | normal |
| EmptyLatentImage | width | 1024 |
| EmptyLatentImage | height | 1024 |
四、高级工作流:IP-Adapter + ControlNet
节点连接
[CheckPointLoader] → ERNIE-Image
↓
[CLIPVisionLoader] → CLIP-ViT-L-14
↓
[IPAdapterModelLoader] → IP-Adapter
↓
[IPAdapterApply] → Scale: 0.8
↓
[ControlNetLoader] → ControlNet 模型
↓
[ControlNetApply] → Depth Map
↓
[KSampler] → 生成
↓
[VAEDecode] → 输出
五、批量生成工作流
节点连接
[CSVLoader] → Prompt 列表
↓
[BatchPrompt] → 批量处理
↓
[KSampler] → 批量生成
↓
[VAEDecode] → 批量解码
↓
[SaveImage] → 批量保存
CSV 模板
prompt,negative_prompt,seed,width,height
"a cat on a table","","42",1024,1024
"a dog in a garden","","137",1024,1024
"a bird in a tree","","256",1024,1024
六、工作流导出与分享
导出 JSON
# ComfyUI API 导出工作流
import requests
workflow = {
"3": {"class_type": "KSampler", "inputs": {"steps": 28, "cfg": 7.0}},
# ... 其他节点
}
with open("workflow.json", "w") as f:
import json
json.dump(workflow, f, indent=2)
加载工作流
# 通过 API 加载
response = requests.post(
"http://localhost:8188/prompt",
json={"workflow": workflow}
)
七、常见问题
Q1:ComfyUI 启动失败
解决方案:检查 Python 版本(推荐 3.10-3.11)和 CUDA 驱动。
Q2:显存不足
解决方案:
- 降低分辨率
- 使用 GGUF 量化模型
- 启用
--lowvram启动参数
Q3:IP-Adapter 节点找不到
解决方案:安装 ComfyUI-Impact-Pack 插件。
八、总结
ComfyUI 工作流搭建核心步骤:
- 环境配置:Python + CUDA + ComfyUI
- 模型下载:ERNIE-Image 8B + VAE + CLIP
- 基础管线:Checkpoint → Prompt → KSampler → VAE → Save
- 高级功能:IP-Adapter + ControlNet + Batch
- 批量生产:CSV 驱动 + API 调用
从零搭建到生产级工作流,ERNIE-Image 完全适配 ComfyUI 生态。
本文工作流基于 ComfyUI + ERNIE-Image 8B。