Skip to content

SDXL 工作流教程

学习使用 SDXL 模型创建高质量图像。

SDXL 简介

SDXL (Stable Diffusion XL) 是 Stability AI 推出的最新模型系列,具有出色的图像质量和 prompt following 能力。

模型特点

特点说明
高分辨率原生 1024x1024
更好的构图改进的构图能力
风格多样支持多种艺术风格
文字渲染更好的文字生成

版本

模型说明
SDXL Base基础模型
SDXL Refiner精炼模型
SDXL Turbo快速生成
SDXL Lightning高速模型

安装 SDXL

下载模型

ComfyUI/models/checkpoints/
stable-diffusion-xl-base-1.0.safetensors

# 可选:精炼模型
stable-diffusion-xl-refiner-1.0.safetensors

下载 VAE

SDXL 使用专用 VAE:

ComfyUI/models/vae/
sdxl-vae-fp16-fix.safetensors

推荐配置

组件要求
显存8GB 最低,16GB 推荐
模型格式safetensors
VAEsdxl-vae

基础工作流

经典工作流

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ CheckpointL │ →  │ CLIPTextEn  │ →  │ KSampler   │
│ oaderSDXL   │    │ (positive)  │    │            │
└─────────────┘    └─────────────┘    └─────────────┘

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│ CLIPTextEn  │    │ VAEDecode   │ ←  │ EmptyLatent│
│ (negative) │    │             │    │ Image      │
└─────────────┘    └─────────────┘    └─────────────┘

节点说明

节点说明
CheckpointLoaderSDXL加载 SDXL 模型
CLIP Text Encode编码提示词(分 positive/negative)
EmptyLatentImage创建潜在空间
KSampler采样生成
VAEDecode解码输出

SDXL 提示词技巧

基本格式

SDXL 支持更长的提示词:

# 单段式
a beautiful landscape with mountains, sunset, golden hour lighting, cinematic, 8k

# 分段式(可选)
# 主体描述
masterpiece, best quality, a young woman with long flowing hair
# 服装
wearing a elegant white dress with floral patterns
# 背景
standing in a flower garden, butterflies around, magical atmosphere
# 画质
ultra detailed, 8k, professional photography

质量增强

标签效果
masterpiece, best quality提升整体质量
extremely detailed, intricate增加细节
8k, high resolution高分辨率
professional, studio lighting专业感

风格指定

# 摄影风格
analog photo, film grain, vintage aesthetic
shot on Leica M6, bokeh, shallow depth

# 艺术风格
oil painting, impressionist style, soft brushstrokes
art nouveau, decorative, elegant

# 插画风格
digital art, fantasy illustration, vibrant colors
concept art, detailed, epic

采样参数

推荐设置

参数推荐值说明
Steps30-50质量与速度平衡
CFG7-12遵循提示词程度
SamplerDPM++ 2M Karras推荐
Size1024x1024原生分辨率

不同质量档位

档位StepsCFG用途
快速预览207-8快速测试
标准质量308-10日常使用
高质量5010-12重要作品

使用 Refiner

两阶段生成

SDXL 可以使用 Refiner 提升质量:

┌─────────────┐    ┌─────────────┐
│ Base Model  │ →  │ 生成基础图像 │
│             │    │ (1024x1024) │
└─────────────┘    └──────┬──────┘

┌─────────────┐    ┌─────────────┐
│ Refiner     │ →  │ 精炼细节    │
│ Model       │    │             │
└─────────────┘    └─────────────┘

工作流配置

1. Base 模型生成
   - Steps: 20-25
   - Switch at: 0.8(80%进度切换)

2. Refiner 精炼
   - Steps: 10-20
   - 细化纹理和细节

Refiner 工作流

┌─────────────┐
│ Base Model  │
│ (KSampler1) │ → 基础图像
└──────┬──────┘

┌─────────────┐    ┌─────────────┐
│ Refiner     │ →  │ KSampler2   │ → 最终图像
│ Model       │    │ (精炼)      │
└─────────────┘    └─────────────┘

图像尺寸

原生分辨率

尺寸比例适用
1024x10241:1头像、方图
1152x8969:7风景
1216x8323:2照片
1344x7687:4宽屏

推荐比例

# 人像
1024x1024, 896x1152, 768x1024

# 风景
1024x1024, 1216x832, 832x1216

# 全身
768x1344, 576x1024

LoRA 使用

SDXL LoRA

SDXL 需要 SDXL 专用 LoRA:

ComfyUI/models/loras/
sdxl_style_name.safetensors

应用 LoRA

1. 使用 Load LoRA 节点
2. 连接模型
3. 设置强度 0.5-0.8
4. 可选:调整 CLIPS strength

LoRA 强度建议

类型模型强度CLIP 强度
风格0.6-0.80.5-1.0
角色0.7-1.00.5-0.8
服装0.5-0.70.5-1.0

ControlNet

SDXL ControlNet

SDXL 支持 ControlNet:

ControlNet用途
canny边缘控制
depth深度控制
openpose姿态控制

使用示例

1. 加载 SDXL 模型
2. 加载 ControlNet
3. 预处理参考图
4. 调整权重 0.5-0.8
5. 生成

常见问题

Q: 显存不足

A:

  • 使用 SDXL Lite 版本
  • 减小图像尺寸
  • 使用 fp16 模型

Q: 提示词不生效

A:

  • 使用更详细的描述
  • 增加 CFG 值
  • 检查提示词格式

Q: 如何提升质量

A:

  • 使用 Refiner
  • 增加 Steps
  • 添加质量标签
  • 使用高分辨率

下一步