You can use Imagen on Vertex AI's upscaling feature to increase the size of an image without losing quality.
Model versions
Upscaling availability is based on model version:
Feature | Imagen (v.002) | Imagen 2 (v.005) | Imagen 2 (v.006) |
---|---|---|---|
Upscaling | ✔ | Not supported | Not supported |
Upscale an image
Use the following code samples to upscale an existing, generated, or edited image.
Console
Follow the generate image with text instructions to generate images.
Select the image to upscale.
Click
Upscale/export.Select Upscale images.
Choose a value from the Scale factor (
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