Skip to content

Commit cff4fe7

Browse files
authored
feat: update generate image sample to 006 (GoogleCloudPlatform#11411)
* feat: update generate image sample to 006 * Trigger Build
1 parent ec184fd commit cff4fe7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

generative_ai/imagen/generate_image.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
--output_file <filepath> --prompt <text>
2020
"""
2121

22-
# [START aiplatform_imagen_generate_image]
22+
# [START generativeaionvertexai_imagen_generate_image]
2323

2424
import argparse
2525

@@ -39,13 +39,26 @@ def generate_image(
3939

4040
vertexai.init(project=project_id, location=location)
4141

42-
model = ImageGenerationModel.from_pretrained("imagegeneration@005")
42+
model = ImageGenerationModel.from_pretrained("imagegeneration@006")
4343

4444
images = model.generate_images(
4545
prompt=prompt,
4646
# Optional parameters
47-
seed=1,
4847
number_of_images=1,
48+
language="en", # prompt language
49+
# By default, a SynthID watermark is added to images, but you can
50+
# disable it. You can't use a seed value and watermark at the same time.
51+
# add_watermark=False,
52+
# seed=100,
53+
aspect_ratio="1:1", # "9:16" "16:9" "4:3" "3:4"
54+
# Adds a filter level to Safety filtering: "block_most" (most strict blocking),
55+
# "block_some" (default), "block_few", or "block_fewest" (available to
56+
# allowlisted users only).
57+
safety_filter_level="block_some",
58+
# Allows generation of people by the model: "dont_allow" (block
59+
# all people), "allow_adult" (default; allow adults but not children),
60+
# "allow_all" (available to allowlisted users only; allow adults and children)
61+
person_generation="allow_adult",
4962
)
5063

5164
images[0].save(location=output_file, include_generation_parameters=True)
@@ -58,7 +71,7 @@ def generate_image(
5871
return images
5972

6073

61-
# [END aiplatform_imagen_generate_image]
74+
# [END generativeaionvertexai_imagen_generate_image]
6275

6376
if __name__ == "__main__":
6477
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)