diff --git a/genai/image_generation/imggen_outpainting_with_txt_img.py b/genai/image_generation/imggen_outpainting_with_txt_img.py deleted file mode 100644 index f213540169..0000000000 --- a/genai/image_generation/imggen_outpainting_with_txt_img.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from google.genai.types import Image - - -def edit_outpainting(output_file: str) -> Image: - # [START googlegenaisdk_imggen_outpainting_with_txt_img] - from google import genai - from google.genai.types import ( - RawReferenceImage, - MaskReferenceImage, - MaskReferenceConfig, - EditImageConfig, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_file = "output-image.png" - - raw_ref = RawReferenceImage( - reference_image=Image.from_file(location="test_resources/living_room.png"), - reference_id=0, - ) - mask_ref = MaskReferenceImage( - reference_id=1, - reference_image=Image.from_file(location="test_resources/living_room_mask.png"), - config=MaskReferenceConfig( - mask_mode="MASK_MODE_USER_PROVIDED", - mask_dilation=0.03, - ), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="A chandelier hanging from the ceiling", - reference_images=[raw_ref, mask_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_OUTPAINT", - ), - ) - - image.generated_images[0].image.save(output_file) - - print(f"Created output image using {len(image.generated_images[0].image.image_bytes)} bytes") - # Example response: - # Created output image using 1234567 bytes - - # [END googlegenaisdk_imggen_outpainting_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_outpainting(output_file="output_folder/living_room_edit.png") diff --git a/genai/image_generation/imggen_product_background_mask_with_txt_img.py b/genai/image_generation/imggen_product_background_mask_with_txt_img.py deleted file mode 100644 index 239fd2c1ee..0000000000 --- a/genai/image_generation/imggen_product_background_mask_with_txt_img.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from google.genai.types import Image - - -def edit_product_background_mask(output_file: str) -> Image: - # [START googlegenaisdk_imggen_product_background_mask_with_txt_img] - from google import genai - from google.genai.types import ( - RawReferenceImage, - MaskReferenceImage, - MaskReferenceConfig, - EditImageConfig, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_file = "output-image.png" - - raw_ref = RawReferenceImage( - reference_image=Image.from_file(location="test_resources/suitcase.png"), - reference_id=0, - ) - mask_ref = MaskReferenceImage( - reference_id=1, - reference_image=Image.from_file(location="test_resources/suitcase_mask.png"), - config=MaskReferenceConfig( - mask_mode="MASK_MODE_USER_PROVIDED", - mask_dilation=0.0, - ), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="A light blue suitcase in an airport", - reference_images=[raw_ref, mask_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_BGSWAP", - ), - ) - - image.generated_images[0].image.save(output_file) - - print(f"Created output image using {len(image.generated_images[0].image.image_bytes)} bytes") - # Example response: - # Created output image using 1234567 bytes - - # [END googlegenaisdk_imggen_product_background_mask_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_product_background_mask(output_file="output_folder/suitcase_edit.png") diff --git a/genai/image_generation/imggen_product_background_with_txt_img.py b/genai/image_generation/imggen_product_background_with_txt_img.py deleted file mode 100644 index 6dcde90c8d..0000000000 --- a/genai/image_generation/imggen_product_background_with_txt_img.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from google.genai.types import Image - - -def edit_product_background(output_file: str) -> Image: - # [START googlegenaisdk_imggen_product_background_with_txt_img] - from google import genai - from google.genai.types import ( - RawReferenceImage, - MaskReferenceImage, - MaskReferenceConfig, - EditImageConfig, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_file = "output-image.png" - - raw_ref = RawReferenceImage( - reference_image=Image.from_file(location="test_resources/suitcase.png"), - reference_id=0, - ) - mask_ref = MaskReferenceImage( - reference_id=1, - reference_image=None, - config=MaskReferenceConfig( - mask_mode="MASK_MODE_BACKGROUND", - ), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="A light blue suitcase in front of a window in an airport", - reference_images=[raw_ref, mask_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_BGSWAP", - ), - ) - - image.generated_images[0].image.save(output_file) - - print(f"Created output image using {len(image.generated_images[0].image.image_bytes)} bytes") - # Example response: - # Created output image using 1234567 bytes - - # [END googlegenaisdk_imggen_product_background_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_product_background(output_file="output_folder/suitcase_edit.png") diff --git a/genai/image_generation/test_image_generation.py b/genai/image_generation/test_image_generation.py index f5cf14bb62..41acc20b71 100644 --- a/genai/image_generation/test_image_generation.py +++ b/genai/image_generation/test_image_generation.py @@ -30,9 +30,6 @@ import imggen_inpainting_removal_mask_with_txt_img import imggen_inpainting_removal_with_txt_img import imggen_mask_free_edit_with_txt_img -import imggen_outpainting_with_txt_img -import imggen_product_background_mask_with_txt_img -import imggen_product_background_with_txt_img import imggen_raw_reference_with_txt_img import imggen_scribble_ctrl_type_with_txt_img import imggen_style_reference_with_txt_img @@ -93,24 +90,6 @@ def test_img_edit_inpainting_removal() -> None: assert response -def test_img_edit_product_background_mask() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "suitcase_edit.png") - response = imggen_product_background_mask_with_txt_img.edit_product_background_mask(OUTPUT_FILE) - assert response - - -def test_img_edit_product_background() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "suitcase_edit.png") - response = imggen_product_background_with_txt_img.edit_product_background(OUTPUT_FILE) - assert response - - -def test_img_edit_outpainting() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "living_room_edit.png") - response = imggen_outpainting_with_txt_img.edit_outpainting(OUTPUT_FILE) - assert response - - def test_img_edit_mask_free() -> None: OUTPUT_FILE = os.path.join(RESOURCES, "latte_edit.png") response = imggen_mask_free_edit_with_txt_img.edit_mask_free(OUTPUT_FILE)