mcpField
I
image-generation

image-generation

github.com/bytedanceクリエイティブ・メディア84.6k2.9k 回インストール1 日前に更新
リポジトリ

image-generation について

image-generationは、構造化プロンプトとPythonスクリプトで画像を生成するスキルです。キャラクター、シーン、製品のビジュアル制作に向けて、参照画像に対応し、環境変数に応じて生成プロバイダーを選択します。

主な機能

  1. 01構造化JSONプロンプトの作成
  2. 02複数の参照画像に対応
  3. 03Pythonスクリプトによる画像生成
  4. 04キャラクター・シーン・製品画像に対応
  5. 05環境変数によるプロバイダー選択

活用シーン

  1. 01説明文からキャラクターデザインを生成
  2. 02参照画像でシーン構図を指定
  3. 03製品ビジュアライゼーションを作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/bytedance/deer-flow --skill image-generation

インストール後、Claude Code で/image-generationを入力して読み込まれたか確認します。

同梱ファイルscripts/generate.pytemplates/doraemon.md

詳細

画像生成スキル

概要

このスキルでは、構造化プロンプトと Python スクリプトを使用して高品質な画像を生成します。このワークフローには、JSON 形式のプロンプトの作成と、任意の参照画像を使用した画像生成の実行が含まれます。

主な機能

  • AIGC 画像生成用の構造化 JSON プロンプトを作成
  • スタイルや構図の参考として複数の参照画像をサポート
  • Python スクリプトの自動実行による画像生成
  • さまざまな画像生成シナリオ(キャラクターデザイン、シーン、製品など)に対応

ワークフロー

ステップ 1:要件を把握する

ユーザーから画像生成を依頼されたら、次の項目を確認します。

  • 被写体/内容:画像に何を描くか
  • スタイルの希望:アートスタイル、雰囲気、カラーパレット
  • 技術仕様:アスペクト比、構図、ライティング
  • 参照画像:生成の参考にする画像があるか
  • /mnt/user-data 配下のフォルダーを確認する必要はありません
ステップ 2:構造化プロンプトを作成する

/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 プロンプトファイルの絶対パス(必須)
  • --reference-images:参照画像の絶対パス(任意、スペース区切り)
  • --output-file:出力画像ファイルの絶対パス(必須)
  • --aspect-ratio:生成画像のアスペクト比(任意、デフォルト:16:9)

[!NOTE] Python ファイルを読まず、パラメーターを指定して呼び出してください。

キャラクター生成の例

ユーザーの依頼:「1990年代の東京ストリートスタイルの女性キャラクターを作成してください」

プロンプトファイルを作成します:/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 スキーマを使用します。

キャラクターデザイン:

  • 身体的特徴(性別、年齢、民族、体型)
  • 顔の特徴と表情
  • 服装とアクセサリー
  • 時代や舞台設定
  • ポーズと背景

シーン生成:

  • 環境の説明
  • 時刻、天候
  • 雰囲気
  • 焦点と構図

製品のビジュアライゼーション:

  • 製品の詳細と素材
  • ライティングの設定
  • 背景とコンテキスト
  • 見せる角度

専用テンプレート

ユーザーの依頼に該当する場合に限り、次のテンプレートファイルを読みます。

出力の取り扱い

生成後:

  • 画像は通常、/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 / OpenAI-compatible)

このスキルは環境変数に基づいてプロバイダーを自動選択します(CLI の変更は不要です)。

  • GEMINI_API_KEY が設定されている場合 → Gemini を使用します(デフォルト、変更なし)。
  • それ以外で MINIMAX_API_KEY が設定されている場合 → MiniMax を使用します(/v1/image_generation、モデル image-01)。
  • それ以外で IMAGE_GENERATION_API_KEY が設定されている場合 → OpenAI 互換の画像 API を使用します。
  • IMAGE_GENERATION_PROVIDER=gemini|minimax|openai で明示的に指定できます。 openai-compatible も openai のエイリアスとして使用できます。

OpenAI 互換の設定:

  • IMAGE_GENERATION_API_KEY(必須)
  • IMAGE_GENERATION_BASE_URL(デフォルトは https://api.openai.com/v1)
  • IMAGE_GENERATION_MODEL(デフォルトは gpt-image-2.5-flare)
  • IMAGE_GENERATION_SIZE(任意の固定サイズ上書き)

テキストから画像を生成する呼び出しでは、POST {base_url}/images/generations を使用します。参照画像を使った呼び出しでは、マルチパート形式の POST {base_url}/images/edits を使用します。リレーは生成に対応していても、編集には対応していない場合があります。レスポンスには、Base64 画像データ、データ URL、またはダウンロード可能な URL が含まれることがあります。IMAGE_GENERATION_SIZE が設定されていない場合、アスペクト比は 1024x1024、1536x1024、または 1024x1536 に対応付けられます。出力ファイルの拡張子によって API の output_format が選択されます。.jpg/.jpeg は jpeg、.webp は webp、その他の拡張子は png を使用します。代わりに dall-e-2 または dall-e-3 が設定されている場合、リクエストではモデルがサポートするサイズと response_format=b64_json を使用します。DALL-E の出力ファイルには .png 拡張子を使用する必要があります。このスキルでは、DALL-E モデルによる参照画像の編集はサポートされていません。編集にはデフォルトの GPT Image モデルを使用してください。

MiniMax の任意の上書き設定:MINIMAX_API_HOST(デフォルトは https://api.minimaxi.com)、MINIMAX_IMAGE_MODEL(デフォルトは image-01)。参照画像は MiniMax の subject_reference キャラクター画像として送信されます。CLI と --prompt-file/--reference-images/--output-file/--aspect-ratio 引数は、どちらのプロバイダーでも同じです。

MiniMax のプロンプト処理(プロバイダー内部)。 作成時はプロバイダーに依存せず、どのプロバイダーが有効でも同じ構造化 JSON を記述します。MiniMax image-01 は単一のテキスト文字列を使用するため、MiniMax の処理経路では JSON の prompt フィールドのみを送信します(style/composition/negative_prompt などの他のフィールドは Gemini の処理経路に適用されます)。また、MiniMax がサーバー側でプロンプトを拡張するように prompt_optimizer を有効にします。MiniMax のプロンプトは 1500 文字までに制限されます。prompt フィールドがこれより長い場合、スクリプトは API を呼び出さずにエラーを返します。Gemini の処理経路には、構造化 JSON 全体が渡されます。

注意事項

  • ユーザーの言語にかかわらず、プロンプトには必ず英語を使用してください
  • JSON 形式により、構造化された解析可能なプロンプトを確保できます
  • 参照画像により、生成品質が大幅に向上します
  • 最適な結果を得るために、反復的な調整を行うのが一般的です
  • キャラクターを生成する場合は、詳細なキャラクターオブジェクトと、内容をまとめたプロンプトフィールドを含めてください

コメント