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
85 changes: 0 additions & 85 deletions google/genai/tests/models/test_recontext_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,8 @@
from ... import types
from .. import pytest_helper

PRODUCT_RECONTEXT_MODEL_LATEST = 'imagen-product-recontext-preview-06-30'

VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST = 'virtual-try-on-001'

BACKPACK1 = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack1.png',
)

BACKPACK2 = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack2.png',
)

BACKPACK3 = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack3.png',
)

PERSON_IMAGE = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/man.jpg',
)
Expand All @@ -46,57 +32,6 @@
)

test_table: list[pytest_helper.TestTableItem] = [
pytest_helper.TestTableItem(
name='test_product_recontext',
exception_if_mldev='only supported in the Vertex AI client',
parameters=types._RecontextImageParameters(
model=PRODUCT_RECONTEXT_MODEL_LATEST,
source=types.RecontextImageSource(
prompt='On a school desk',
product_images=[
types.ProductImage(product_image=BACKPACK1)
],
),
config=types.RecontextImageConfig(
number_of_images=1,
add_watermark=True,
output_mime_type='image/jpeg',
),
),
),
pytest_helper.TestTableItem(
name='test_product_recontext_all_config',
exception_if_mldev='only supported in the Vertex AI client',
parameters=types._RecontextImageParameters(
model=PRODUCT_RECONTEXT_MODEL_LATEST,
source=types.RecontextImageSource(
prompt='On a school desk',
product_images=[
types.ProductImage(
product_image=BACKPACK1,
),
types.ProductImage(
product_image=BACKPACK2,
),
types.ProductImage(
product_image=BACKPACK3,
),
],
),
config=types.RecontextImageConfig(
number_of_images=1,
output_mime_type='image/jpeg',
base_steps=32,
seed=1337,
add_watermark=False,
safety_filter_level=types.SafetyFilterLevel.BLOCK_MEDIUM_AND_ABOVE,
person_generation=types.PersonGeneration.ALLOW_ADULT,
output_compression_quality=75,
enhance_prompt=False,
labels={'imagen_label_key': 'recontext_image'}
),
),
),
pytest_helper.TestTableItem(
name='test_virtual_try_on',
exception_if_mldev='only supported in the Vertex AI client',
Expand Down Expand Up @@ -149,26 +84,6 @@
)


@pytest.mark.asyncio
async def test_product_recontext_async(client):
with pytest_helper.exception_if_mldev(client, ValueError):
response = await client.aio.models.recontext_image(
model=PRODUCT_RECONTEXT_MODEL_LATEST,
source=types.RecontextImageSource(
prompt='On a school desk',
product_images=[
types.ProductImage(product_image=BACKPACK1)
],
),
config=types.RecontextImageConfig(
number_of_images=1,
output_mime_type='image/jpeg',
)
)
assert len(response.generated_images) == 1
assert response.generated_images[0].image.image_bytes


@pytest.mark.asyncio
async def test_virtual_try_on_async(client):
with pytest_helper.exception_if_mldev(client, ValueError):
Expand Down
21 changes: 11 additions & 10 deletions google/genai/tests/shared/models/test_recontext_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,35 @@
from .... import types
from ... import pytest_helper

PRODUCT_RECONTEXT_MODEL_LATEST = 'imagen-product-recontext-preview-06-30'
VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST = 'virtual-try-on-001'

BACKPACK1 = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack1.png',
PERSON_IMAGE = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/man.jpg',
)

PANTS = types.Image(
gcs_uri='gs://genai-sdk-tests/inputs/images/pants.jpg',
)

test_table: list[pytest_helper.TestTableItem] = [
pytest_helper.TestTableItem(
name='test_product_recontext',
name='test_virtual_try_on',
exception_if_mldev='only supported in the Vertex AI client',
parameters=types._RecontextImageParameters(
model=PRODUCT_RECONTEXT_MODEL_LATEST,
model=VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST,
source=types.RecontextImageSource(
prompt='On a school desk',
person_image=PERSON_IMAGE,
product_images=[
types.ProductImage(product_image=BACKPACK1)
types.ProductImage(product_image=PANTS)
],
),
config=types.RecontextImageConfig(
number_of_images=1,
add_watermark=True,
output_mime_type='image/jpeg',
),
),
),
]


pytestmark = pytest_helper.setup(
file=__file__,
globals_for_file=globals(),
Expand Down
Loading