Supported model versions
Imagen upscale supports the following models:
imagen-4.0-upscale-preview
For more information about the features that the model supports, see Imagen models.
HTTP request
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/MODEL_ID:predict \
-d '{
"instances": [
{
"image": {
// Union field can be only one of the following:
"bytesBase64Encoded": string,
"gcsUri": string,
// End of list of possible types for union field.
},
}
],
"parameters": {
"addWatermark": boolean,
"storageUri": string,
"outputOptions": {
"mimeType": string,
"compressionQuality": integer
},
"upscaleConfig": {
"upscaleFactor": string
}
}
}'
Instances
| Instances | |
|---|---|
|
Union field
The image that you are upscaling. You can provide either a |
|
bytesBase64Encoded |
A bytes base64-encoded string of an image or a video file. |
gcsUri |
A string URI to a Cloud Storage bucket location. |
Parameters
| Parameters | |
|---|---|
addWatermark |
Optional. Add an invisible watermark to the generated images.
The default value is |
storageUri |
Optional. A string URI to a Cloud Storage bucket location that is used to store the generated images. If a Cloud Storage bucket isn't provided, then base64-encoded image bytes are returned in the response. |
outputOptions |
Optional. Describes the output image format in an |
upscaleConfig.upscaleFactor |
The scaling factor for the upscaled image. The following values are accepted:
|
Output options object
The outputOptions object describes the image output.
| Parameters | |
|---|---|
outputOptions.mimeType |
Optional: The image output format. The following values are supported:
The default value is |
outputOptions.compressionQuality |
Optional:
The level of compression if the output type is
|
Sample request
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. -
PROJECT_ID: Your Google Cloud project ID. -
BASE64_SUBJECT_IMAGE: A base64-encoded image of the subject image. -
ADD_WATERMARK: An optional Boolean value. Set totrueto enable watermarked images, orfalseto disable watermarked images. The default value istrue. -
GCS_IMAGE_PATH: A Cloud Storage path to an image file. -
GCS_OUTPUT_PATH: the Cloud Storage path to store the generated output to. -
OUTPUT_MIMETYPE: An optional string that defines the output file type of the image. The following values are accepted:"image/png"or"image/jpeg". The default is"image/png". -
COMPRESSION_QUALITY: An optional integer value that specifies the level of detail that the model preserves for JPEG images. The following range of values are accepted:0-100. The higher value specifies a higher compression level. The default is75. -
UPSCALE_FACTOR: The scaling factor for the upscaled image. The following values are accepted:"x2""x3""x4"
HTTP method and URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview:predict
Request JSON body:
{
"instances": [
{
"image": {
// use one of the following to specify the image to upscale
"bytesBase64Encoded": "BASE64_SUBJECT_IMAGE"
"gcsUri": "GCS_IMAGE_PATH"
// end of base image input options
},
}
],
"parameters": {
"addWatermark": ADD_WATERMARK, // Optional
"storageUri": "GCS_OUTPUT_PATH",
"outputOptions": { // Optional
"mimeType": "OUTPUT_MIMETYPE", // Optional
"compressionQuality": COMPRESSION_QUALITY // Optional
},
"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://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview: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/imagen-4.0-upscale-preview:predict" | Select-Object -Expand Content
{
"predictions": [
{
"mimeType": "image/png",
"bytesBase64Encoded": "BASE64_IMG_BYTES"
}
]
}