Imagen on Vertex AI lets you set the output resolution of generated images when you use the following Imagen 4 models:
imagen-4.0-generate-001
imagen-4.0-ultra-generate-001
Console
In the Google Cloud console, go to the Vertex AI > Media Studio page.
Click Imagen. The Imagen Media Studio image generation page is displayed.
In the Settings panel, adjust the following options:
Model: Choose a model from the available options.
For more information about available models, see Imagen models.
Output resolution: Choose an output resolution from the available options.
In the Write your prompt box, enter your text prompt that describes the images to generate. For example,
"small boat on water in the morning watercolor illustration"
.Click
Generate.
REST
Before using any of the request data, make the following replacements:
-
REGION
: The region that your project is located in. For more information about supported regions, see Generative AI on Vertex AI locations. -
TEXT_PROMPT
: The text prompt to use to generate images. -
PROJECT_ID
: Your Google Cloud project ID. -
MODEL_VERSION
: The Imagen model version to use. The following are accepted values when usingsampleImageSize
:imagen-4.0-generate-001
imagen-4.0-ultra-generate-001
-
IMAGE_RESOLUTION
: The output image resolution. The following are accepted:"1K"
"2K"
The default setting is
"1K"
. -
IMAGE_COUNT
: The number of images to generate. The accepted range of values is1
to4
.
HTTP method and URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/MODEL_VERSION:predict
Request JSON body:
{ "instances": [ { "prompt": "TEXT_PROMPT" } ], "parameters": { "sampleImageSize": "IMAGE_RESOLUTION", "sampleCount": IMAGE_COUNT } }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/MODEL_VERSION:predict"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/MODEL_VERSION:predict" | Select-Object -Expand Content
{ "predictions": [ { "mimeType": "image/png", "bytesBase64Encoded": "BASE64_IMG_BYTES" }, { "bytesBase64Encoded": "BASE64_IMG_BYTES", "mimeType": "image/png" } ] }