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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ video.show()
from google.genai import types

# Read local image (uses mimetypes.guess_type to infer mime type)
image = types.Image.from_file("local/path/file.png")
image = types.Image.from_file(location="local/path/file.png")

# Create operation
operation = client.models.generate_videos(
Expand Down
28 changes: 16 additions & 12 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5318,8 +5318,10 @@ def recontext_image(
virtual_try_on_response = client.models.recontext_image(
model="virtual-try-on-001",
source=types.RecontextImageSource(
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
product_images=[types.ProductImage(product_image=
types.Image.from_file(location=IMAGE2_FILE_PATH)
)],
),
config=types.RecontextImageConfig(
number_of_images=1,
Expand Down Expand Up @@ -5424,7 +5426,7 @@ def segment_image(
response = client.models.segment_image(
model="image-segmentation-001",
source=types.SegmentImageSource(
image=types.Image.from_file(IMAGE_FILE_PATH),
image=types.Image.from_file(location=IMAGE_FILE_PATH),
),
)

Expand Down Expand Up @@ -6649,7 +6651,7 @@ def edit_image(

raw_ref_image = RawReferenceImage(
reference_id=1,
reference_image=types.Image.from_file(IMAGE_FILE_PATH),
reference_image=types.Image.from_file(location=IMAGE_FILE_PATH),
)

mask_ref_image = MaskReferenceImage(
Expand All @@ -6661,7 +6663,7 @@ def edit_image(
)
response = client.models.edit_image(
model='imagen-3.0-capability-001',
prompt='man with dog',
prompt='Man with dog',
reference_images=[raw_ref_image, mask_ref_image],
config=types.EditImageConfig(
edit_mode= "EDIT_MODE_INPAINT_INSERTION",
Expand Down Expand Up @@ -6704,7 +6706,7 @@ def upscale_image(
IMAGE_FILE_PATH="my-image.png"
response=client.models.upscale_image(
model='imagen-3.0-generate-001',
image=types.Image.from_file(IMAGE_FILE_PATH),
image=types.Image.from_file(location=IMAGE_FILE_PATH),
upscale_factor='x2',
)
response.generated_images[0].image.show()
Expand Down Expand Up @@ -7507,8 +7509,10 @@ async def recontext_image(
virtual_try_on_response = await client.aio.models.recontext_image(
model="virtual-try-on-001",
source=types.RecontextImageSource(
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
product_images=[types.ProductImage(product_image=
types.Image.from_file(location=IMAGE2_FILE_PATH)
)],
),
config=types.RecontextImageConfig(
number_of_images=1,
Expand Down Expand Up @@ -7610,10 +7614,10 @@ async def segment_image(
Usage:

```
response = client.models.segment_image(
response = await client.aio.models.segment_image(
model="image-segmentation-001",
source=types.SegmentImageSource(
image=types.Image.from_file(IMAGE_FILE_PATH),
image=types.Image.from_file(location=IMAGE_FILE_PATH),
),
config=types.SegmentImageConfig(
mode=types.SegmentMode.foreground,
Expand Down Expand Up @@ -8707,7 +8711,7 @@ async def edit_image(

raw_ref_image = RawReferenceImage(
reference_id=1,
reference_image=types.Image.from_file(IMAGE_FILE_PATH),
reference_image=types.Image.from_file(location=IMAGE_FILE_PATH),
)

mask_ref_image = MaskReferenceImage(
Expand Down Expand Up @@ -8869,7 +8873,7 @@ async def upscale_image(
IMAGE_FILE_PATH="my-image.png"
response = await client.aio.models.upscale_image(
model='imagen-3.0-generate-001',
image=types.Image.from_file(IMAGE_FILE_PATH),
image=types.Image.from_file(location=IMAGE_FILE_PATH),
upscale_factor='x2',
)
response.generated_images[0].image.show()
Expand Down
Loading