Skip to content

Commit e9a0eb9

Browse files
matthew29tangcopybara-github
authored andcommitted
chore: Remove/update tests for the deprecated product recontext model.
PiperOrigin-RevId: 893758362
1 parent 07e932f commit e9a0eb9

File tree

2 files changed

+11
-95
lines changed

2 files changed

+11
-95
lines changed

google/genai/tests/models/test_recontext_image.py

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,8 @@
2121
from ... import types
2222
from .. import pytest_helper
2323

24-
PRODUCT_RECONTEXT_MODEL_LATEST = 'imagen-product-recontext-preview-06-30'
25-
2624
VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST = 'virtual-try-on-001'
2725

28-
BACKPACK1 = types.Image(
29-
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack1.png',
30-
)
31-
32-
BACKPACK2 = types.Image(
33-
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack2.png',
34-
)
35-
36-
BACKPACK3 = types.Image(
37-
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack3.png',
38-
)
39-
4026
PERSON_IMAGE = types.Image(
4127
gcs_uri='gs://genai-sdk-tests/inputs/images/man.jpg',
4228
)
@@ -46,57 +32,6 @@
4632
)
4733

4834
test_table: list[pytest_helper.TestTableItem] = [
49-
pytest_helper.TestTableItem(
50-
name='test_product_recontext',
51-
exception_if_mldev='only supported in the Vertex AI client',
52-
parameters=types._RecontextImageParameters(
53-
model=PRODUCT_RECONTEXT_MODEL_LATEST,
54-
source=types.RecontextImageSource(
55-
prompt='On a school desk',
56-
product_images=[
57-
types.ProductImage(product_image=BACKPACK1)
58-
],
59-
),
60-
config=types.RecontextImageConfig(
61-
number_of_images=1,
62-
add_watermark=True,
63-
output_mime_type='image/jpeg',
64-
),
65-
),
66-
),
67-
pytest_helper.TestTableItem(
68-
name='test_product_recontext_all_config',
69-
exception_if_mldev='only supported in the Vertex AI client',
70-
parameters=types._RecontextImageParameters(
71-
model=PRODUCT_RECONTEXT_MODEL_LATEST,
72-
source=types.RecontextImageSource(
73-
prompt='On a school desk',
74-
product_images=[
75-
types.ProductImage(
76-
product_image=BACKPACK1,
77-
),
78-
types.ProductImage(
79-
product_image=BACKPACK2,
80-
),
81-
types.ProductImage(
82-
product_image=BACKPACK3,
83-
),
84-
],
85-
),
86-
config=types.RecontextImageConfig(
87-
number_of_images=1,
88-
output_mime_type='image/jpeg',
89-
base_steps=32,
90-
seed=1337,
91-
add_watermark=False,
92-
safety_filter_level=types.SafetyFilterLevel.BLOCK_MEDIUM_AND_ABOVE,
93-
person_generation=types.PersonGeneration.ALLOW_ADULT,
94-
output_compression_quality=75,
95-
enhance_prompt=False,
96-
labels={'imagen_label_key': 'recontext_image'}
97-
),
98-
),
99-
),
10035
pytest_helper.TestTableItem(
10136
name='test_virtual_try_on',
10237
exception_if_mldev='only supported in the Vertex AI client',
@@ -149,26 +84,6 @@
14984
)
15085

15186

152-
@pytest.mark.asyncio
153-
async def test_product_recontext_async(client):
154-
with pytest_helper.exception_if_mldev(client, ValueError):
155-
response = await client.aio.models.recontext_image(
156-
model=PRODUCT_RECONTEXT_MODEL_LATEST,
157-
source=types.RecontextImageSource(
158-
prompt='On a school desk',
159-
product_images=[
160-
types.ProductImage(product_image=BACKPACK1)
161-
],
162-
),
163-
config=types.RecontextImageConfig(
164-
number_of_images=1,
165-
output_mime_type='image/jpeg',
166-
)
167-
)
168-
assert len(response.generated_images) == 1
169-
assert response.generated_images[0].image.image_bytes
170-
171-
17287
@pytest.mark.asyncio
17388
async def test_virtual_try_on_async(client):
17489
with pytest_helper.exception_if_mldev(client, ValueError):

google/genai/tests/shared/models/test_recontext_image.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,35 @@
1919
from .... import types
2020
from ... import pytest_helper
2121

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

24-
BACKPACK1 = types.Image(
25-
gcs_uri='gs://genai-sdk-tests/inputs/images/backpack1.png',
24+
PERSON_IMAGE = types.Image(
25+
gcs_uri='gs://genai-sdk-tests/inputs/images/man.jpg',
26+
)
27+
28+
PANTS = types.Image(
29+
gcs_uri='gs://genai-sdk-tests/inputs/images/pants.jpg',
2630
)
2731

2832
test_table: list[pytest_helper.TestTableItem] = [
2933
pytest_helper.TestTableItem(
30-
name='test_product_recontext',
34+
name='test_virtual_try_on',
3135
exception_if_mldev='only supported in the Vertex AI client',
3236
parameters=types._RecontextImageParameters(
33-
model=PRODUCT_RECONTEXT_MODEL_LATEST,
37+
model=VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST,
3438
source=types.RecontextImageSource(
35-
prompt='On a school desk',
39+
person_image=PERSON_IMAGE,
3640
product_images=[
37-
types.ProductImage(product_image=BACKPACK1)
41+
types.ProductImage(product_image=PANTS)
3842
],
3943
),
4044
config=types.RecontextImageConfig(
4145
number_of_images=1,
42-
add_watermark=True,
4346
output_mime_type='image/jpeg',
4447
),
4548
),
4649
),
4750
]
48-
49-
5051
pytestmark = pytest_helper.setup(
5152
file=__file__,
5253
globals_for_file=globals(),

0 commit comments

Comments
 (0)