見出し画像

YAMLプロンプトでAI画像はどう変わる?通常プロンプトと徹底比較

 YAMLプロンプトはAIに対して明確な指示や出力形式を指定することで、より精度の高い応答を得るための方法です。

 通常のプロンプトは特定の型に縛られず自由な形式あるのに対し、YAMLプロンプトはYAML(YAML Ain't Markup Language)という言語の構文規則に従って記述されます。

 要は明確なルールがあるのがYAMLプロンプトということだけ覚えてもらえればOKです(僕もちゃんと理解しているわけではないので)。それでは、さっそく具体例を記します。

YAMLプロンプトの具体例

task: "イラスト生成"
subject:
- "若い女性"
setting:
- "夏の晴れた日"
- "海辺のカフェ"
action:
- "本を読む"
style:
- "イラスト"
- "水彩画タッチ"
lighting:
- "やわらかい光"

 ここではわかりやすくするために日本語で記述していますが、実際に生成する際は英語の方がおすすめです。AIは日本語の理解力も上がってきているとは言え、やはり英語のデータの方が豊富なので英語の方が有利です。

 英語ができなくても今は翻訳サイトがありますし、ChatGPTやGeminiに作成してもらうこともできます。では、通常のプロンプトとYAMLプロンプトによる画像生成を比較してみます。使用したのはChatGPTとSoraです。

通常プロンプトとYAMLプロンプト比較

アニメ風少女(通常プロンプト)

anime-style illustration of a beautiful high school girl sitting by the classroom window after school, colorful anime, soft pastel colors, detailed shading, warm sunlight shining through the window, soft glow, calm and nostalgic after-school mood

YAMLプロンプト

positive_prompt: subject: | anime-style illustration of a beautiful high school girl scene: | sitting by the classroom window after school style: | colorful anime, soft pastel colors, detailed shading lighting: | warm sunlight shining through the window, soft glow atmosphere: | calm, nostalgic, quiet after-school mood negative_prompt: | deformed, low resolution, photorealistic, 3D render, messy background

 うーん? 個人の好みもあるでしょうが、どっちかというと通常のプロンプトの方が良いような……モノクロでやってみましょうか。

モノクロ風(通常プロンプト)

manga-style drawing of a beautiful high school girl sitting by the classroom window after school, black and white ink, clean line art, detailed screentone shading, dramatic contrast between sunlight and classroom shadows, nostalgic and slightly melancholic mood

YAMLプロンプト

positive_prompt: subject: | manga-style drawing of a beautiful high school girl scene: | sitting by the classroom window after school style: | black and white ink, clean line art, detailed screentone shading lighting: | dramatic contrast between sunlight and classroom shadows atmosphere: | nostalgic, reflective, slightly melancholic mood negative_prompt: | color, watercolor, digital painting, blurred lines, low resolution

 そんなに変わらない気がする。テーマが簡単すぎるとあまり差が出ないのかもしれません。難易度を少し上げてみます。

5人の半円配置(通常プロンプト)

anime-style illustration of 5 high school students sitting in a semicircle inside a classroom, each with different expressions and poses, wide shot, detailed shading, warm lighting, cinematic perspective

YAMLプロンプト

positive_prompt: subject: | anime-style illustration of 5 high school students arrangement: | sitting in a semicircle, evenly spaced, facing toward the center scene: | inside a classroom with desks and chalkboard style: | colorful, detailed anime shading, clean line art composition: | wide shot, balanced perspective to show all 5 characters lighting: | warm sunlight from the windows, soft glow atmosphere: | friendly, calm, after-school mood negative_prompt: | more than 5 people, scattered random positions, messy composition, blurry details, photorealistic

 キャラクターのポーズが少し違うくらいでほとんど差がありません。こうなったら最上級の難易度のテーマで行きましょう。AI泣かせの超難題です。

左利きの少女が午後3時15分を指すアナログ時計を背景に、教室でノートを左手で書いている

 AIが特に苦手としている「左利きの人物」と「指定したアナログ時計」の両方を描写させてみます。

通常プロンプト

anime-style illustration of a left-handed high school girl writing in a notebook with her left hand, sitting in a classroom, a large wall clock behind her showing 3:15, colorful and detailed, warm lighting, cheerful atmosphere

YAMLプロンプト

positive_prompt: subject: | anime-style illustration of a left-handed high school girl action: | writing in a notebook with her left hand scene: | classroom interior, a large wall clock in the background clock: | analog clock showing exactly 3:15 (hour hand slightly past 3, minute hand on 3) style: | colorful, detailed, soft pastel anime shading lighting: | warm afternoon sunlight through the window atmosphere: | cheerful, everyday school life negative_prompt: | right-handed writing, wrong clock time, deformed hands, photorealistic, 3D render

 やっぱり再現は難しかったようです。ただ、YAMLプロンプトは通常と比べてクオリティが少し上がった気がします。

注意点

 この記事で紹介したYAMLプロンプトには最後の方にネガティブプロンプトが入っています。最初のアニメ風少女のYAMLプロンプトだと、

negative_prompt: | deformed, low resolution, photorealistic, 3D render, messy background
日本語訳
ネガティブプロンプト:| 変形、低解像度、フォトリアリスティック、3Dレンダリング、乱雑な背景

 まずネガティブプロンプトはChatGPTやGemini、Copilotのような大規模言語モデル(LLM)では効果がありません。有効なのはStable DiffusionやMidJourneyのような画像生成に特化したAIです。ということは、SoraやWhisk、ImageFXではOKということです。

 ただ、LLMでも「avoid」「without」(「避ける」「なしで」)のようなキーワードを入れておくのはおすすめ。
 僕は性能を確かめるために5人の半円配置のときだけChatGPTを使いましたが、あとはすべてSoraです。

 YAMLプロンプトは劇的に質が上がるといった魔法のような効果はありませんが、試してみると良い事あるかも?

いいなと思ったら応援しよう!