Mulai 29 April 2025, model Gemini 1.5 Pro dan Gemini 1.5 Flash tidak tersedia di project yang belum pernah menggunakan model ini, termasuk project baru. Untuk mengetahui detailnya, lihat Versi dan siklus proses model.
Mode peningkatan skala adalah kolom opsional dalam objek parameters dari isi permintaan JSON. Saat Anda meningkatkan skala gambar menggunakan API, tentukan
"mode": "upscale" dan upscaleConfig.
Sebelum menggunakan salah satu data permintaan,
lakukan penggantian berikut:
LOCATION: Region project Anda. Misalnya,
us-central1, europe-west2, atau asia-northeast3. Untuk mengetahui daftar
region yang tersedia, lihat
Lokasi AI Generatif di Vertex AI.
B64_BASE_IMAGE: Gambar dasar yang akan diedit atau di-upscale. Gambar
harus ditentukan sebagai string byte berenkode base64. Batas ukuran: 10 MB.
IMAGE_SOURCE: Lokasi Cloud Storage gambar yang ingin Anda edit atau tingkatkan kualitasnya. Contoh: gs://output-bucket/source-photos/photo.png.
UPSCALE_FACTOR: Opsional. Faktor yang akan digunakan untuk meningkatkan skala gambar. Jika tidak ditentukan, faktor peningkatan kualitas akan ditentukan dari sisi terpanjang gambar input dan sampleImageSize. Nilai yang tersedia: x2 atau x4 .
Metode HTTP dan URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagegeneration@002:predict
Isi JSON permintaan:
{
"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"
}
}
}
Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
curl
Simpan isi permintaan dalam file bernama request.json,
dan jalankan perintah berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-25 UTC."],[],[],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/)"]]