Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_content() -> str:
image = Image.open("test_resources/example-image-eiffel-tower.png")

response = client.models.generate_content(
model="gemini-2.5-flash-image",
model="gemini-3-pro-image-preview",
contents=[image, "Edit this image to make it look like a cartoon."],
config=GenerateContentConfig(response_modalities=[Modality.TEXT, Modality.IMAGE]),
)
Expand All @@ -36,12 +36,7 @@ def generate_content() -> str:
elif part.inline_data:
image = Image.open(BytesIO((part.inline_data.data)))
image.save("output_folder/bw-example-image.png")
# Example response:
# Here's the cartoon-style edit of the image:
# Cartoon-style edit:
# - Simplified the Eiffel Tower with bolder lines and slightly exaggerated proportions.
# - Brightened and saturated the colors of the sky, fireworks, and foliage for a more vibrant, cartoonish look.
# ....

# [END googlegenaisdk_imggen_mmflash_edit_img_with_txt_img]
return "output_folder/bw-example-image.png"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def generate_content() -> int:
client = genai.Client()

response = client.models.generate_content(
model="gemini-2.5-flash-image",
model="gemini-3-pro-image-preview",
contents=(
"Generate an illustrated recipe for a paella."
"Create images to go alongside the text as you generate the recipe"
Expand All @@ -38,9 +38,7 @@ def generate_content() -> int:
image = Image.open(BytesIO((part.inline_data.data)))
image.save(f"output_folder/example-image-{i+1}.png")
fp.write(f"![image](example-image-{i+1}.png)")
# Example response:
# A markdown page for a Paella recipe(`paella-recipe.md`) has been generated.
# It includes detailed steps and several images illustrating the cooking process.

# [END googlegenaisdk_imggen_mmflash_txt_and_img_with_txt]
return True

Expand Down
14 changes: 2 additions & 12 deletions genai/image_generation/imggen_mmflash_with_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ def generate_content() -> str:
client = genai.Client()

response = client.models.generate_content(
model="gemini-2.5-flash-image",
model="gemini-3-pro-image-preview",
contents=("Generate an image of the Eiffel tower with fireworks in the background."),
config=GenerateContentConfig(
response_modalities=[Modality.TEXT, Modality.IMAGE],
candidate_count=1,
safety_settings=[
{"method": "PROBABILITY"},
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT"},
{"threshold": "BLOCK_MEDIUM_AND_ABOVE"},
],
),
)
for part in response.candidates[0].content.parts:
Expand All @@ -41,11 +35,7 @@ def generate_content() -> str:
elif part.inline_data:
image = Image.open(BytesIO((part.inline_data.data)))
image.save("output_folder/example-image-eiffel-tower.png")
# Example response:
# I will generate an image of the Eiffel Tower at night, with a vibrant display of
# colorful fireworks exploding in the dark sky behind it. The tower will be
# illuminated, standing tall as the focal point of the scene, with the bursts of
# light from the fireworks creating a festive atmosphere.

# [END googlegenaisdk_imggen_mmflash_with_txt]
return True

Expand Down