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 > Media Studio page.

    Go to Media Studio

  2. Click Imagen. The Imagen Media Studio image generation page is displayed.

  3. 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.

  4. 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".

  5. 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 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"
    }
  ]
}