image-generation

image-generation

热门

当用户需要生成、创建、构想或呈现角色、场景、产品等任何视觉内容的图像时使用此 Skill。支持通过结构化 Prompt 和参考图进行引导生成。

7.8万Star
1.1万Fork
更新于 2026/8/1
SKILL.md
只读
名称
image-generation
描述

当用户需要生成、创建、构想或呈现角色、场景、产品等任何视觉内容的图像时使用此 Skill。支持通过结构化 Prompt 和参考图进行引导生成。

图像生成 Skill

概述

本 Skill 通过结构化 Prompt 和 Python 脚本生成高质量图像。工作流包含构建 JSON 格式的 Prompt,并执行图像生成(支持可选的参考图)。

核心功能

  • 构建用于 AIGC 图像生成的结构化 JSON Prompt
  • 支持多张参考图,用于画风与构图引导
  • 通过自动化 Python 脚本执行图像生成
  • 覆盖多样化的图像生成场景(角色设计、场景、产品展示等)

工作流

步骤 1:明确需求

当用户提出图像生成需求时,需确认:

  • 主体/内容:图像中需要展示什么
  • 风格偏好:艺术风格、氛围、配色方案
  • 技术规格:宽高比、构图、光影
  • 参考图:用于引导生成的参考图片
  • 无需检查 /mnt/user-data 目录下的文件夹

步骤 2:创建结构化 Prompt

/mnt/user-data/workspace/ 目录下生成结构化 JSON 文件,命名格式为:{descriptive-name}.json

步骤 3:执行生成

调用 Python 脚本:

python /mnt/skills/public/image-generation/scripts/generate.py \
  --prompt-file /mnt/user-data/workspace/prompt-file.json \
  --reference-images /path/to/ref1.jpg /path/to/ref2.png \
  --output-file /mnt/user-data/outputs/generated-image.jpg
  --aspect-ratio 16:9

参数说明:

  • --prompt-file:JSON Prompt 文件的绝对路径(必填)
  • --reference-images:参考图的绝对路径(可选,多个路径用空格分隔)
  • --output-file:输出图像文件的绝对路径(必填)
  • --aspect-ratio:生成图像的宽高比(可选,默认:16:9)

[!NOTE]
请勿读取 Python 脚本文件,直接传入参数调用即可。

角色生成示例

用户需求:“帮我生成一个 20 世纪 90 年代东京街头风格的女性角色”

创建 Prompt 文件:/mnt/user-data/workspace/asian-woman.json

{
  "characters": [{
    "gender": "female",
    "age": "mid-20s",
    "ethnicity": "Japanese",
    "body_type": "slender, elegant",
    "facial_features": "delicate features, expressive eyes, subtle makeup with emphasis on lips, long dark hair partially wet from rain",
    "clothing": "stylish trench coat, designer handbag, high heels, contemporary Tokyo street fashion",
    "accessories": "minimal jewelry, statement earrings, leather handbag",
    "era": "1990s"
  }],
  "negative_prompt": "blurry face, deformed, low quality, overly sharp digital look, oversaturated colors, artificial lighting, studio setting, posed, selfie angle",
  "style": "Leica M11 street photography aesthetic, film-like rendering, natural color palette with slight warmth, bokeh background blur, analog photography feel",
  "composition": "medium shot, rule of thirds, subject slightly off-center, environmental context of Tokyo street visible, shallow depth of field isolating subject",
  "lighting": "neon lights from signs and storefronts, wet pavement reflections, soft ambient city glow, natural street lighting, rim lighting from background neons",
  "color_palette": "muted naturalistic tones, warm skin tones, cool blue and magenta neon accents, desaturated compared to digital photography, film grain texture"
}

执行生成:

python /mnt/skills/public/image-generation/scripts/generate.py \
  --prompt-file /mnt/user-data/workspace/cyberpunk-hacker.json \
  --output-file /mnt/user-data/outputs/cyberpunk-hacker-01.jpg \
  --aspect-ratio 2:3

结合参考图:

