Skip to content
Open
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 @@ -1302,7 +1302,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
2 changes: 1 addition & 1 deletion docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ Generate Videos (Image to Video)
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
16 changes: 8 additions & 8 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4444,7 +4444,7 @@ def recontext_image(
virtual_try_on_response = client.models.recontext_image(
model="virtual-try-on-preview-08-04",
source=types.RecontextImageSource(
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
),
config=types.RecontextImageConfig(
Expand Down Expand Up @@ -4530,7 +4530,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 @@ -5537,7 +5537,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 Down Expand Up @@ -5592,7 +5592,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 @@ -6288,7 +6288,7 @@ async def recontext_image(
virtual_try_on_response = client.models.recontext_image(
model="virtual-try-on-preview-08-04",
source=types.RecontextImageSource(
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
),
config=types.RecontextImageConfig(
Expand Down Expand Up @@ -6374,7 +6374,7 @@ async 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),
),
config=types.SegmentImageConfig(
mode=types.SegmentMode.foreground,
Expand Down Expand Up @@ -7321,7 +7321,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 @@ -7483,7 +7483,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