19
19
--output_file <filepath> --prompt <text>
20
20
"""
21
21
22
- # [START aiplatform_imagen_generate_image ]
22
+ # [START generativeaionvertexai_imagen_generate_image ]
23
23
24
24
import argparse
25
25
@@ -39,13 +39,26 @@ def generate_image(
39
39
40
40
vertexai .init (project = project_id , location = location )
41
41
42
- model = ImageGenerationModel .from_pretrained ("imagegeneration@005 " )
42
+ model = ImageGenerationModel .from_pretrained ("imagegeneration@006 " )
43
43
44
44
images = model .generate_images (
45
45
prompt = prompt ,
46
46
# Optional parameters
47
- seed = 1 ,
48
47
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" ,
49
62
)
50
63
51
64
images [0 ].save (location = output_file , include_generation_parameters = True )
@@ -58,7 +71,7 @@ def generate_image(
58
71
return images
59
72
60
73
61
- # [END aiplatform_imagen_generate_image ]
74
+ # [END generativeaionvertexai_imagen_generate_image ]
62
75
63
76
if __name__ == "__main__" :
64
77
parser = argparse .ArgumentParser ()
0 commit comments