{
  "characters": [{
    "gender": "based on [Image 1]",
    "age": "based on [Image 1]",
    "ethnicity": "human from [Image 1] adapted to Star Wars universe",
    "body_type": "based on [Image 1]",
    "facial_features": "matching [Image 1] with slight weathered look from space travel",
    "clothing": "Star Wars style outfit - worn leather jacket with utility vest, cargo pants with tactical pouches, scuffed boots, belt with holster",
    "accessories": "blaster pistol on hip, comlink device on wrist, goggles pushed up on forehead, satchel with supplies, personal vehicle based on [Image 2]",
    "era": "Star Wars universe, post-Empire era"
  }],
  "prompt": "Character inspired by [Image 1] standing next to a vehicle inspired by [Image 2] on a bustling alien planet street in Star Wars universe aesthetic. Character wearing worn leather jacket with utility vest, cargo pants with tactical pouches, scuffed boots, belt with blaster holster. The vehicle adapted to Star Wars aesthetic with weathered metal panels, repulsor engines, desert dust covering, parked on the street. Exotic alien marketplace street with multi-level architecture, weathered metal structures, hanging market stalls with colorful awnings, alien species walking by as background characters. Twin suns casting warm golden light, atmospheric dust particles in air, moisture vaporators visible in distance. Gritty lived-in Star Wars aesthetic, practical effects look, film grain texture, cinematic composition.",
  "negative_prompt": "clean futuristic look, sterile environment, overly CGI appearance, fantasy medieval elements, Earth architecture, modern city",
  "style": "Star Wars original trilogy aesthetic, lived-in universe, practical effects inspired, cinematic film look, slightly desaturated with warm tones",
  "composition": "medium wide shot, character in foreground with alien street extending into background, environmental storytelling, rule of thirds",
  "lighting": "warm golden hour lighting from twin suns, rim lighting on character, atmospheric haze, practical light sources from market stalls",
  "color_palette": "warm sandy tones, ochre and sienna, dusty blues, weathered metals, muted earth colors with pops of alien market colors",
  "technical": {
    "aspect_ratio": "9:16",
    "quality": "high",
    "detail_level": "highly detailed with film-like texture"
  }
}
python /mnt/skills/public/image-generation/scripts/generate.py \
  --prompt-file /mnt/user-data/workspace/star-wars-scene.json \
  --reference-images /mnt/user-data/uploads/character-ref.jpg /mnt/user-data/uploads/vehicle-ref.jpg \
  --output-file /mnt/user-data/outputs/star-wars-scene-01.jpg \
  --aspect-ratio 16:9

常见场景

不同场景推荐使用不同的 JSON Schema。

角色设计

  • 外貌特征(性别、年龄、族裔、体型)
  • 面部细节与表情
  • 服装与配饰
  • 历史时代或背景设定
  • 姿势与环境上下文

场景生成

  • 环境描述
  • 时间、天气
  • 氛围与情绪
  • 视觉焦点与构图

产品展示

  • 产品细节与材质
  • 打光方案
  • 背景与环境
  • 展示角度

特定模板

仅当用户需求匹配时,才读取对应的模板文件:

输出处理

生成完成后:

  • 图像通常保存在 /mnt/user-data/outputs/
  • 使用 present_files 工具向用户展示生成的图像
  • 对生成结果进行简要说明
  • 如需调整,主动询问是否需要进一步微调

小贴士:使用参考图提升生成效果

对于视觉精准度要求较高的场景,建议在生成前先使用 image_search 工具查找参考图

推荐使用 image_search 工具的场景:

  • 角色/人像生成:搜索相似的姿势、表情或风格,用以引导面部特征和人体比例
  • 具体物件或产品:查找真实物品的参考图,确保细节表达准确
  • 建筑或环境场景:搜索实景参考,捕捉地道的细节与氛围
  • 时尚与服饰:查找穿搭参考,确保服装细节与造型准确

示例工作流:

  1. 调用 image_search 工具获取合适的参考图:
    image_search(query="Japanese woman street photography 1990s", size="Large")
    
  2. 将返回的图片 URL 下载到本地文件
  3. 将下载的文件作为 --reference-images 参数传入生成脚本

这种方式能为模型提供具象的视觉引导,相比单纯依赖文本描述,可以显著提升图像生成质量。

服务提供商(Gemini / MiniMax)

本 Skill 会根据环境变量自动选择 Provider(无需修改命令行):

  • 设置了 GEMINI_API_KEY → 使用 Gemini(默认方式,保持不变)。
  • 仅设置了 MINIMAX_API_KEY → 使用 MiniMax(/v1/image_generation,模型为 image-01)。
  • 如需显式指定,可设置环境变量 IMAGE_GENERATION_PROVIDER=gemini|minimax

MiniMax 可选覆写配置:MINIMAX_API_HOST(默认 https://api.minimaxi.com)、MINIMAX_IMAGE_MODEL(默认 image-01)。参考图会作为 MiniMax 的 subject_reference 主体参考图传入。无论是哪个 Provider,CLI 命令及 --prompt-file / --reference-images / --output-file / --aspect-ratio 等参数均完全一致。

MiniMax Prompt 处理逻辑(内部实现): 提示词构建独立于 Provider——无论当前生效的是哪个 Provider,编写相同的结构化 JSON 即可。MiniMax image-01 接收单条文本字符串,因此 MiniMax 处理路径仅发送 JSON 中的 prompt 字段(其他字段如 style / composition / negative_prompt 适用于 Gemini 路径),并开启 prompt_optimizer 允许 MiniMax 在服务端进行扩写。MiniMax 限制 Prompt 字符数不超过 1500;若 prompt 字段超出长度,脚本会报错并停止调用 API。Gemini 路径则会接收完整的结构化 JSON。

注意事项

  • 无论用户使用何种语言,Prompt 一律统一使用英文编写
  • 使用 JSON 格式可确保 Prompt 结构明确、易于解析
  • 参考图能大幅提升生成的精确度与效果
  • 经过多轮迭代调整获得理想效果属于正常流程
  • 在进行角色生成时,需同时包含详细的 character 对象以及汇总好的 consolidated prompt 字段