Stable Diffusion 提示词高阶用法实战指南
刚接触 Stable Diffusion 时,经常遇到输入详细描述但生成效果不佳的情况。提示词(prompt)的使用技巧是决定生成质量的关键因素。
新手常见问题分析
- 描述模糊导致效果不稳定:使用'一个漂亮的女孩'等泛化提示词,每次生成的差异很大
- 细节控制不足:无法精确控制服装、姿势、背景等具体元素
- 意外元素出现:画面中经常出现不想要的物体或畸变
- 风格不一致:难以保持统一的画风和质量
提示词策略深度解析
正向提示词 vs 负向提示词
正向提示词(Positive Prompt)告诉 AI 你想要什么,而负向提示词(Negative Prompt)则告诉 AI 你不想要什么。两者配合使用效果最佳。
负向提示词示例:
lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
正向提示词示例:
masterpiece, best quality, 1girl, long hair, blue eyes, school uniform, cherry blossoms background
权重调整技巧
通过使用 () 和 [] 可以调整提示词的重要性:
(word:1.3)- 将'word'的权重提高 30%[word]- 降低该词的权重- 多层嵌套
((word))相当于(word:1.21)
特殊符号的使用
- 交替提示词:使用
[A|B]让 AI 在 A 和 B 之间选择 - 分步渲染:使用
AND连接不同概念,让 AI 分阶段处理 - 风格融合:使用
:连接两个艺术家名字来混合风格
代码实战示例
下面是一个使用 diffusers 库调用 Stable Diffusion 的 Python 示例,展示了如何实现高级提示词控制:
from diffusers import StableDiffusionPipeline
import torch
# 加载模型
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16
).to("cuda")
# 高级提示词示例
prompt =
negative_prompt =
image = pipe(
prompt,
negative_prompt=negative_prompt,
height=,
width=,
num_inference_steps=,
guidance_scale=
).images[]
image.save()

