工作流概述
工作流信息
- 工作流类型: 文生图
- 难度等级: 入门
- 预计执行时间: 10-30秒
- 推荐模型: Stable Diffusion 1.5
- ComfyUI版本要求: >= 1.0
功能特点
- 从文本生成高质量图像
- 支持正向和负向提示词
- 可调节生成质量和速度
- 支持批量生成
适用场景
- 创意设计
- 概念艺术
- 插画创作
- 素材生成
工作流结构
文生图工作流示意图
下图展示了完整的文生图工作流流程:
这个图展示了文生图工作流的完整流程: - 模型加载: CheckpointLoaderSimple加载主模型 - 文本编码: CLIPTextEncode编码提示词 - 潜在空间: EmptyLatentImage创建初始噪声 - 采样生成: KSampler执行去噪生成 - 解码输出: VAEDecode解码为图像 - 保存结果: SaveImage保存最终图像
节点流程图
CheckpointLoaderSimple
├── MODEL ──────────────┐
├── CLIP ───┬────────────┼── KSampler ─── VAEDecode ─── SaveImage
└── VAE ────┴────────────┘ │
└── samples ──┘
CLIPTextEncode (positive) ─── positive ──┘
CLIPTextEncode (negative) ─── negative ──┘
EmptyLatentImage ─── latent_image ───────┘
核心节点说明
- 作用: 加载Stable Diffusion主模型
- 关键参数: ckpt_name(模型文件名)
- 作用: 编码正向提示词
- 关键参数: text(正向提示词)
- 作用: 编码负向提示词
- 关键参数: text(负向提示词)
- 作用: 创建空白潜在空间
- 关键参数: width, height, batch_size
- 作用: 执行采样生成
- 关键参数: seed, steps, cfg, sampler_name, scheduler, denoise
- 作用: 解码潜在空间为图像
- 关键参数: 无
- 作用: 保存生成的图像
- 关键参数: filename_prefix
使用步骤
步骤1: 准备工作
- 确保已安装ComfyUI
- 下载Stable Diffusion模型文件
- 将模型放入
models/checkpoints/目录
步骤2: 加载工作流
- 打开ComfyUI
- 点击"Load"按钮
- 选择工作流JSON文件
步骤3: 配置参数
ckpt_name: v1-5-pruned-emaonly.ckpt
text: beautiful landscape, mountains, sunset, 4k, detailed, cinematic lighting
text: ugly, blurry, low quality, distorted, bad anatomy
width: 512
height: 512
batch_size: 1
seed: 123456789 (或点击随机按钮)
steps: 20
cfg: 8
sampler_name: euler
scheduler: normal
denoise: 1.0
filename_prefix: txt2img_
步骤4: 执行工作流
- 点击"Queue Prompt"按钮
- 等待执行完成
- 查看生成的图像
工作流JSON
{
"3": {
"inputs": {
"seed": 123456789,
"steps": 20,
"cfg": 8,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1,
"model": ["4", 0],
"positive": ["6", 0],
"negative": ["7", 0],
"latent_image": ["5", 0]
},
"class_type": "KSampler"
},
"4": {
"inputs": {
"ckpt_name": "v1-5-pruned-emaonly.ckpt"
},
"class_type": "CheckpointLoaderSimple"
},
"5": {
"inputs": {
"width": 512,
"height": 512,
"batch_size": 1
},
"class_type": "EmptyLatentImage"
},
"6": {
"inputs": {
"text": "beautiful landscape, mountains, sunset, 4k, detailed, cinematic lighting",
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"text": "ugly, blurry, low quality, distorted, bad anatomy",
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"8": {
"inputs": {
"samples": ["3", 0],
"vae": ["4", 2]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "txt2img_",
"images": ["8", 0]
},
"class_type": "SaveImage"
}
}
参数配置指南
关键参数说明
- 推荐值: 20-30
- 影响: 步数越多质量越好但速度越慢
- 调整: 根据质量需求调整
- 推荐值: 7-12
- 影响: 值越大越遵循提示词
- 调整: 从7开始,逐步调整
- euler: 快速,质量好,推荐
- dpmpp_2m: 高质量,推荐
- euler_ancestral: 更随机,创意性更强
- normal: 标准调度
- karras: 更好的质量分布
- 512x512: 标准尺寸,速度快
- 768x768: 更高质量,速度较慢
- 1024x1024: 高清,速度慢
示例结果
示例1: 风景
- 提示词: beautiful landscape, mountains, sunset, 4k, detailed, cinematic lighting
- 负向提示词: ugly, blurry, low quality
- 参数: steps=20, cfg=8, sampler=euler
- 结果: 高质量风景图像
示例2: 肖像
- 提示词: portrait of a beautiful woman, detailed face, professional photography, 8k
- 负向提示词: ugly, distorted, bad anatomy, low quality
- 参数: steps=25, cfg=7.5, sampler=dpmpp_2m
- 结果: 高质量肖像图像
示例3: 动漫风格
- 提示词: anime style, beautiful girl, detailed, vibrant colors, studio ghibli style
- 负向提示词: realistic, photo, 3d render
- 参数: steps=20, cfg=9, sampler=euler_ancestral
- 结果: 动漫风格图像
提示词工程
正向提示词技巧
- 描述主体: 清晰描述主要对象
- 添加细节: 添加细节和修饰词
- 指定风格: 指定艺术风格
- 质量关键词: 添加高质量关键词
负向提示词技巧
- 避免低质量: 添加低质量关键词
- 避免不想要的内容: 明确避免的内容
- 避免特定风格: 如果不想要某种风格
提示词示例
正向: majestic mountain range, snow-capped peaks, golden hour light, dramatic clouds, ultra detailed, 8k, photorealistic
负向: blurry, low quality, ugly, distorted, oversaturated
正向: professional portrait, beautiful woman, detailed eyes, soft lighting, high quality, sharp focus, 8k
负向: ugly, distorted, bad anatomy, blurry, low resolution, cartoonish
正向: abstract art, vibrant colors, geometric shapes, dynamic composition, modern art style, high detail
负向: realistic, photo, boring, simple, low contrast
优化建议
性能优化
- 减少steps: 提高速度
- 使用快速采样器: euler或lcm
- 降低分辨率: 使用512x512
- 减少batch_size: 使用1
质量优化
- 增加steps: 提高质量
- 使用高质量采样器: dpmpp_2m
- 提高cfg: 更遵循提示词
- 使用karras调度器: 改善质量分布
批量生成
- 增加batch_size: 一次生成多张
- 使用不同seed: 生成不同图像
- 修改filename_prefix: 区分不同批次
常见问题
Q1: 生成的图像质量差怎么办?
A: 增加steps,调整cfg,改进提示词,使用更好的采样器。
Q2: 如何生成不同风格的图像?
A: 在提示词中添加风格关键词,如"anime style", "photorealistic"等。
Q3: 如何提高生成速度?
A: 减少steps,使用快速采样器,降低分辨率。
Q4: 如何批量生成图像?
A: 增加batch_size参数,或使用不同的seed多次执行。
Q5: 提示词如何写更好?
A: 清晰描述主体,添加细节,指定风格,使用质量关键词。
变体工作流
变体1: 高质量文生图
- 增加steps到30
- 使用dpmpp_2m采样器
- 使用karras调度器
- 提高分辨率到768x768
变体2: 快速文生图
- 减少steps到15
- 使用euler采样器
- 使用normal调度器
- 保持512x512分辨率
变体3: 批量文生图
- 增加batch_size到4
- 使用不同的seed
- 修改filename_prefix区分批次
相关工作流
扩展阅读
更新日志
- 2026-01-26: 初始版本创建