diff --git a/genai/image_generation/imggen_raw_reference_with_txt_img.py b/genai/image_generation/imggen_raw_reference_with_txt_img.py deleted file mode 100644 index c60830bc6f..0000000000 --- a/genai/image_generation/imggen_raw_reference_with_txt_img.py +++ /dev/null @@ -1,54 +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. - - -def style_transfer_customization(output_gcs_uri: str) -> str: - # [START googlegenaisdk_imggen_raw_reference_with_txt_img] - from google import genai - from google.genai.types import EditImageConfig, Image, RawReferenceImage - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_gcs_uri = "gs://your-bucket/your-prefix" - - # Create a raw reference image of teacup stored in Google Cloud Storage - # using https://storage.googleapis.com/cloud-samples-data/generative-ai/image/teacup-1.png - raw_ref_image = RawReferenceImage( - reference_image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/teacup-1.png"), - reference_id=1, - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="transform the subject in the image so that the teacup[1] is made entirely out of chocolate", - reference_images=[raw_ref_image], - config=EditImageConfig( - edit_mode="EDIT_MODE_DEFAULT", - number_of_images=1, - safety_filter_level="BLOCK_MEDIUM_AND_ABOVE", - person_generation="ALLOW_ADULT", - output_gcs_uri=output_gcs_uri, - ), - ) - - # Example response: - # gs://your-bucket/your-prefix - print(image.generated_images[0].image.gcs_uri) - # [END googlegenaisdk_imggen_raw_reference_with_txt_img] - return image.generated_images[0].image.gcs_uri - - -if __name__ == "__main__": - style_transfer_customization(output_gcs_uri="gs://your-bucket/your-prefix") diff --git a/genai/image_generation/imggen_scribble_ctrl_type_with_txt_img.py b/genai/image_generation/imggen_scribble_ctrl_type_with_txt_img.py deleted file mode 100644 index 64e9a95a47..0000000000 --- a/genai/image_generation/imggen_scribble_ctrl_type_with_txt_img.py +++ /dev/null @@ -1,60 +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. - - -def scribble_customization(output_gcs_uri: str) -> str: - # [START googlegenaisdk_imggen_scribble_ctrl_type_with_txt_img] - from google import genai - from google.genai.types import ( - ControlReferenceConfig, - ControlReferenceImage, - EditImageConfig, - Image, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_gcs_uri = "gs://your-bucket/your-prefix" - - # Create a reference image out of an existing scribble image signal - # using https://storage.googleapis.com/cloud-samples-data/generative-ai/image/car_scribble.png - control_reference_image = ControlReferenceImage( - reference_id=1, - reference_image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/car_scribble.png"), - config=ControlReferenceConfig(control_type="CONTROL_TYPE_SCRIBBLE"), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="an oil painting showing the side of a red car[1]", - reference_images=[control_reference_image], - config=EditImageConfig( - edit_mode="EDIT_MODE_CONTROLLED_EDITING", - number_of_images=1, - safety_filter_level="BLOCK_MEDIUM_AND_ABOVE", - person_generation="ALLOW_ADULT", - output_gcs_uri=output_gcs_uri, - ), - ) - - # Example response: - # gs://your-bucket/your-prefix - print(image.generated_images[0].image.gcs_uri) - # [END googlegenaisdk_imggen_scribble_ctrl_type_with_txt_img] - return image.generated_images[0].image.gcs_uri - - -if __name__ == "__main__": - scribble_customization(output_gcs_uri="gs://your-bucket/your-prefix") diff --git a/genai/image_generation/imggen_style_reference_with_txt_img.py b/genai/image_generation/imggen_style_reference_with_txt_img.py deleted file mode 100644 index 124c9db8fb..0000000000 --- a/genai/image_generation/imggen_style_reference_with_txt_img.py +++ /dev/null @@ -1,60 +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. - - -def style_customization(output_gcs_uri: str) -> str: - # [START googlegenaisdk_imggen_style_reference_with_txt_img] - from google import genai - from google.genai.types import ( - EditImageConfig, - Image, - StyleReferenceConfig, - StyleReferenceImage, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_gcs_uri = "gs://your-bucket/your-prefix" - - # Create a style reference image of a neon sign stored in Google Cloud Storage - # using https://storage.googleapis.com/cloud-samples-data/generative-ai/image/neon.png - style_reference_image = StyleReferenceImage( - reference_id=1, - reference_image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/neon.png"), - config=StyleReferenceConfig(style_description="neon sign"), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt="generate an image of a neon sign [1] with the words: have a great day", - reference_images=[style_reference_image], - config=EditImageConfig( - edit_mode="EDIT_MODE_DEFAULT", - number_of_images=1, - safety_filter_level="BLOCK_MEDIUM_AND_ABOVE", - person_generation="ALLOW_ADULT", - output_gcs_uri=output_gcs_uri, - ), - ) - - # Example response: - # gs://your-bucket/your-prefix - print(image.generated_images[0].image.gcs_uri) - # [END googlegenaisdk_imggen_style_reference_with_txt_img] - return image.generated_images[0].image.gcs_uri - - -if __name__ == "__main__": - style_customization(output_gcs_uri="gs://your-bucket/your-prefix") diff --git a/genai/image_generation/test_image_generation.py b/genai/image_generation/test_image_generation.py index f5cf14bb62..292933630e 100644 --- a/genai/image_generation/test_image_generation.py +++ b/genai/image_generation/test_image_generation.py @@ -33,9 +33,6 @@ 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 import imggen_subj_refer_ctrl_refer_with_txt_imgs import imggen_upscale_with_img import imggen_virtual_try_on_with_txt_img @@ -124,21 +121,6 @@ def test_img_customization_subject(output_gcs_uri: str) -> None: assert response -def test_img_customization_style(output_gcs_uri: str) -> None: - response = imggen_style_reference_with_txt_img.style_customization(output_gcs_uri=output_gcs_uri) - assert response - - -def test_img_customization_style_transfer(output_gcs_uri: str) -> None: - response = imggen_raw_reference_with_txt_img.style_transfer_customization(output_gcs_uri=output_gcs_uri) - assert response - - -def test_img_customization_scribble(output_gcs_uri: str) -> None: - response = imggen_scribble_ctrl_type_with_txt_img.scribble_customization(output_gcs_uri=output_gcs_uri) - assert response - - def test_img_customization_canny_edge(output_gcs_uri: str) -> None: response = imggen_canny_ctrl_type_with_txt_img.canny_edge_customization(output_gcs_uri=output_gcs_uri) assert response