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
10 changes: 10 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,9 @@ def _GenerateVideosConfig_to_mldev(
if getv(from_object, ['labels']) is not None:
raise ValueError('labels parameter is not supported in Gemini API.')

if getv(from_object, ['resize_mode']) is not None:
raise ValueError('resize_mode parameter is not supported in Gemini API.')

return to_object


Expand Down Expand Up @@ -2281,6 +2284,13 @@ def _GenerateVideosConfig_to_vertex(
if getv(from_object, ['labels']) is not None:
setv(parent_object, ['labels'], getv(from_object, ['labels']))

if getv(from_object, ['resize_mode']) is not None:
setv(
parent_object,
['parameters', 'resizeMode'],
getv(from_object, ['resize_mode']),
)

return to_object


Expand Down
2 changes: 2 additions & 0 deletions google/genai/tests/models/test_generate_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ def test_text_and_image_to_video_poll(client):
image=GCS_IMAGE if client.vertexai else LOCAL_IMAGE,
config=types.GenerateVideosConfig(
output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
resize_mode=(types.ImageResizeMode.CROP
if client.vertexai else None),
),
)
while not operation.done:
Expand Down
18 changes: 18 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,17 @@ class VideoCompressionQuality(_common.CaseInSensitiveEnum):
with a larger file size."""


class ImageResizeMode(_common.CaseInSensitiveEnum):
"""Resize mode for the image input for video generation."""

CROP = 'CROP'
"""Crop the image to fit the correct aspect ratio (so we lose parts
of the image in the process)."""
PAD = 'PAD'
"""Pad the image to fit the correct aspect ratio (so we don't lose
any parts of the image in the process)."""


class TuningMethod(_common.CaseInSensitiveEnum):
"""Enum representing the tuning method."""

Expand Down Expand Up @@ -11181,6 +11192,10 @@ class GenerateVideosConfig(_common.BaseModel):
default=None,
description="""User specified labels to track billing usage.""",
)
resize_mode: Optional[ImageResizeMode] = Field(
default=None,
description="""Resize mode of the image input for video generation.""",
)


class GenerateVideosConfigDict(TypedDict, total=False):
Expand Down Expand Up @@ -11253,6 +11268,9 @@ class GenerateVideosConfigDict(TypedDict, total=False):
labels: Optional[dict[str, str]]
"""User specified labels to track billing usage."""

resize_mode: Optional[ImageResizeMode]
"""Resize mode of the image input for video generation."""


GenerateVideosConfigOrDict = Union[
GenerateVideosConfig, GenerateVideosConfigDict
Expand Down
Loading