Anda dapat menggunakan Imagen di Vertex AI untuk meningkatkan skala gambar, yang akan meningkatkan ukurannya tanpa mengurangi kualitas gambar.
imagen-4.0-upscale-preview mendukung peningkatan kualitas gambar di
Pratinjau.
Sebelum memulai
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
Siapkan autentikasi untuk lingkungan Anda.
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
REST
Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, gunakan kredensial yang Anda berikan ke gcloud CLI.
Instal Google Cloud CLI. Setelah penginstalan, inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
gcloud initJika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
Untuk mengetahui informasi selengkapnya, lihat Melakukan autentikasi untuk menggunakan REST dalam dokumentasi autentikasi Google Cloud .
Meningkatkan skala gambar
Konsol
Di konsol Google Cloud , buka halaman Vertex AI > Vertex AI Studio > Generate media.
Klik Imagen. Halaman Media playground akan ditampilkan.
Klik upload gambar, lalu pilih gambar yang akan diupload.
Klik Ekspor gambar, lalu Tingkatkan skala gambar juga.
Pilih faktor penskalaan, lalu klik Ekspor.
Watermark digital otomatis ditambahkan ke gambar yang di-upgrade. Anda tidak dapat menonaktifkan watermark digital untuk peningkatan skala gambar menggunakan konsol Google Cloud .
REST
Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
-
REGION: Region tempat project Anda berada. Untuk mengetahui informasi selengkapnya tentang region yang didukung, lihat Lokasi AI Generatif di Vertex AI. -
PROJECT_ID: Google Cloud Project ID Anda. -
BASE64_SUBJECT_IMAGE: Gambar subjek yang dienkode base64. -
ADD_WATERMARK: Nilai Boolean opsional. Setel ketrueuntuk mengaktifkan gambar yang memiliki watermark, ataufalseuntuk menonaktifkan gambar yang memiliki watermark. Nilai defaultnya adalahtrue. -
GCS_IMAGE_PATH: Jalur Cloud Storage ke file gambar. -
GCS_OUTPUT_PATH: jalur Cloud Storage untuk menyimpan output yang dihasilkan. -
OUTPUT_MIMETYPE: String opsional yang menentukan jenis file output gambar. Nilai berikut diterima:"image/png"atau"image/jpeg". Defaultnya adalah"image/png". -
COMPRESSION_QUALITY: Nilai bilangan bulat opsional yang menentukan tingkat detail yang dipertahankan model untuk gambar JPEG. Rentang nilai berikut diterima:0-100. Nilai yang lebih tinggi menentukan tingkat kompresi yang lebih tinggi. Defaultnya adalah75. -
UPSCALE_FACTOR: Faktor penskalaan untuk gambar yang di-upscale. Resolusi output akhir gambar setelah menerapkan faktor peningkatan kualitas tidak boleh melebihi 17 megapiksel. Nilai berikut diterima:"x2""x3""x4"
Metode HTTP dan URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview:predict
Meminta isi JSON:
{ "instances": [ { "prompt": "Upscale the image", "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": { "mode": "upscale", "storageUri": "GCS_OUTPUT_PATH", "outputOptions": { "mimeType": "OUTPUT_MIMETYPE", "compressionQuality": COMPRESSION_QUALITY }, "upscaleConfig": { "upscaleFactor": "UPSCALE_FACTOR" } } }Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:
Permintaan ini akan menampilkan objek gambar. Dalam contoh ini, objek gambar ditampilkan sebagai objek prediksi dengan gambar berenkode base64.curl
Simpan isi permintaan dalam file bernama
request.json, dan jalankan perintah berikut: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
Simpan isi permintaan dalam file bernama
request.json, dan jalankan perintah berikut:$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" } ] }Langkah berikutnya
Baca artikel tentang Imagen dan produk AI Generatif lainnya di Vertex AI:
- Panduan developer untuk mulai menggunakan Imagen 3 di Vertex AI
- Model dan alat media generatif baru, dibuat dengan dan untuk kreator
- Baru di Gemini: Gem Kustom dan peningkatan pembuatan gambar dengan Imagen 3
- Google DeepMind: Imagen 3 - Model text-to-image berkualitas tertinggi kami
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-12-16 UTC.
[[["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-12-16 UTC."],[],[]]