Qwen-Image-2.1 提示词书写完全指南

Qwen-Image-2.1 提示词书写完全指南

[[INKDRAFT]]
日期:2026年11月2日
来源:mickeylan
作者:mickeylan
mickeylan

字数 4788,阅读大约需 24 分钟

一、提示词基础原理

1.1 Qwen-Image-2.1 如何理解提示词

Qwen-Image-2.1 使用 Qwen3-VL 8B 作为文本编码器,这是一个强大的视觉-语言模型。与传统 CLIP 编码器相比,它能够:

• ✅ 理解复杂的自然语言描述

• ✅ 理解空间关系和位置描述

• ✅ 理解否定指令(不要包含什么)

• ✅ 理解风格和氛围的抽象描述

• ✅ 支持多语言输入(但输出推荐用英文)

1.2 提示词的核心要素

一个完整的提示词应该包含以下要素:

┌─────────────────────────────────────────────────────────────┐│                    完整提示词结构                             │├─────────────────┬───────────────────────────────────────────┤│   主体 (30%)    │  主体是什么/谁,动作,特征                   ││   场景 (20%)    │  在哪里,什么环境,背景                     ││   细节 (20%)    │  颜色,材质,纹理,姿态                     ││   光照 (10%)    │  光源方向,色温,氛围                       ││   风格 (10%)    │  艺术风格,摄影师/艺术家风格                 ││   质量 (10%)    │  画质修饰词,分辨率,细节级别                 │└─────────────────┴───────────────────────────────────────────┘

1.3 提示词长度与效果

长度

效果

适用场景

短(5-15 词)
创意空间大,结果多样

快速探索、灵感激发

中等(20-50 词)
平衡可控性与创意

日常创作、精准控制

长(50-100+ 词)
高度精确,但可能过约束

复杂场景、最终输出

💡 建议:先使用短提示词快速探索,找到满意方向后逐步添加细节。对于 Qwen-Image-2.1,中等长度提示词往往能获得最佳效果。

二、提示词结构模板

2.1 通用结构模板

[主体] + [场景/环境] + [动作/状态] + [细节特征] + [光照/氛围] + [风格] + [质量修饰词]

示例拆解:

A majestic golden eagle              → 主体perched on a pine branch            → 场景at sunrise, wings spread wide       → 动作golden feathers with iridescent      → 细节hints, fierce intelligent eyes       │soft morning light, misty forest    → 光照/氛围photorealistic nature photography   → 风格shot on Canon EOS R5, 8K resolution → 质量

2.2 分层结构模板

对于复杂场景,建议使用分层描述:

# 分层提示词示例prompt = """Subject: A female warrior in ornate silver armorAction: Standing on a cliff edge, looking toward distant mountainsSetting: Ancient ruins overgrown with moss, dramatic clouds aboveLighting: Golden hour light with lens flare, volumetric god raysStyle: Epic fantasy illustration, Greg Rutkowski meets MoebiusQuality: Masterpiece, ultra-detailed, cinematic composition, 8K"""

2.3 结构化提示词模板库

