Set output resolution

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

  1. In the Google Cloud console, go to the Vertex AI > Vertex AI Studio page.

    Go to Vertex AI Studio

  2. Click Generate media .

  3. Click Image .

  4. From the Tasklist, select Text-to-image.

  5. From the Modellist, select the Imagen model to use.

  6. In the Promptbox, enter a prompt that describes how to edit the image.

  7. Click chevron_forward Parameters, and then adjust the following options:

    • Aspect ratio: Choose an aspect ratio from the available options.
    • Number of results: Adjust the slider to select 1 to 4 generated images.
    • Output resolution: Choose an output resolution from the available options.
  8. Click Run.

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 using sampleImageSize :
    • 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 is 1 to 4 .

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
The request returns image objects. In this example, two image objects are returned, with two prediction objects as base64-encoded images.
{
  "predictions": [
    {
      "mimeType": "image/png",
      "bytesBase64Encoded": " BASE64_IMG_BYTES 
"
    },
    {
      "bytesBase64Encoded": " BASE64_IMG_BYTES 
",
      "mimeType": "image/png"
    }
  ]
}
Create a Mobile Website
View Site in Mobile | Classic
Share by: