From 9af540eadb901ee33361c13ee32740f6ad8aa4b2 Mon Sep 17 00:00:00 2001 From: David del Real Sifuentes Date: Mon, 31 Aug 2026 21:27:11 +0000 Subject: [PATCH] chore(genai): remove unused image generation samples Deletes unused image generation examples (inpainting removal and mask-free edit) and updates the corresponding tests. --- ...en_inpainting_removal_mask_with_txt_img.py | 66 ------------------- .../imggen_inpainting_removal_with_txt_img.py | 65 ------------------ .../imggen_mask_free_edit_with_txt_img.py | 53 --------------- .../image_generation/test_image_generation.py | 21 ------ 4 files changed, 205 deletions(-) delete mode 100644 genai/image_generation/imggen_inpainting_removal_mask_with_txt_img.py delete mode 100644 genai/image_generation/imggen_inpainting_removal_with_txt_img.py delete mode 100644 genai/image_generation/imggen_mask_free_edit_with_txt_img.py diff --git a/genai/image_generation/imggen_inpainting_removal_mask_with_txt_img.py b/genai/image_generation/imggen_inpainting_removal_mask_with_txt_img.py deleted file mode 100644 index 144155664d4..00000000000 --- a/genai/image_generation/imggen_inpainting_removal_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_inpainting_removal_mask(output_file: str) -> Image: - # [START googlegenaisdk_imggen_inpainting_removal_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/fruit.png"), - reference_id=0, - ) - mask_ref = MaskReferenceImage( - reference_id=1, - reference_image=Image.from_file(location="test_resources/fruit_mask.png"), - config=MaskReferenceConfig( - mask_mode="MASK_MODE_USER_PROVIDED", - mask_dilation=0.01, - ), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="", - reference_images=[raw_ref, mask_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_INPAINT_REMOVAL", - ), - ) - - 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_inpainting_removal_mask_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_inpainting_removal_mask(output_file="output_folder/fruit_edit.png") diff --git a/genai/image_generation/imggen_inpainting_removal_with_txt_img.py b/genai/image_generation/imggen_inpainting_removal_with_txt_img.py deleted file mode 100644 index 4784bccb299..00000000000 --- a/genai/image_generation/imggen_inpainting_removal_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_inpainting_removal(output_file: str) -> Image: - # [START googlegenaisdk_imggen_inpainting_removal_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/fruit.png"), - reference_id=0, - ) - mask_ref = MaskReferenceImage( - reference_id=1, - reference_image=None, - config=MaskReferenceConfig( - mask_mode="MASK_MODE_FOREGROUND", - ), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="", - reference_images=[raw_ref, mask_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_INPAINT_REMOVAL", - ), - ) - - 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_inpainting_removal_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_inpainting_removal(output_file="output_folder/fruit_edit.png") diff --git a/genai/image_generation/imggen_mask_free_edit_with_txt_img.py b/genai/image_generation/imggen_mask_free_edit_with_txt_img.py deleted file mode 100644 index ed7691a834e..00000000000 --- a/genai/image_generation/imggen_mask_free_edit_with_txt_img.py +++ /dev/null @@ -1,53 +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_mask_free(output_file: str) -> Image: - # [START googlegenaisdk_imggen_mask_free_edit_with_txt_img] - from google import genai - from google.genai.types import RawReferenceImage, 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/latte.jpg"), - reference_id=0, - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="Swan latte art in the coffee cup and an assortment of red velvet cupcakes in gold wrappers on the white plate", - reference_images=[raw_ref], - config=EditImageConfig( - edit_mode="EDIT_MODE_DEFAULT", - ), - ) - - 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_mask_free_edit_with_txt_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - edit_mask_free(output_file="output_folder/latte_edit.png") diff --git a/genai/image_generation/test_image_generation.py b/genai/image_generation/test_image_generation.py index f5cf14bb62c..eaa46e30ee3 100644 --- a/genai/image_generation/test_image_generation.py +++ b/genai/image_generation/test_image_generation.py @@ -27,9 +27,6 @@ import imggen_canny_ctrl_type_with_txt_img import imggen_inpainting_insert_mask_with_txt_img import imggen_inpainting_insert_with_txt_img -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 @@ -81,18 +78,6 @@ def test_img_edit_inpainting_insert() -> None: assert response -def test_img_edit_inpainting_removal_mask() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "fruit_edit.png") - response = imggen_inpainting_removal_mask_with_txt_img.edit_inpainting_removal_mask(OUTPUT_FILE) - assert response - - -def test_img_edit_inpainting_removal() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "fruit_edit.png") - response = imggen_inpainting_removal_with_txt_img.edit_inpainting_removal(OUTPUT_FILE) - 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) @@ -111,12 +96,6 @@ def test_img_edit_outpainting() -> None: 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) - assert response - - def test_img_customization_subject(output_gcs_uri: str) -> None: response = imggen_subj_refer_ctrl_refer_with_txt_imgs.subject_customization( output_gcs_uri=output_gcs_uri