Stable Diffusion 学习路线
Stable Diffusion是最流行的开源AI绘画模型,本文提供完整学习资料。
官方资源
1. 官方文档
2. WebUI 工具
- AUTOMATIC1111 WebUI - 最流行
- ComfyUI - 节点式工作流
- InvokeAI - 专业级
基础使用
Diffusers 库
# 安装
pip install diffusers transformers accelerate
# 文生图
from diffusers import StableDiffusionPipeline
import torch
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
image = pipe("a photo of a cat").images[0]
image.save("cat.png")
SDXL 使用
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16
)
image = pipe(
prompt="A majestic lion",
negative_prompt="blurry, low quality",
num_inference_steps=30,
guidance_scale=7.5
).images[0]
提示词工程
基础结构
[主体], [描述], [风格], [质量词]
示例:
a beautiful sunset over mountains,
golden hour lighting, dramatic clouds,
oil painting style, artstation trending,
highly detailed, 8k resolution
负面提示词
blurry, low quality, bad anatomy,
worst quality, low resolution,
watermark, signature, text
进阶技术
- LoRA - 低秩适应微调
- ControlNet - 精确控制生成
- Inpainting - 局部重绘
- Outpainting - 画面扩展
- Img2Img - 图生图
模型资源
- Civitai - 模型分享社区
- Hugging Face SD模型
暂无评论。成为第一个评论的人吧!