工作流概述
工作流信息
- 工作流类型: 图生图
- 难度等级: 入门
- 预计执行时间: 10-30秒
- 推荐模型: Stable Diffusion 1.5
- ComfyUI版本要求: >= 1.0
功能特点
- 从图像生成新图像
- 修改图像风格
- 调整图像内容
- 保持图像结构
适用场景
- 风格转换
- 图像修改
- 艺术创作
- 图像增强
工作流结构
图生图工作流示意图
下图展示了图生图工作流的完整流程:
这个图展示了: - LoadImage: 加载输入图像 - VAEEncode: 将图像编码到潜在空间 - KSampler: 执行采样生成(denoise控制修改程度) - VAEDecode: 解码为图像 - SaveImage: 保存生成的图像
节点流程图
LoadImage
├── IMAGE ──┬── VAEEncode ─── KSampler ─── VAEDecode ─── SaveImage
└── MASK ───┘ │
└── samples ──┘
CheckpointLoaderSimple
├── MODEL ──────────────┐
├── CLIP ───┬────────────┼── KSampler
└── VAE ────┴────────────┘
CLIPTextEncode (positive) ─── positive ──┘
CLIPTextEncode (negative) ─── negative ──┘
核心节点说明
- 作用: 加载输入图像
- 关键参数: image(图像文件)
- 作用: 将图像编码到潜在空间
- 关键参数: pixels(图像)、vae(VAE模型)
- 作用: 执行采样生成
- 关键参数: denoise(去噪强度,通常0.5-0.8)
- CheckpointLoaderSimple: 加载模型
- CLIPTextEncode: 编码提示词
- VAEDecode: 解码潜在空间
- SaveImage: 保存图像
使用步骤
步骤1: 准备工作
- 准备输入图像
- 将图像放入
input/目录 - 确保模型已加载
步骤2: 加载工作流
- 打开ComfyUI
- 点击"Load"按钮
- 选择工作流JSON文件
步骤3: 配置参数
image: example.png
text: oil painting style, vibrant colors, artistic, detailed
text: blurry, low quality, ugly
seed: 123456789
steps: 20
cfg: 7.5
sampler_name: euler
scheduler: normal
denoise: 0.6 # 图生图通常0.5-0.8
步骤4: 执行工作流
- 点击"Queue Prompt"按钮
- 等待执行完成
- 查看生成的图像
工作流JSON
{
"3": {
"inputs": {
"seed": 123456789,
"steps": 20,
"cfg": 7.5,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 0.6,
"model": ["4", 0],
"positive": ["6", 0],
"negative": ["7", 0],
"latent_image": ["36", 0]
},
"class_type": "KSampler"
},
"4": {
"inputs": {
"ckpt_name": "v1-5-pruned-emaonly.ckpt"
},
"class_type": "CheckpointLoaderSimple"
},
"6": {
"inputs": {
"text": "oil painting style, vibrant colors, artistic, detailed",
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"text": "blurry, low quality, ugly",
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"8": {
"inputs": {
"samples": ["3", 0],
"vae": ["4", 2]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "img2img_",
"images": ["8", 0]
},
"class_type": "SaveImage"
},
"35": {
"inputs": {
"image": "example.png"
},
"class_type": "LoadImage"
},
"36": {
"inputs": {
"pixels": ["35", 0],
"vae": ["4", 2]
},
"class_type": "VAEEncode"
}
}
参数配置指南
关键参数说明
- 0.3-0.5: 轻微修改,保持原图
- 0.5-0.7: 中等修改,改变风格
- 0.7-0.8: 较大修改,改变内容
- 0.8-0.9: 大幅修改,接近重新生成
- 推荐: 15-25步
- 影响: 步数越多变化越大
- 权衡: 在变化和保持原图间平衡
- 推荐: 6-9
- 影响: 值越大越遵循提示词
- 注意: 值过高可能偏离原图
示例结果
示例1: 风格转换
- 输入: 照片
- 提示词: oil painting style, artistic
- denoise: 0.6
- 结果: 油画风格图像
示例2: 艺术增强
- 输入: 简单草图
- 提示词: detailed, vibrant colors, professional
- denoise: 0.7
- 结果: 详细的艺术作品
示例3: 轻微调整
- 输入: 高质量图像
- 提示词: enhance details, improve quality
- denoise: 0.3
- 结果: 质量提升的图像
提示词技巧
风格提示词
- 油画风格: oil painting, artistic, brush strokes
- 水彩风格: watercolor, soft, flowing
- 素描风格: sketch, pencil, charcoal
- 数字艺术: digital art, vibrant, modern
质量提示词
- 高质量: high quality, detailed, sharp
- 艺术性: artistic, creative, unique
- 专业: professional, masterpiece, best quality
负向提示词
- 避免低质量: blurry, low quality, ugly
- 避免失真: distorted, deformed, bad anatomy
- 避免不想要的风格: photo, realistic (如果不想要照片风格)
优化建议
性能优化
- 减少steps: 提高速度
- 降低分辨率: 使用较小输入图像
- 使用快速采样器: euler或lcm
质量优化
- 调整denoise: 找到合适的denoise值
- 改进提示词: 使用更精确的提示词
- 增加steps: 提高质量
效果控制
- denoise值: 控制修改程度
- 提示词强度: 调整cfg值
- 采样器选择: 不同采样器产生不同效果
常见问题
Q1: denoise值如何设置?
A: 轻微修改用0.3-0.5,风格转换用0.5-0.7,大幅修改用0.7-0.8。
Q2: 如何保持原图结构?
A: 使用较低的denoise值(0.3-0.5),减少steps。
Q3: 如何完全改变风格?
A: 使用较高的denoise值(0.7-0.8),强调风格提示词。
Q4: 图像失真怎么办?
A: 降低denoise值,减少cfg值,改进提示词。
Q5: 如何批量处理图像?
A: 增加batch_size,或使用批量处理工作流。
变体工作流
变体1: 轻微修改
- denoise: 0.3-0.4
- steps: 15
- cfg: 6-7
- 用途: 轻微调整图像
变体2: 风格转换
- denoise: 0.6-0.7
- steps: 20
- cfg: 7.5-8
- 用途: 转换图像风格
变体3: 大幅修改
- denoise: 0.8-0.9
- steps: 25
- cfg: 8-9
- 用途: 大幅改变图像
相关工作流
扩展阅读
更新日志
- 2026-01-26: 初始版本创建