TEMPLATES = {    # === 人物肖像 ===    "portrait": (        "{expression} portrait of {subject}, "        "{pose}, "        "{setting}, "        "{lighting} lighting, "        "{camera} camera with {lens} lens, "        "{style}, "        "{quality}"    ),    # === 风景场景 ===    "landscape": (        "{scene_type} landscape of {location}, "        "featuring {main_elements}, "        "with {secondary_elements} in {foreground/midground/background}, "        "{time_of_day} lighting, "        "{weather} atmosphere, "        "{camera} shot, "        "{style}, "        "{quality}"    ),    # === 产品展示 ===    "product": (        "Professional product photography of {product}, "        "{presentation_style}, "        "{background}, "        "{lighting_setup} lighting, "        "sharp focus on {focus_point}, "        "{color_grading} color grading, "        "{style}, "        "{quality}"    ),    # === 艺术创作 ===    "artwork": (        "{medium} artwork of {subject}, "        "{art_style} style, "        "inspired by {artist_reference}, "        "{composition}, "        "{color_palette} color palette, "        "{mood} mood, "        "{quality}"    ),    # === 动漫/角色 ===    "anime": (        "{anime_style} anime art of {character}, "        "{pose} with {expression} expression, "        "in {outfit}, "        "{setting}, "        "{background}, "        "detailed {hair_style} hair, "        "{eye_detail} eyes, "        "high quality anime illustration"    ),}# 使用示例portrait_prompt = TEMPLATES["portrait"].format(    expression="confident and elegant",    subject="young Asian woman in her 30s",    pose="turned slightly to the side",    setting="urban rooftop garden with city skyline",    lighting="warm golden hour backlight",    camera="shot on Sony A7R IV",    lens="85mm f/1.4",    style="editorial fashion photography",    quality="professional, sharp, 8K resolution")

三、主体描述技巧

3.1 人物描述

# === 基础描述 ==="A person"  # 太模糊,可能生成随机人物"A tall woman with long black hair"  # 更好,但仍可改进# === 推荐格式 ==="A portrait of a 30-year-old East Asian woman, "  # 年龄+种族"long wavy black hair falling past shoulders, "    # 发型"freckles scattered across cheeks, "               # 面部特征"wearing a cream colored sweater, "                # 服装"looking directly at camera with a slight smile"   # 表情/姿态# === 更多示例 ===# 男性"A rugged 40-year-old man with salt-and-pepper beard, ""weathered skin, intense dark eyes, ""wearing a leather jacket, ""dramatic side lighting, cinematic portrait"# 儿童"A cheerful 8-year-old girl with pigtails, ""gap-toothed smile, rosy cheeks, ""wearing a yellow sundress, ""outdoor natural lighting, candid photo style"# 多人"Three friends laughing together at a cafe table, ""one woman with red hair, one man with glasses, ""one woman with braids, varied ethnicities, ""natural joyful expressions, warm indoor lighting"

3.2 物体描述

# === 汽车 ==="A sleek 2024 electric sports car, ""matte black exterior with electric blue accents, ""aerodynamic design, LED headlights, ""displayed in a modern showroom, ""dramatic studio lighting with reflections on floor"# === 食物 ==="A gourmet burger with juicy beef patty, ""melted cheddar cheese, fresh lettuce and tomato, ""special sauce dripping from the sides, ""on a rustic wooden board, ""studio food photography, appetizing, 4K"# === 建筑 ==="An ancient stone castle perched on a mountain cliff, ""medieval architecture with towers and turrets, ""worn stone texture, climbing ivy, ""dramatic clouds and lightning in the background, ""fantasy concept art style, epic composition"

3.3 避免模糊描述

# ❌ 模糊描述(可能导致不想要的结果)"A beautiful scene""A nice car""A happy person"# ✅ 具体描述(更可控的结果)"A serene mountain lake at golden hour with crystal clear water""A red 1969 Ford Mustang convertible on a coastal highway""A laughing elderly couple dancing together in a park"

四、场景与背景描述

4.1 场景类型词库

类别

关键词

自然
forest, beach, mountain, desert, ocean, prairie, jungle, canyon, cave

城市
city, street, alley, rooftop, subway, bridge, park, square

室内
studio, living room, bedroom, kitchen, cafe, library, museum, church

幻想
floating island, parallel world, dreamscape, ethereal realm, void

太空
nebula, asteroid field, alien planet, space station, cosmic void

4.2 背景层次描述

# === 前中后景分层 ===prompt = (    "A scenic mountain landscape, "                   # 主体场景    "in the foreground: a wooden pier extending into the water, "  # 前景    "in the midground: calm lake reflecting the mountains, "        # 中景    "in the background: snow-capped mountain peaks, "               # 背景    "dramatic storm clouds gathering, "                 # 氛围    "photorealistic landscape photography, 8K")# === 室内场景 ===prompt = (    "A cozy bookshop interior, "    "floor-to-ceiling wooden bookshelves filled with colorful books, "    "a leather armchair near a window with warm reading lamp light, "    "scattered loose pages and coffee cups on tables, "    "dusty sunbeams streaming through tall windows, "    "warm inviting atmosphere, cinematic composition")

4.3 光照与氛围

# === 光照类型 ===LIGHTING = {    "natural": [        "natural daylight", "golden hour", "blue hour",        "overcast soft light", "harsh midday sun", "dappled sunlight"    ],    "artificial": [        "studio lighting", "neon lights", "candlelight",        "fireplace glow", "street lamps", "fluorescent"    ],    "电影感": [        "cinematic lighting", "volumetric lighting", "god rays",        "lens flare", "rim lighting", "low key dramatic"    ],}# === 氛围类型 ===MOOD = {    "积极": "joyful, energetic, vibrant, peaceful, serene, hopeful",    "消极": "melancholic, somber, dramatic, tense, mysterious",    "浪漫": "romantic, dreamy, soft, intimate, ethereal",    "神秘": "mysterious, enigmatic, otherworldly, ethereal, mystical",    "复古": "vintage, nostalgic, retro, aged, timeless",}# 使用示例prompt = (    "A portrait of a woman at a rainy window, "    "warm candlelight on her face, "    "neon signs reflecting in rain puddles outside, "    "moody cinematic atmosphere, "    "blue and orange color contrast, "    "film noir inspired lighting")

五、风格控制

5.1 摄影风格

# === 摄影类型 ===PHOTO_TYPES = {    "portrait": "portrait photography, professional headshot, sharp focus on eyes",    "landscape": "landscape photography, wide angle, epic vista",    "street": "street photography, candid, documentary style",    "fashion": "fashion photography, editorial, magazine cover",    "product": "product photography, commercial, clean background",    "macro": "macro photography, extreme close-up, shallow depth of field",    "wildlife": "wildlife photography, natural habitat, National Geographic style",    "architecture": "architectural photography, straight lines, clean composition",}# === 相机/镜头模拟 ===CAMERA_STYLE = {    "人像": "shot on Canon EOS R5 with 85mm f/1.4 lens, shallow depth of field",    "广角": "shot on Sony 16-35mm f/2.8, wide angle perspective",    "长焦": "shot on 200mm telephoto lens, compressed perspective",    "电影": "shot on ARRI Alexa, anamorphic lens, cinematic letterbox",    "复古": "shot on Kodak Portra 400 film, grain, warm tones",}# === 示例 ===prompt = (    "A fashion model in couture gown on Parisian rooftop, "    "fashion photography, editorial style, "    "shot on Canon EOS R5 with 85mm f/1.4, "    "golden hour light, magazine cover quality")

5.2 绘画/艺术风格

# === 绘画风格 ===PAINTING_STYLES = {    "油画": "oil painting, impasto brushstrokes, rich textures, museum quality",    "水彩": "watercolor painting, soft edges, flowing pigments, paper texture visible",    "素描": "pencil sketch, detailed cross-hatching, graphite on cream paper",    "丙烯": "acrylic painting, bold colors, contemporary art style",    "浮世绘": "ukiyo-e Japanese woodblock print, flat colors, bold outlines",    "壁画": "mural painting, large scale, public art, vibrant colors",}# === 艺术家风格 ===ARTIST_STYLES = {    "古典": "in the style of Renaissance masters, Leonardo da Vinci influence",    "印象派": "impressionist style, Monet or Renoir, visible brushwork",    "毕加索": "Cubist style, Picasso influence, geometric abstraction",    "梵高": "Van Gogh style, swirling brushstrokes, expressive, starry night colors",    "浮世绘": "in the style of Hokusai, Japanese woodblock print aesthetic",    "当代": "contemporary illustration, clean lines, flat design, modern aesthetic",}# === 示例 ===prompt = (    "An oil painting of a Venetian canal scene, "    "impressionist style inspired by Monet, "    "visible brushstrokes capturing light on water, "    "warm afternoon sun, reflections shimmering, "    "rich impasto texture, museum quality artwork")

5.3 数字艺术风格

# === 数字风格 ===DIGITAL_STYLES = {    "概念艺术": "concept art, digital painting, highly detailed, ArtStation trending",    "赛博朋克": "cyberpunk aesthetic, neon lights, futuristic, Blade Runner vibes",    "蒸汽朋克": "steampunk style, Victorian era, brass and copper, gears and cogs",    "奇幻": "fantasy art, epic, Greg Rutkowski style, detailed environment",    "科幻": "sci-fi concept art, futuristic technology, hard surface design",    "像素": "pixel art, 16-bit style, retro game aesthetic, vibrant colors",    "等距": "isometric illustration, clean vector style, flat design",}# === 示例 ===prompt = (    "A cyberpunk street market scene, "    "neon signs in multiple languages, "    "flying vehicles in the sky, "    "rain-slicked streets reflecting colorful lights, "    "cyberpunk digital art style, "    "Blade Runner 2049 atmosphere, "    "highly detailed, ArtStation trending")

5.4 混合风格

# 多种风格的混合可以产生独特效果prompt = (    "A portrait in the style of combining "    "Japanese ukiyo-e woodblock print aesthetics with "    "modern neon cyberpunk lighting, "    "traditional kimono with futuristic accessories, "    "cultural fusion artwork, "    "unique artistic vision, masterpiece")

六、质量修饰词

6.1 分辨率/细节修饰词

QUALITY_MODIFIERS = {    # 分辨率    "高清": "high resolution, HD, 1920x1080",    "超清": "ultra high definition, 4K",    "极致": "8K resolution, extremely detailed, ultra-sharp",    # 细节    "精细": "highly detailed, intricate details, finely crafted",    "极简": "minimalist, clean lines, simple composition",    "复杂": "complex composition, many details, elaborate scene",    # 质感    "真实": "photorealistic, hyperrealistic, indistinguishable from photo",    "质感": "realistic textures, lifelike materials, tactile quality",}

6.2 构图修饰词

COMPOSITION = {    "角度": [        "bird's eye view (top-down)",        "worm's eye view (low angle looking up)",        "eye level, straight on",        "slightly above, looking down",        "dramatic low angle",        "over the shoulder"    ],    "取景": [        "close-up shot, face only",        "medium shot, waist up",        "full body shot",        "wide shot, environmental context",        "extreme close-up, macro detail"    ],    "比例": [        "centered composition, symmetrical",        "rule of thirds, off-center",        "golden ratio composition",        "diagonal composition, dynamic",        "frame within frame"    ],}

6.3 组合示例

# 完整的高质量提示词prompt = (    "An award-winning wildlife photograph of a lioness "    "resting with her cubs in the golden African savanna grass, "    "late afternoon golden hour light, dramatic rim lighting on fur, "    "shot from low angle, medium distance, "    "rule of thirds composition, "    "Canon EOS R5 with 600mm f/4 lens, "    "shallow depth of field, background softly blurred, "    "National Geographic quality, "    "hyperrealistic, 8K resolution, "    "magnificent and powerful atmosphere")

七、高级技巧

7.1 否定提示词(Negative Prompting)

当 guidance_scale > 1.0 时,可以使用负提示词来排除不需要的元素:

# 注意:需要设置 guidance_scale > 1.0 才能生效image = pipe(    prompt="A beautiful landscape with mountains and a lake",    negative_prompt="people, buildings, roads, power lines, blurry, low quality, "                    "distorted, deformed, ugly, bad anatomy, extra fingers",    guidance_scale=7.5,  # 需要 > 1.0    num_inference_steps=40,).images[0]

常用否定词类别:

NEGATIVE_PROMPTS = {    "质量": "blurry, low quality, distorted, ugly, deformed, bad anatomy",    "伪影": "artifacts, noise, compression artifacts, jpeg artifacts",    "人像": "extra fingers, missing limbs, mutated, mutated hands, bad hands",    "技术": "watermark, text, logo, signature, username, blurry",    "内容": "nsfw, nude, violent, gore, disturbing",}

7.2 提示词加权(Prompt Weighting)

通过调整不同部分的权重来强调或弱化某些元素:

# 方法 1:括号强调prompt = (    "A cozy cafe interior, "    "((warm golden lighting)), "              # 强调光照    "wooden furniture, "    "books on shelves, "    "((a cat sleeping on a chair))"           # 强调猫)# 方法 2:重复关键词prompt = (    "A forest, forest, forest, forest, "      # 强调森林感    "with ancient trees, "    "moss covered stones")# 方法 3:否定关键词prompt = (    "A clean modern kitchen, "    "(no people), "                           # 不要人    "no clutter, "                            # 不要杂乱    "minimal design")

7.3 渐进式描述

# 从简单到复杂,逐步添加细节STEPS = [    "A person",                                           # Step 1: 基础    "A woman standing",                                   # Step 2: 添加动作    "A woman standing in a garden",                       # Step 3: 添加场景    "A woman standing in a garden holding flowers",       # Step 4: 添加物体    "A woman standing in a garden holding flowers, "      # Step 5: 添加细节    "wearing a white dress, golden hour light, "    "smiling, wind in hair",]# 实际应用中,可以先生成简单的,逐步迭代

7.4 场景组合

# 组合多个场景元素prompt = (    "A surreal dreamscape combining elements of: "    "floating islands inspired by Studio Ghibli films, "    "bioluminescent forest from Avatar, "    "ancient Greek temple ruins, "    "with a dramatic sunset sky with multiple moons, "    "surrealist art style, Salvador Dali meets digital art, "    "masterpiece, incredibly detailed")

7.5 参考风格词

# 引用特定风格或作品STYLE_REFERENCES = {    "电影": [        "Blade Runner 2049 color grading",        "Wes Anderson pastel aesthetic",        "Christopher Nolan cinematic style",        "Studio Ghibli animation warmth"    ],    "游戏": [        "Elden Ring concept art style",        "Cyberpunk 2077 neon aesthetic",        "Genshin Impact art style",        "Elden Ring dark fantasy atmosphere"    ],    "照片": [        "Steven Meisel editorial style",        "Annie Leibovitz portrait lighting",        "Ansel Adams landscape mastery",        "Steve McCurry cultural photography"    ],}prompt = (    "A portrait combining the lighting of Rembrandt "    "with the color palette of Wes Anderson films, "    "cinematic composition, masterpiece")

八、按场景分类的提示词模板

8.1 电商/产品类

ECOMMERCE_TEMPLATES = {    "产品主图": (        "{product_name}, "        "professional product photography, "        "clean white background, "        "soft studio lighting from upper left, "        "sharp focus, "        "commercial quality, "        "high resolution, "        "no shadows except subtle product shadow"    ),    "产品场景图": (        "{product_name} in a lifestyle setting, "        "{scene_description}, "        "natural lighting, "        "aspirational lifestyle photography, "        "magazine quality, "        "professional color grading"    ),    "产品细节图": (        "extreme close-up of {product_name}, "        "showing texture and material details, "        "macro photography, "        "studio lighting to highlight surface, "        "sharp focus, "        "product detail shot"    ),}

8.2 社交媒体内容

SOCIAL_TEMPLATES = {    "Instagram帖子": (        "A visually striking {content_type}, "        "instagram-worthy composition, "        "{aesthetic} aesthetic, "        "high contrast, vibrant colors, "        "clean or artistic background, "        "shareable, engaging visual"    ),    "故事/Story": (        "A {mood} story cover image, "        "vertical format 9:16, "        "{style} style, "        "text-friendly composition with space for overlay, "        "eye-catching first frame"    ),    "YouTube缩略图": (        "A high-click YouTube thumbnail, "        "expressive face or dramatic moment, "        "bold contrast, "        "clear subject, "        "text-friendly layout, "        "16:9 aspect ratio, "        "attention-grabbing composition"    ),}

8.3 艺术创作类

ART_TEMPLATES = {    "插画": (        "Original illustration of {subject}, "        "{art_style} style, "        "detailed linework, "        "{color_scheme} color palette, "        "clean vector art or traditional media texture, "        "high quality artwork"    ),    "概念艺术": (        "Concept art of {subject}, "        "{environment} environment, "        "{lighting} lighting setup, "        "digital painting, "        "highly detailed, "        "ArtStation trending, "        "professional portfolio quality"    ),    "海报": (        "A movie poster style illustration of {subject}, "        "dramatic composition, "        "{mood} atmosphere, "        "bold typography-ready layout, "        "cinematic color grading, "        "high impact visual"    ),}

8.4 头像/肖像类

PORTRAIT_TEMPLATES = {    "专业头像": (        "Professional headshot of {description}, "        "clean solid background (blue/grey/white), "        "professional studio lighting, "        "looking at camera, "        "neutral expression, "        "sharp focus on face, "        "commercial photography quality"    ),    "艺术肖像": (        "Artistic portrait of {description}, "        "{lighting} lighting, "        "{mood} atmosphere, "        "{style} style, "        "expressive and characterful, "        "gallery-worthy"    ),    "头像/Avatar": (        "A profile picture avatar of {description}, "        "square format, "        "centered composition, "        "{style} style, "        "clean background or subtle gradient, "        "clear recognizable features, "        "optimized for small display"    ),}

九、提示词优化工作流

9.1 推荐工作流

┌──────────────────────────────────────────────────────────────┐│                    提示词优化工作流                           │├──────────────────────────────────────────────────────────────┤│                                                              ││  1️⃣ 简单尝试                                                 ││     └─→ 使用简短提示词快速生成,查看模型理解方向                ││                                                              ││           ↓ 方向满意?                                       ││           ┌────────┬────────┐                                ││          / 不满意  \  满意   \                               ││         /           \         \                              ││        ↓             ↓                                       ││                                                              ││  2️⃣ 迭代细化                                                 ││     └─→ 添加场景、细节、风格等元素                            ││                                                              ││           ↓ 细节足够?                                       ││           ┌────────┬────────┐                                ││          / 不足    \  足够   \                               ││         /           \         \                              ││        ↓             ↓                                       ││                                                              ││  3️⃣ 质量增强                                                 ││     └─→ 添加质量修饰词、光照、构图                            ││                                                              ││           ↓                                                  ││                                                              ││  4️⃣ 最终生成                                                 ││     └─→ 固定种子,多生成几张选择最佳                          ││                                                              │└──────────────────────────────────────────────────────────────┘

9.2 提示词测试脚本

#!/usr/bin/env python3"""提示词测试工具快速测试不同提示词变体的效果"""import torchfrom diffusers import QwenImage21Pipelinefrom PIL import Imagefrom pathlib import Pathdef test_prompts(prompts, output_dir="prompt_tests", base_seed=42):    """    测试多个提示词变体    Args:        prompts: [{"name": "...", "prompt": "..."}, ...]        output_dir: 输出目录        base_seed: 基础随机种子    """    output_dir = Path(output_dir)    output_dir.mkdir(exist_ok=True)    pipe = QwenImage21Pipeline.from_pretrained(        "Qwen/Qwen-Image-2.1",        torch_dtype=torch.bfloat16    ).to("cuda")    results = []    for i, item in enumerate(prompts):        print(f"\n[{i+1}/{len(prompts)}] Testing: {item['name']}")        print(f"Prompt: {item['prompt'][:80]}...")        # 生成图像        image = pipe(            prompt=item["prompt"],            width=1024,  # 使用较低分辨率快速测试            height=1024,            num_inference_steps=30,  # 减少步数快速测试            generator=torch.Generator("cuda").manual_seed(base_seed),        ).images[0]        # 保存        output_path = output_dir / f"{item['name']}.png"        image.save(output_path)        print(f"  ✓ Saved: {output_path}")        results.append({            "name": item["name"],            "path": str(output_path),            "prompt": item["prompt"]        })    return results# 使用示例if __name__ == "__main__":    # 测试不同的主体描述方式    prompts = [        {            "name": "simple",            "prompt": "A cat"        },        {            "name": "detailed",            "prompt": "A fluffy orange tabby cat with green eyes sitting on a windowsill"        },        {            "name": "with_style",            "prompt": "A fluffy orange tabby cat with green eyes, "                      "photorealistic, professional pet photography"        },        {            "name": "with_scene",            "prompt": "A fluffy orange tabby cat with green eyes, "                      "sitting on a sunny windowsill, "                      "morning light streaming through glass, "                      "cozy home atmosphere, lifestyle photography"        },        {            "name": "full_quality",            "prompt": "A fluffy orange tabby cat with green eyes, "                      "sitting on a sunny wooden windowsill, "                      "morning golden hour light, soft bokeh background, "                      "shot on Canon EOS R5 with 100mm macro lens, "                      "shallow depth of field, professional pet photography, "                      "National Geographic quality, 8K resolution"        },    ]    results = test_prompts(prompts, "cat_prompt_tests")    print("\n===== 测试结果 =====")    for r in results:        print(f"{r['name']}: {r['path']}")

9.3 提示词保存与复用

import jsonfrom pathlib import Pathfrom datetime import datetimeclass PromptLibrary:    """提示词库管理"""    def __init__(self, library_file="prompt_library.json"):        self.library_file = Path(library_file)        self.prompts = self._load()    def _load(self):        if self.library_file.exists():            with open(self.library_file) as f:                return json.load(f)        return {"categories": {}}    def _save(self):        with open(self.library_file, "w") as f:            json.dump(self.prompts, f, indent=2)    def add(self, category, name, prompt, tags=None):        """添加提示词到库"""        if category not in self.prompts["categories"]:            self.prompts["categories"][category] = []        self.prompts["categories"][category].append({            "name": name,            "prompt": prompt,            "tags": tags or [],            "created": datetime.now().isoformat()        })        self._save()        print(f"✓ Added to {category}: {name}")    def search(self, query):        """搜索提示词"""        results = []        for cat, items in self.prompts["categories"].items():            for item in items:                if query.lower() in item["prompt"].lower():                    results.append({**item, "category": cat})        return results    def get_random(self, category=None):        """随机获取提示词"""        import random        if category:            items = self.prompts["categories"].get(category, [])        else:            items = []            for cat_items in self.prompts["categories"].values():                items.extend(cat_items)        return random.choice(items) if items else None# 使用示例library = PromptLibrary("my_prompts.json")# 添加提示词library.add(    category="portraits",    name="Professional Headshot",    prompt="Professional headshot of a person, "           "clean grey background, "           "studio lighting, "           "looking at camera, "           "commercial photography",    tags=["headshot", "professional", "studio"])# 搜索results = library.search("portrait")for r in results:    print(f"[{r['category']}] {r['name']}: {r['prompt'][:50]}...")

十、常见问题与最佳实践

10.1 常见错误

错误

问题

解决方案

提示词过长

可能过约束,细节互相冲突

精简到核心要素

风格冲突

"写实又卡通"导致混乱

保持风格一致

缺少主体

场景描述太多,主体模糊

确保主体明确

忽略光照

生成质量不稳定

添加光照描述

中英混杂

可能影响理解

统一使用英文

10.2 最佳实践清单

CHECKLIST = {    "结构": [        "✅ 主体是否明确?",        "✅ 场景/背景是否清晰?",        "✅ 是否有足够的细节?",    ],    "风格": [        "✅ 风格是否统一(不要混搭冲突风格)?",        "✅ 是否指定了光照/氛围?",        "✅ 是否有参考艺术家/作品?",    ],    "质量": [        "✅ 是否有质量修饰词?",        "✅ 构图是否清晰?",        "✅ 提示词是否简洁但不模糊?",    ],    "优化": [        "✅ 建议使用 Prompt Rewriting 工具自动优化",        "✅ 先用低分辨率快速测试",        "✅ 多生成几张选择最佳结果",    ],}

10.3 不同场景的提示词长度建议

场景

推荐长度

示例

简单物体

10-20 词

"A red apple with a leaf"

人物肖像

30-50 词

含主体、表情、服装、光照、风格

复杂场景

50-100 词

含多元素、分层、光照、氛围、构图

艺术创作

30-70 词

风格明确、有参考、质量修饰

十一、提示词速查表

11.1 常用质量修饰词

# 分辨率8K, ultra high resolution, hyperrealistic, photorealistic, masterpiece# 细节intricate details, highly detailed, finely crafted, elaborate# 构图cinematic composition, rule of thirds, golden ratio, centered# 光照cinematic lighting, volumetric lighting, god rays, rim lighting, soft lighting# 氛围moody, dramatic, ethereal, peaceful, vibrant, serene# 相机/风格shot on [camera], [lens], [style] photography, ArtStation trending

11.2 常用连接词

# 关系with, wearing, holding, standing on, sitting in, surrounded by# 光照in [color] light, lit by, illuminated by, backlit by# 风格参考in the style of, inspired by, reminiscent of# 质量professional, commercial, high quality, award-winning, magazine cover

11.3 颜色词

# 基本色red, blue, green, yellow, orange, purple, pink, black, white, gold, silver# 色调warm tones, cool tones, pastel colors, vibrant colors, muted colorsmonochromatic, complementary colors, analogous colors# 材质色ivory, cream, burgundy, teal, coral, lavender, mint, navy, charcoal

🔗 原文链接:https://mp.weixin.qq.com/s/uzCMRedibVH0h4WQVi_GuQ