POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict
请求 JSON 正文:
{
"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"
}
}
}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[],[],null,["# Upscale a generated, edited, or existing image\n\nYou can use Imagen on Vertex AI's upscaling feature to increase the size of an\nimage without losing quality.\n\nModel versions\n--------------\n\nUpscaling availability is based on model version:\n\nUpscale an image\n----------------\n\nUse the following code samples to upscale an existing, generated, or edited\nimage. \n\n### Console\n\n1. Follow the [generate image with text](/vertex-ai/generative-ai/docs/image/generate-images)\n instructions to generate images.\n\n2. Select the image to upscale.\n\n3. Click\n download**Upscale/export**.\n\n4. Select **Upscale images**.\n\n5. Choose a value from the **Scale factor** (`2x` or `4x`).\n\n6. Click\n download**Export** to save the\n upscaled image.\n\n### REST\n\n\nFor more information about `imagegeneration` model requests, see the\n[`imagegeneration` model API reference](/vertex-ai/generative-ai/docs/model-reference/image-generation).\n\nUpscaling mode is an optional field in the `parameters` object of a JSON\nrequest body. When you upscale an image using the API, specify\n`\"mode\": \"upscale\"` and `upscaleConfig`.\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: Your project's region. For example, `us-central1`, `europe-west2`, or `asia-northeast3`. For a list of available regions, see [Generative AI on Vertex AI locations](/vertex-ai/generative-ai/docs/learn/locations-genai).\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your Google Cloud [project ID](/resource-manager/docs/creating-managing-projects#identifiers).\n- \u003cvar translate=\"no\"\u003eB64_BASE_IMAGE\u003c/var\u003e: The base image to edit or upscale. The image must be specified as a [base64-encoded](/vertex-ai/generative-ai/docs/image/base64-encode) byte string. Size limit: 10 MB.\n- \u003cvar translate=\"no\"\u003eIMAGE_SOURCE\u003c/var\u003e: The Cloud Storage location of the image you want to edit or upscale. For example: `gs://output-bucket/source-photos/photo.png`.\n- \u003cvar translate=\"no\"\u003eUPSCALE_FACTOR\u003c/var\u003e: 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` or `x4` .\n\n\nHTTP method and URL:\n\n```\nPOST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict\n```\n\n\nRequest JSON body:\n\n```\n{\n \"instances\": [\n {\n \"prompt\": \"\",\n \"image\": {\n // use one of the following to specify the image to upscale\n \"bytesBase64Encoded\": \"B64_BASE_IMAGE\"\n \"gcsUri\": \"IMAGE_SOURCE\"\n // end of base image input options\n },\n }\n ],\n \"parameters\": {\n \"sampleCount\": 1,\n \"mode\": \"upscale\",\n \"upscaleConfig\": {\n \"upscaleFactor\": \"UPSCALE_FACTOR\"\n }\n }\n}\n```\n\nTo send your request, choose one of these options: \n\n#### curl\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict\"\n```\n\n#### PowerShell\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"predictions\": [\n {\n \"mimeType\": \"image/png\",\n \"bytesBase64Encoded\": \"iVBOR..[base64-encoded-upscaled-image]...YII=\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\nRead articles about Imagen and other Generative AI on Vertex AI\nproducts:\n\n- [A developer's guide to getting started with Imagen 3 on\n Vertex AI](https://cloud.google.com/blog/products/ai-machine-learning/a-developers-guide-to-imagen-3-on-vertex-ai?e=0?utm_source%3Dlinkedin)\n- [New generative media models and tools, built with and for creators](https://blog.google/technology/ai/google-generative-ai-veo-imagen-3/#veo)\n- [New in Gemini: Custom Gems and improved image generation with\n Imagen 3](https://blog.google/products/gemini/google-gemini-update-august-2024/)\n- [Google DeepMind: Imagen 3 - Our highest quality\n text-to-image model](https://deepmind.google/technologies/imagen-3/)"]]