diff --git a/genai/image_generation/imggen_subj_refer_ctrl_refer_with_txt_imgs.py b/genai/image_generation/imggen_subj_refer_ctrl_refer_with_txt_imgs.py deleted file mode 100644 index 50f733e61c..0000000000 --- a/genai/image_generation/imggen_subj_refer_ctrl_refer_with_txt_imgs.py +++ /dev/null @@ -1,74 +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 subject_customization(output_gcs_uri: str) -> str: - # [START googlegenaisdk_imggen_subj_refer_ctrl_refer_with_txt_imgs] - from google import genai - from google.genai.types import ( - ControlReferenceConfig, - ControlReferenceImage, - EditImageConfig, - Image, - SubjectReferenceConfig, - SubjectReferenceImage, - ) - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_gcs_uri = "gs://your-bucket/your-prefix" - - # Create subject and control reference images of a photograph stored in Google Cloud Storage - # using https://storage.googleapis.com/cloud-samples-data/generative-ai/image/person.png - subject_reference_image = SubjectReferenceImage( - reference_id=1, - reference_image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/person.png"), - config=SubjectReferenceConfig( - subject_description="a headshot of a woman", - subject_type="SUBJECT_TYPE_PERSON", - ), - ) - control_reference_image = ControlReferenceImage( - reference_id=2, - reference_image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/person.png"), - config=ControlReferenceConfig(control_type="CONTROL_TYPE_FACE_MESH"), - ) - - image = client.models.edit_image( - model="imagen-3.0-capability-001", - prompt=""" - a portrait of a woman[1] in the pose of the control image[2]in a watercolor style by a professional artist, - light and low-contrast stokes, bright pastel colors, a warm atmosphere, clean background, grainy paper, - bold visible brushstrokes, patchy details - """, - reference_images=[subject_reference_image, control_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_subj_refer_ctrl_refer_with_txt_imgs] - return image.generated_images[0].image.gcs_uri - - -if __name__ == "__main__": - subject_customization(output_gcs_uri="gs://your-bucket/your-prefix") diff --git a/genai/image_generation/imggen_upscale_with_img.py b/genai/image_generation/imggen_upscale_with_img.py deleted file mode 100644 index c3ea9ffa64..0000000000 --- a/genai/image_generation/imggen_upscale_with_img.py +++ /dev/null @@ -1,45 +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 upscale_images(output_file: str) -> Image: - # [START googlegenaisdk_imggen_upscale_with_img] - from google import genai - from google.genai.types import Image - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_file = "output-image.png" - - image = client.models.upscale_image( - model="imagen-4.0-upscale-preview", - image=Image.from_file(location="test_resources/dog_newspaper.png"), - upscale_factor="x2", - ) - - 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_upscale_with_img] - return image.generated_images[0].image - - -if __name__ == "__main__": - upscale_images(output_file="output_folder/dog_newspaper.png") diff --git a/genai/image_generation/imggen_with_txt.py b/genai/image_generation/imggen_with_txt.py deleted file mode 100644 index cfd673042c..0000000000 --- a/genai/image_generation/imggen_with_txt.py +++ /dev/null @@ -1,47 +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 generate_images(output_file: str) -> Image: - # [START googlegenaisdk_imggen_with_txt] - from google import genai - from google.genai.types import GenerateImagesConfig - - client = genai.Client() - - # TODO(developer): Update and un-comment below line - # output_file = "output-image.png" - - image = client.models.generate_images( - model="imagen-4.0-generate-001", - prompt="A dog reading a newspaper", - config=GenerateImagesConfig( - image_size="2K", - ), - ) - - 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_with_txt] - return image.generated_images[0].image - - -if __name__ == "__main__": - generate_images(output_file="output_folder/dog_newspaper.png") diff --git a/genai/image_generation/test_image_generation.py b/genai/image_generation/test_image_generation.py index f5cf14bb62..201f4b74b1 100644 --- a/genai/image_generation/test_image_generation.py +++ b/genai/image_generation/test_image_generation.py @@ -36,10 +36,7 @@ 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 -import imggen_with_txt os.environ["GOOGLE_GENAI_USE_ENTERPRISE"] = "True" os.environ["GOOGLE_CLOUD_LOCATION"] = "us-central1" @@ -63,12 +60,6 @@ def output_gcs_uri() -> str: blob.delete() -def test_img_generation() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "dog_newspaper.png") - response = imggen_with_txt.generate_images(OUTPUT_FILE) - assert response - - def test_img_edit_inpainting_insert_with_mask() -> None: OUTPUT_FILE = os.path.join(RESOURCES, "fruit_edit.png") response = imggen_inpainting_insert_mask_with_txt_img.edit_inpainting_insert_mask(OUTPUT_FILE) @@ -117,13 +108,6 @@ def test_img_edit_mask_free() -> None: 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 - ) - 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 @@ -148,9 +132,3 @@ def test_img_virtual_try_on() -> None: OUTPUT_FILE = os.path.join(RESOURCES, "man_in_sweater.png") response = imggen_virtual_try_on_with_txt_img.virtual_try_on(OUTPUT_FILE) assert response - - -def test_img_upscale() -> None: - OUTPUT_FILE = os.path.join(RESOURCES, "dog_newspaper.png") - response = imggen_upscale_with_img.upscale_images(OUTPUT_FILE) - assert response