This guide shows you how to increase the size of an image by using the upscaling feature of Imagen on Vertex AI. Upscaling increases image dimensions without a significant loss in quality.
The following diagram summarizes the overall workflow:
Model versions
The availability of the upscaling feature depends on the model version:
Feature | Imagen (v.002) | Imagen 2 (v.005) | Imagen 2 (v.006) |
---|---|---|---|
Upscaling | ✔ | Not supported | Not supported |
Upscale an image
You can upscale an image using the Google Cloud console or the REST API.
Method | Description | Use Case |
---|---|---|
Google Cloud console | A user interface for upscaling individual images. | Best for quick experiments, visual confirmation, or one-off upscaling tasks without writing code. |
REST API | A programmatic interface to send upscaling requests to the Imagen on Vertex AI model. | Best for integrating image upscaling into applications or automating the processing of multiple images. |
The following tabs show you how to upscale an existing, generated, or edited image.
Console
Follow these steps to upscale an image in the Google Cloud console immediately after you generate it.
- Generate one or more images. For instructions, see Generate images from text prompts.
- From the generated images, select the one you want to upscale.
- Click Upscale/export.
- Select Upscale images.
- From the Scale factor list, choose
2x
or4x
. - Click Export to save the upscaled image.
REST
For more information about imagegeneration
model requests, see the
imagegeneration
model API reference.
Upscaling mode is an optional field in the parameters
object of a JSON request body. When you upscale an image using the API, specify "mode": "upscale"
and upscaleConfig
.
Before using any of the request data, make the following replacements:
- LOCATION: Your project's region. For example,
us-central1
,europe-west2
, orasia-northeast3
. For a list of available regions, see Generative AI on Vertex AI locations. - PROJECT_ID: Your Google Cloud project ID.
- B64_BASE_IMAGE: The base image to edit or upscale. The image must be specified as a base64-encoded byte string. Size limit: 10 MB.
- IMAGE_SOURCE: The Cloud Storage location of the image you
want to edit or upscale. For example:
gs://output-bucket/source-photos/photo.png
. - UPSCALE_FACTOR: Optional. The factor to which the image will be upscaled. If not
specified, the upscale factor will be determined from the longer side of the input image and
sampleImageSize
. Available values:x2
orx4
.
HTTP method and URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict
Request JSON body:
{ "instances": [ { "prompt": "", "image": { // use one of the following to specify the image to upscale "bytesBase64Encoded": "B64_BASE_IMAGE" "gcsUri": "IMAGE_SOURCE" // end of base image input options }, } ], "parameters": { "sampleCount": 1, "mode": "upscale", "upscaleConfig": { "upscaleFactor": "UPSCALE_FACTOR" } } }
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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002: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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "predictions": [ { "mimeType": "image/png", "bytesBase64Encoded": "iVBOR..[base64-encoded-upscaled-image]...YII=" } ] }
What's next
Read articles about Imagen and other Generative AI on Vertex AI products:
- A developer's guide to getting started with Imagen 3 on Vertex AI
- New generative media models and tools, built with and for creators
- New in Gemini: Custom Gems and improved image generation with Imagen 3
- Google DeepMind: Imagen 3 - Our highest quality text-to-image model