数码之家

 找回密码
 立即注册

QQ登录

只需一步,快速开始

微信登录

微信扫一扫,快速登录

搜索
查看: 48|回复: 0

[科技] Nano Banana 官方提示词来了,附完整代码示例

[复制链接]
发表于 昨天 22:40 | 显示全部楼层 |阅读模式

爱科技、爱创意、爱折腾、爱极致,我们都是技术控

您需要 登录 才可以下载或查看,没有账号?立即注册 微信登录

x
Nano banana 正火爆全球,谷歌立马推出官方提示词指南。
下面先进行一些效果展示,看看它的强大之处。
借助 Nano-banana、Seedance 和 Kling,梵高、蒙娜丽莎、戴珍珠耳环的少女都能在纽约中央公园里合照。
不仅如此,还能生成十分炫酷的动画视频。
甚至能毫无痕迹的换脸?!
好家伙,香蕉这波真是让我开眼了。感觉官方再不出教程,网友们自己都能搞个“百科全书”了。
正值香蕉热度爆棚之际,谷歌总结其 5 大核心功能,助你轻松玩转这一创新工具。
  • 文本转图像:从文本描述生成高质量图像。
  • 图像 + 文本转图像(编辑):可通过文本提示对图像进行添加、删除或修改元素,还能改变风格和调整色彩。
  • 多图像到图像(构图和风格转换):使用多张输入图像来组成一个新场景或将风格从一张图像转换到另一张图像。
  • 迭代细化:可通过多次对话逐步微调图像,直至完美。
  • 高保真文本渲染:准确生成清晰且布局合理的文字图像,适用于 logo、图表和海报等。

谷歌还特别提示了,描述场景,不要仅仅列出关键词。
相比简单、不连贯的关键词列表,一段叙事性强、描述详细的段落通常能生成更好、更连贯的图像。
对于此指导,网友可谓十分喜欢。
下面让我们一起看看具体提示词是什么样的。
6 类 Nano banana 提示词
生成图像最常见的方法,就是告诉它你想看什么。
先看看官方生成的图片,猫猫在双子座星空下的豪华餐厅里吃香蕉。
哇哦,猫猫桌子上还摆着刀叉和酒杯,餐厅里其他桌子上也有客人,真是充满了细节。
如果你也想用纳米香蕉生成如此惊艳的效果,就一起来学学谷歌的 6 大类提示词吧。
逼真的场景
要获得逼真的图像,最好像摄影师一样思考。提及相机角度、镜头类型、光线和精细细节,这将使模型达到最逼真的效果。
通用提示如下所示:
A photorealistic [shot type] of [subject], [action or expression], set in [environment]. The scene is illuminated by [lighting deion], creating a [mood] atmosphere. Captured with a [camera/lens details], emphasizing [key textures and details]. The image should be in a [aspect ratio] format.
不仅如此,谷歌还特意给出了 API 代码。
1 from google import genai 2 from google.genai import types 3 from PIL import Image 4 from io import BytesIO 5 6 client = genai.Client 7 8 # Generate an image from a text prompt 9 response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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 with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful.",12 )1314 image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18 ]1920 if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('photorealistic_example.png')23 image.show
以下为官方生成的一位老年陶瓷艺术家的特写。
柔和的金色阳光透过窗户洒进画面,照亮了陶土的细腻质感和老人脸上的皱纹。
风格化的插图和贴纸
如果你想为项目创建贴纸、图标或其他素材,务必明确指定风格,并在需要时要求使用白色背景。
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 white.
1from google import genai 2from google.genai import types 3from PIL import Image 4from io import BytesIO 5 6client = genai.Client 7 8# Generate an image from a text prompt 9response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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 with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful.",12)1314image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18]1920if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('photorealistic_example.png')23 image.show
以下为一张卡哇伊风格的快乐小熊贴纸。
背景为设定的白色,整体采用清晰轮廓和大胆配色,整个设计十分生动和吸引人。
图像中的准确文本
在渲染文本时,需具体描述文本内容、字体风格,以及整体设计。
Create a [image type] for [brand/concept] with the text “[text to render]” in a [font style]. The design should be [style deion], with a [color scheme].
1from google import genai 2from google.genai import types 3from PIL import Image 4from io import BytesIO 5 6client = genai.Client 7 8# Generate an image from a text prompt 9response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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.",12)1314image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18]1920if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('logo_example.png')23 image.show
以下是为名为“The Daily Grind”的咖啡店创建的一个现代简约风格的标志。
此图整体采用黑白风格,中间的咖啡豆图标成为了整个设计的焦点,非常符合咖啡店的品牌形象。
产品模型和商业摄影
纳米香蕉还能为电子商务、广告或品牌创建清晰、专业的产品照片。
A high-resolution, studio-lit product photograph of a [product deion] on a [background surface/deion]. 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].
1from google import genai 2from google.genai import types 3from PIL import Image 4from io import BytesIO 5 6client = genai.Client 7 8# Generate an image from a text prompt 9response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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.",12)1314image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18]1920if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('product_mockup.png')23 image.show
以下为一张高分辨率、工作室灯光下的简约陶瓷咖啡杯产品照片。
此图可以清晰地看到杯内升起的蒸汽,整体线条简约,画面极其逼真。
极简主义和空间设计
它还非常适用于创建网站、演示文稿或营销材料的背景,并在这些背景上覆盖文本加以修饰。
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].
1from google import genai 2from google.genai import types 3from PIL import Image 4from io import BytesIO 5 6client = genai.Client 7 8# Generate an image from a text prompt 9response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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.",12)1314image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18]1920if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('minimalist_design.png')23 image.show
以下是一张极简主义构图,右下角以一片精致的红色枫叶为特色。
连环画(漫画面板 / 故事板)
通过清晰的场景描述,逐帧创建引人入胜的视觉叙事,特别适合制作故事板、漫画或任何形式的连环画。
A single comic book panel in a [art style] style. In the foreground, [character deion 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].
1from google import genai 2from google.genai import types 3from PIL import Image 4from io import BytesIO 5 6client = genai.Client 7 8# Generate an image from a text prompt 9response = client.models.generate_content(10 model="gemini-2.5-flash-image-preview",11 contents="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.",12)1314image_parts = [15 part.inline_data.data16 for part in response.candidates[0].content.parts17 if part.inline_data18]1920if image_parts:21 image = Image.open(BytesIO(image_parts[0]))22 image.save('comic_panel.png')23 image.show
以下是一幅黑色艺术风格的漫画书面板。
此漫画中,主人公身穿风衣站在路灯下,背景中,一家荒凉酒吧的灯牌映照在水中,整体充满了浓厚的隐秘与危险氛围。
这些提示词指南和效果展示难道还没有引起你的兴趣吗?
心动不如行动,赶紧去体验一下这项创新技术的强大吧~
参考链接:
  • [1]https://x.com/googleaistudio/status/1962957615262224511
  • [2]https://ai.google.dev/gemini-api/docs/image-generation


您需要登录后才可以回帖 登录 | 立即注册 微信登录

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2025-9-4 04:57 , Processed in 0.156000 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz!

© 2006-2025 MyDigit.Net

快速回复 返回顶部 返回列表