Skip to content

Commit cce5398

Browse files
matthew29tangcopybara-github
authored andcommitted
docs: Fix python docstrings for Image.from_file() to use kwargs
PiperOrigin-RevId: 908262626
1 parent 4e17a9c commit cce5398

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ video.show()
12841284
from google.genai import types
12851285

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

12891289
# Create operation
12901290
operation = client.models.generate_videos(

google/genai/models.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5318,8 +5318,10 @@ def recontext_image(
53185318
virtual_try_on_response = client.models.recontext_image(
53195319
model="virtual-try-on-001",
53205320
source=types.RecontextImageSource(
5321-
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
5322-
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
5321+
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
5322+
product_images=[types.ProductImage(product_image=
5323+
types.Image.from_file(location=IMAGE2_FILE_PATH)
5324+
)],
53235325
),
53245326
config=types.RecontextImageConfig(
53255327
number_of_images=1,
@@ -5424,7 +5426,7 @@ def segment_image(
54245426
response = client.models.segment_image(
54255427
model="image-segmentation-001",
54265428
source=types.SegmentImageSource(
5427-
image=types.Image.from_file(IMAGE_FILE_PATH),
5429+
image=types.Image.from_file(location=IMAGE_FILE_PATH),
54285430
),
54295431
)
54305432
@@ -6649,7 +6651,7 @@ def edit_image(
66496651
66506652
raw_ref_image = RawReferenceImage(
66516653
reference_id=1,
6652-
reference_image=types.Image.from_file(IMAGE_FILE_PATH),
6654+
reference_image=types.Image.from_file(location=IMAGE_FILE_PATH),
66536655
)
66546656
66556657
mask_ref_image = MaskReferenceImage(
@@ -6661,7 +6663,7 @@ def edit_image(
66616663
)
66626664
response = client.models.edit_image(
66636665
model='imagen-3.0-capability-001',
6664-
prompt='man with dog',
6666+
prompt='Man with dog',
66656667
reference_images=[raw_ref_image, mask_ref_image],
66666668
config=types.EditImageConfig(
66676669
edit_mode= "EDIT_MODE_INPAINT_INSERTION",
@@ -6704,7 +6706,7 @@ def upscale_image(
67046706
IMAGE_FILE_PATH="my-image.png"
67056707
response=client.models.upscale_image(
67066708
model='imagen-3.0-generate-001',
6707-
image=types.Image.from_file(IMAGE_FILE_PATH),
6709+
image=types.Image.from_file(location=IMAGE_FILE_PATH),
67086710
upscale_factor='x2',
67096711
)
67106712
response.generated_images[0].image.show()
@@ -7507,8 +7509,10 @@ async def recontext_image(
75077509
virtual_try_on_response = await client.aio.models.recontext_image(
75087510
model="virtual-try-on-001",
75097511
source=types.RecontextImageSource(
7510-
person_image=types.Image.from_file(IMAGE1_FILE_PATH),
7511-
product_images=[types.ProductImage.from_file(IMAGE2_FILE_PATH)],
7512+
person_image=types.Image.from_file(location=IMAGE1_FILE_PATH),
7513+
product_images=[types.ProductImage(product_image=
7514+
types.Image.from_file(location=IMAGE2_FILE_PATH)
7515+
)],
75127516
),
75137517
config=types.RecontextImageConfig(
75147518
number_of_images=1,
@@ -7610,10 +7614,10 @@ async def segment_image(
76107614
Usage:
76117615
76127616
```
7613-
response = client.models.segment_image(
7617+
response = await client.aio.models.segment_image(
76147618
model="image-segmentation-001",
76157619
source=types.SegmentImageSource(
7616-
image=types.Image.from_file(IMAGE_FILE_PATH),
7620+
image=types.Image.from_file(location=IMAGE_FILE_PATH),
76177621
),
76187622
config=types.SegmentImageConfig(
76197623
mode=types.SegmentMode.foreground,
@@ -8707,7 +8711,7 @@ async def edit_image(
87078711
87088712
raw_ref_image = RawReferenceImage(
87098713
reference_id=1,
8710-
reference_image=types.Image.from_file(IMAGE_FILE_PATH),
8714+
reference_image=types.Image.from_file(location=IMAGE_FILE_PATH),
87118715
)
87128716
87138717
mask_ref_image = MaskReferenceImage(
@@ -8869,7 +8873,7 @@ async def upscale_image(
88698873
IMAGE_FILE_PATH="my-image.png"
88708874
response = await client.aio.models.upscale_image(
88718875
model='imagen-3.0-generate-001',
8872-
image=types.Image.from_file(IMAGE_FILE_PATH),
8876+
image=types.Image.from_file(location=IMAGE_FILE_PATH),
88738877
upscale_factor='x2',
88748878
)
88758879
response.generated_images[0].image.show()

0 commit comments

Comments
 (0)