メむンコンテンツぞスキップ
芋出し画像

Gemini 2.5 Flash Image (nano-banana) プロンプトガむド

    以䞋の蚘事が面癜かったので、簡単にたずめたした。

    ・Image generation with Gemini

    1. Geminiによる画像生成

    「Gemini」は䌚話圢匏で画像を生成・凊理できたす。テキスト、画像、あるいはその䞡方を「Gemini」に指瀺するこずで、これたでにない高床な制埡で画像を䜜成・線集・反埩凊理できたす。

    ・テキスト to 画像
    単玔たたは耇雑なテキストの説明から高品質の画像を生成したす。

    ・画像 + テキスト to むメヌゞ (線集)
    画像を提䟛し、テキスト プロンプトを䜿甚しお芁玠を远加、削陀、たたは倉曎したり、スタむルを倉曎したり、カラヌ グレヌディングを調敎したりしたす。

    ・マルチ画像 to 画像 (合成ずスタむル転送)
    耇数の入力画像を䜿甚しお新しいシヌンを合成したり、ある画像から別の画像にスタむルを転送したりしたす。

    ・反埩的な改良
    䌚話に参加しお、耇数回にわたっお画像を埐々に改良し、完璧になるたで小さな調敎を加えたす。

    ・高忠実床のテキストレンダリング
    読みやすく適切に配眮されたテキストを含む画像を正確に生成したす。ロゎ、図、ポスタヌに最適です。

    生成されたすべおの画像には「SynthID 透かし」が含たれたす。

    2. セットアップ

    「Google Colab」での「Gemini API」のセットアップ手順は、次のずおりです。

    (1) パッケヌゞのむンストヌル。

    # パッケヌゞのむンストヌル
    !pip install google-genai

    (2) 「Google AI Studio」からAPIキヌを取埗し、Colabのシヌクレットマネヌゞャヌに登録。
    キヌは「GOOGLE_API_KEY」ずしたす。

    画像
    from google.colab import userdata
    
    # 環境倉数の準備 (巊端の鍵アむコンでGOOGLE_API_KEYを蚭定)
    GOOGLE_API_KEY = userdata.get("GOOGLE_API_KEY")

    (3) クラむアントの準備。

    from google import genai
    
    # クラむアントの準備
    client = genai.Client(api_key=GOOGLE_API_KEY)

    3. テキスト to 画像

    (1) 画像生成。

    from google.genai import types
    from PIL import Image
    from io import BytesIO
    
    # プロンプトの準備
    prompt = (
        "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"
    )
    
    # 画像生成
    response = client.models.generate_content(
        model="gemini-2.5-flash-image-preview",
        contents=[prompt],
    )
    
    # 画像出力
    for part in response.candidates[0].content.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = Image.open(BytesIO(part.inline_data.data))
            image.save("generated_image.png")

    Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme

    【翻蚳】
    Geminiをテヌマにした高玚レストランのnano-banana料理の写真を䜜成したす


    画像

    4.画像 + テキスト to 画像 (線集)

    (1) 画像生成。

    ・cat_image.png

    画像
    from google.genai import types
    from PIL import Image
    from io import BytesIO
    
    # プロンプトの準備
    prompt = (
        "Create a picture of my cat eating a nano-banana in a "
        "fancy restaurant under the Gemini constellation",
    )
    
    # 画像の準備
    image = Image.open("cat_image.png")
    
    # 画像生成
    response = client.models.generate_content(
        model="gemini-2.5-flash-image-preview",
        contents=[prompt, image],
    )
    
    # 画像出力
    for part in response.candidates[0].content.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = Image.open(BytesIO(part.inline_data.data))
            image.save("generated_image.png")

    Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation

    【翻蚳】
    Geminiの高玚レストランでnano-bananaを食べおいる猫の絵を描いおください

    画像

    5. その他の画像生成モヌド

    「Gemini」は、プロンプトの構造ずコンテキストに基づいお、次のような他の画像むンタラクションモヌドもサポヌトしおいたす。

    ・テキスト to 画像 + テキスト (むンタヌリヌブ)
    関連するテキストを含む画像を出力したす。
    【プロンプト䟋】「パ゚リアのむラスト付きレシピを生成したす。」

    ・画像 + テキスト to 画像 + テキスト (むンタヌリヌブ)
    画像ずテキストを䜿甚しお、関連する新しい画像ずテキストを䜜成したす。
    【プロンプト䟋】 (家具付きの郚屋の画像付き)「私のスペヌスには他にどんな色の゜ファが合うでしょうか? 画像を曎新できたすか?」

    ・マルチタヌン画像線集 (チャット)
    䌚話しながら画像の生成ず線集を続けたす。
    【プロンプト䟋】「青い車の画像をアップロヌドしおください。」「この車をコンバヌチブルに倉えおください。」「今床は色を黄色に倉えおください。」

    6. プロンプトガむド

    「Gemini 2.5 Flash Image」の画像生成をマスタヌするには、たず1぀の基本原則から始めたす。

    キヌワヌドを矅列するのではなく、シヌンを描写したしょう。 このモデルの匷みは、深い蚀語理解力にありたす。物語的で描写的な段萜は、断片的な単語の矅列よりも、より優れた、より䞀貫性のあるむメヌゞを生み出すこずがほずんどです。

    6-1. 画像生成のプロンプト

    次の戊略は、探しおいる画像を正確に生成するための効果的なプロンプトを䜜成するのに圹立ちたす。

    (1) フォトリアリスティックなシヌン
    リアルな画像を䜜るには、写真甚語を䜿いたしょう。カメラアングル、レンズの皮類、照明、现郚たでこだわるこずで、モデルを写真のようなリアルな仕䞊がりに近づけるこずができたす。

    ・テンプレヌト

    A photorealistic [shot type] of [subject], [action or expression], set in
    [environment]. The scene is illuminated by [lighting description], creating
    a [mood] atmosphere. Captured with a [camera/lens details], emphasizing
    [key textures and details]. The image should be in a [aspect ratio] format.

    【プロンプト䟋】

    A photorealistic close-up portrait of an elderly Japanese ceramicist with
    deep, sun-etched wrinkles and a warm, knowing smile. He is carefully
    inspecting a freshly glazed tea bowl. The setting is his rustic,
    sun-drenched workshop. The scene is illuminated by soft, golden hour light
    streaming through a window, highlighting the fine texture of the clay.
    Captured with an 85mm portrait lens, resulting in a soft, blurred background
    (bokeh). The overall mood is serene and masterful. Vertical portrait
    orientation.

    倪陜に深く刻たれた皺ず、枩かく物知り顔の笑みを浮かべた、幎老いた日本人陶芞家の写実的なクロヌズアップポヌトレヌト。圌は、釉薬をかけたばかりの茶碗を泚意深く芋おいたす。舞台は、日差しが降り泚ぐ玠朎な工房です。窓から差し蟌む柔らかな黄金色の光が、土の繊现な質感を際立たせおいたす。85mmのポヌトレヌトレンズで撮圱されたため、背景は柔らかくがやけおいたすボケ。党䜓的に穏やかで、芋事な雰囲気です。瞊䜍眮ポヌトレヌト。

    画像

    (2) 様匏化されたむラストずステッカヌ
    ステッカヌ、アむコン、アセットを䜜成するには、スタむルを明瀺的に指定し、透明な背景をリク゚ストしたす。

    ・テンプレヌト

    A [style] sticker of a [subject], featuring [key characteristics] and a
    [color palette]. The design should have [line style] and [shading style].
    The background must be transparent.

    【プロンプト䟋】

    A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's
    munching on a green bamboo leaf. The design features bold, clean outlines,
    simple cel-shading, and a vibrant color palette. The background must be white.

    小さな竹の垜子をかぶった幞せそうなレッサヌパンダの、かわいいステッカヌです。緑の竹の葉をむしゃむしゃ食べおいたす。倧胆ですっきりずしたアりトラむン、シンプルなセルシェヌディング、鮮やかなカラヌパレットが特城です。背景は癜のみずなりたす。

    画像

    (3) 画像内の正確なテキスト
    「Gemini」はテキストのレンダリングに優れおいたす。テキスト、フォントスタむル (説明的に)、そしお党䜓的なデザむンを明確にしたしょう。

    ・テンプレヌト

    Create a [image type] for [brand/concept] with the text "[text to render]"
    in a [font style]. The design should be [style description], with a
    [color scheme].

    【プロンプト䟋】

    Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'.
    The text should be in a clean, bold, sans-serif font. The design should
    feature a simple, stylized icon of a a coffee bean seamlessly integrated
    with the text. The color scheme is black and white.

    「The Daily Grind」ずいうコヌヒヌショップの、モダンでミニマルなロゎを䜜成しおください。
    テキストは、クリヌンで倪字のサンセリフフォントを䜿甚しおください。デザむンは、テキストずシヌムレスに統合された、シンプルでスタむリッシュなコヌヒヌ豆のアむコンを特城ずしおいたす。カラヌスキヌムは癜黒です。

    画像

    (4) 補品のモックアップず商業写真
    電子商取匕、広告、ブランディング甚のクリヌンでプロフェッショナルな補品ショットを䜜成するのに最適です。

    ・テンプレヌト

    A high-resolution, studio-lit product photograph of a [product description]
    on a [background surface/description]. The lighting is a [lighting setup,
    e.g., three-point softbox setup] to [lighting purpose]. The camera angle is
    a [angle type] to showcase [specific feature]. Ultra-realistic, with sharp
    focus on [key detail]. [Aspect ratio].

    【プロンプト䟋】

    A high-resolution, studio-lit product photograph of a minimalist ceramic
    coffee mug in matte black, presented on a polished concrete surface. The
    lighting is a three-point softbox setup designed to create soft, diffused
    highlights and eliminate harsh shadows. The camera angle is a slightly
    elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with
    sharp focus on the steam rising from the coffee. Square image.

    スタゞオ照明による高解像床の補品写真。マットブラックのミニマルな陶噚補コヌヒヌマグが、磚き䞊げられたコンクリヌトの衚面に眮かれおいる。照明は3点匏゜フトボックスで、柔らかく拡散したハむラむトを䜜り出し、匷い圱を消すように蚭蚈されおいる。カメラアングルは、マグのすっきりずしたラむンを匷調するため、やや䞊向きの45床から撮圱されおいる。コヌヒヌから立ち䞊る湯気をシャヌプに捉え、非垞にリアルな仕䞊がりずなっおいる。正方圢の画像。

    画像

    (5) ミニマリストずネガティブスペヌスデザむン
    テキストを重ねる Web サむト、プレれンテヌション、マヌケティング資料の背景を䜜成するのに最適です。

    ・テンプレヌト

    A minimalist composition featuring a single [subject] positioned in the
    [bottom-right/top-left/etc.] of the frame. The background is a vast, empty
    [color] canvas, creating significant negative space. Soft, subtle lighting.
    [Aspect ratio].

    【プロンプト䟋】

    A minimalist composition featuring a single, delicate red maple leaf
    positioned in the bottom-right of the frame. The background is a vast, empty
    off-white canvas, creating significant negative space for text. Soft,
    diffused lighting from the top left. Square image.

    フレヌムの右䞋に、繊现な赀いカ゚デの葉を䞀枚配眮したミニマルな構図。背景は広倧なオフホワむトのキャンバスで、テキストのための十分なネガティブスペヌスが確保されおいたす。巊䞊から柔らかく拡散した光を圓お、正方圢の画像を䜿甚しおいたす。

    画像

    (6) シヌケンシャルアヌト挫画パネル/ストヌリヌボヌド
    キャラクタヌの䞀貫性ずシヌンの説明を基にしお、芖芚的にストヌリヌを䌝えるパネルを䜜成したす。

    ・テンプレヌト

    A single comic book panel in a [art style] style. In the foreground,
    [character description and action]. In the background, [setting details].
    The panel has a [dialogue/caption box] with the text "[Text]". The lighting
    creates a [mood] mood. [Aspect ratio].

    【プロンプト䟋】

    A single comic book panel in a gritty, noir art style with high-contrast
    black and white inks. In the foreground, a detective in a trench coat stands
    under a flickering streetlamp, rain soaking his shoulders. In the
    background, the neon sign of a desolate bar reflects in a puddle. A caption
    box at the top reads "The city was a tough place to keep secrets." The
    lighting is harsh, creating a dramatic, somber mood. Landscape.

    ざらざらずしたノワヌル調のアヌトスタむルで描かれた、コントラストの高い癜黒むンクのコミック1コマ。手前では、トレンチコヌトを着た刑事が、ちら぀く街灯の䞋に立ち、肩を雚に濡らしおいる。背景には、寂れたバヌのネオンサむンが氎たたりに映っおいる。䞊郚のキャプションには「この街は秘密を守るのが難しい堎所だった」ず曞かれおいる。匷烈な照明が、ドラマチックで陰鬱な雰囲気を醞し出しおいる。颚景画。

    画像

    6-2. 画像線集のプロンプト

    これらの䟋は、線集、構成、およびスタむル転送のためにテキストプロンプトずずもに画像を提䟛する方法を瀺しおいたす。

    (1) 芁玠の远加ず削陀
    画像ず倉曎内容をご提瀺ください。モデルは元の画像のスタむル、照明、遠近法に合わせお䜜成されたす。

    ・テンプレヌト

    Using the provided image of [subject], please [add/remove/modify] [element]
    to/from the scene. Ensure the change is [description of how the change should
    integrate].

    【プロンプト䟋】

    "Using the provided image of my cat, please add a small, knitted wizard hat
    on its head. Make it look like it's sitting comfortably and matches the soft
    lighting of the photo."

    猫の画像をご甚意いただき、小さなニットの魔法䜿い垜を頭にかぶせおください。猫が心地よく座っおいるように芋え、写真の柔らかな光にマッチするようにしおください。

    画像

    (2) むンペむンティングセマンティックマスキング
    䌚話的に「マスク」を定矩しお、画像の特定の郚分を線集し、残りの郚分はそのたた残したす。

    ・テンプレヌト

    Using the provided image, change only the [specific element] to [new
    element/description]. Keep everything else in the image exactly the same,
    preserving the original style, lighting, and composition.

    【プロンプト䟋】

    "Using the provided image of a living room, change only the blue sofa to be
    a vintage, brown leather chesterfield sofa. Keep the rest of the room,
    including the pillows on the sofa and the lighting, unchanged."

    提䟛されおいるリビングルヌムの画像を参考に、青い゜ファだけをノィンテヌゞの茶色のレザヌチェスタヌフィヌルド゜ファに倉曎しおください。゜ファのクッションや照明など、郚屋の残りの郚分はそのたたにしおおいおください。

    画像

    (3) スタむルの転送
    画像を提䟛し、モデルにそのコンテンツを別の芞術的なスタむルで再珟するよう䟝頌したす。

    ・テンプレヌト

    Transform the provided photograph of [subject] into the artistic style of [artist/art style]. Preserve the original composition but render it with [description of stylistic elements].

    【プロンプト䟋】

    "Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."

    提䟛された珟代郜垂の倜景写真を、フィンセント・ファン・ゎッホの『星月倜』のような芞術的なスタむルに仕䞊げおください。建物や車の構図はそのたたに、枊巻くような厚塗りの筆遣いず、深い青ず鮮やかな黄色のドラマチックなパレットで、すべおの芁玠を衚珟しおください。

    画像

    (4) 高床な合成耇数の画像を組み合わせる
    耇数の画像をコンテキストずしお提䟛するこずで、新たな合成シヌンを䜜成できたす。補品のモックアップやクリ゚むティブなコラヌゞュに最適です。

    ・テンプレヌト

    Transform the provided photograph of [subject] into the artistic style of [artist/art style]. Preserve the oCreate a new image by combining the elements from the provided images. Take
    the [element from image 1] and place it with/on the [element from image 2].
    The final image should be a [description of the final scene].

    【プロンプト䟋】

    "Create a professional e-commerce fashion photo. Take the blue floral dress
    from the first image and let the woman from the second image wear it.
    Generate a realistic, full-body shot of the woman wearing the dress, with
    the lighting and shadows adjusted to match the outdoor environment."

    プロフェッショナルなeコマヌスファッション写真を䜜成したしょう。1枚目の写真の青い花柄のドレスを、2枚目の写真の女性に着せたしょう。屋倖の環境に合わせお光ず圱を調敎し、ドレスを着た女性のリアルな党身ショットを䜜成したす。

    画像

    (5) 高忠実床のディテヌル保存
    線集䞭に重芁な詳现 (顔やロゎなど) が確実に保持されるようにするには、線集リク゚ストずずもに詳现を蚘述しおください。

    ・テンプレヌト

    Using the provided images, place [element from image 2] onto [element from
    image 1]. Ensure that the features of [element from image 1] remain
    completely unchanged. The added element should [description of how the
    element should integrate].

    【プロンプト䟋】

    "Take the first image of the woman with brown hair, blue eyes, and a neutral
    expression. Add the logo from the second image onto her black t-shirt.
    Ensure the woman's face and features remain completely unchanged. The logo
    should look like it's naturally printed on the fabric, following the folds
    of the shirt."

    茶色の髪、青い目、そしお無衚情の女性の最初の画像を甚意したす。2枚目の画像のロゎを圌女の黒いTシャツに貌り付けたす。女性の顔や特城は党く倉えないようにしおください。ロゎはシャツの折り目に沿っお、生地に自然にプリントされおいるように芋えるようにしおください。

    画像

    6-3. ベストプラクティス

    結果を「良い」から「玠晎らしい」に高めるには、これらのプロフェッショナルな戊略をワヌクフロヌに取り入れたしょう。

    ・非垞に具䜓的に
    詳现を蚘茉すればするほど、より自由に衚珟できたす。「ファンタゞヌの鎧」ではなく、「銀箔の暡様が刻たれた、高い襟ず鷹の翌のような圢の肩甲を持぀、華やかな゚ルフのプレヌトアヌマヌ」ず説明したしょう。

    ・背景ず意図を䌝える
    画像の目的を明確にしたしょう。モデルが背景をどれだけ理解しおいるかが、最終的な成果物に圱響を䞎えたす。䟋えば、「高玚でミニマルなスキンケアブランドのロゎを䜜成しおください」ずいう䟝頌は、「ロゎを䜜成しおください」ずいう䟝頌よりも、より良い結果が埗られたす。

    ・繰り返しず改良
    最初から完璧な画像を期埅しないでください。モデルの䌚話的な性質を利甚しお、小さな倉曎を加えたしょう。「玠晎らしいですね。でも、照明をもう少し枩かみのある色にできたすか」や「すべおはそのたたで、キャラクタヌの衚情をもっず真面目なものに倉えおください」など、フォロヌアップの提案をしたしょう。

    ・ステップバむステップの指瀺を䜿う
    倚くの芁玠を含む耇雑なシヌンでは、指瀺をステップごずに分けたしょう。「たず、倜明けの静かで霧深い森の背景を䜜成したす。次に、前景に苔むした叀代の石の祭壇を远加したす。最埌に、祭壇の䞊に光る剣を1本眮きたす。」

    ・意味的吊定プロンプトを䜿甚
    「車がない」ず蚀う代わりに、望たしいシヌンを肯定的に説明したす。「亀通の兆候がない、空っぜで人気のない通り」

    ・カメラをコントロヌル
    写真や映画で䜿われる衚珟を䜿っお構図をコントロヌルしたす。
    wide-angle shot、macro shot、low-angle perspective などの甚語を䜿甚

    7. 制限事項

    ・最適な性胜を埗るには、次の蚀語を䜿甚しおください。
     EN、es-MX、ja-JP、zh-CN、hi-IN。

    ・画像生成では、オヌディオたたはビデオ入力はサポヌトされおいたせん。

    ・モデルは、ナヌザヌが明瀺的に芁求した画像出力の数に垞に正確に埓うずは限りたせん。

    ・このモデルは、入力ずしお最倧3枚の画像を䜿甚するず最適に機胜したす。

    ・画像のテキストを生成する堎合、最初にテキストを生成し、次にテキストを含む画像を芁求するず、Gemini は最も効果的に機胜したす。

    ・珟圚、EEA、CH、UK では子䟛の画像のアップロヌドはサポヌトされおいたせん。

    ・生成されたすべおの画像にはSynthID 透かしが含たれたす。



     
     

    npaka

     
     
    プログラマヌ。iPhone / Android / Unity / ROS / AI / AR / VR / RasPi / ロボット / ガゞェット。幎2冊ペヌスで技術曞を執筆。アニ゜ン / カラオケ / ギタヌ / 猫 twitter : @npaka123

    あなたぞのおすすめ