1919 --output_file <filepath> --prompt <text>
2020"""
2121
22- # [START aiplatform_imagen_generate_image ]
22+ # [START generativeaionvertexai_imagen_generate_image ]
2323
2424import 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
6376if __name__ == "__main__" :
6477 parser = argparse .ArgumentParser ()
0 commit comments