Vertex AI の Imagen を使用して画像をアップスケールすると、画質を損なうことなく画像のサイズを大きくできます。
imagen-4.0-upscale-preview は、プレビュー版で画像のアップスケーリングをサポートしています。
始める前に
- 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. -
環境の認証を設定します。
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
このページの REST API サンプルをローカル開発環境で使用するには、gcloud CLI に指定した認証情報を使用します。
Google Cloud CLI をインストールします。 インストール後、次のコマンドを実行して Google Cloud CLI を初期化します。
gcloud init外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
詳細については、 Google Cloud 認証ドキュメントの REST を使用して認証するをご覧ください。
画像をアップスケールする
コンソール
Google Cloud コンソールで、[Vertex AI] > [Vertex AI Studio] > [メディアを生成] ページに移動します。
[Imagen] をクリックします。[メディア プレイグラウンド] ページが表示されます。
[画像をアップロード] をクリックし、アップロードする画像を選択します。
[画像をエクスポート]、[画像をアップスケールもする] の順にクリックします。
スケーリング ファクタを選択して、[エクスポート] をクリックします。
アップスケールされた画像に電子透かしが自動的に追加されます。 Google Cloud コンソールでは、画像アップスケールの電子透かしを無効にすることはできません。
REST
リクエストのデータを使用する前に、次のように置き換えます。
-
REGION: プロジェクトが配置されているリージョン。サポートされているリージョンの詳細については、Vertex AI の生成 AI のロケーションをご覧ください。 -
PROJECT_ID: 実際の Google Cloud プロジェクト ID。 -
BASE64_SUBJECT_IMAGE: Base64 でエンコードされた被写体の画像。 -
ADD_WATERMARK: 省略可能なブール値。透かし入りの画像を有効にするにはtrueに、透かし入りの画像を無効にするにはfalseに設定します。デフォルト値はtrueです。 -
GCS_IMAGE_PATH: 画像ファイルへの Cloud Storage パス。 -
GCS_OUTPUT_PATH: 生成された出力を保存する Cloud Storage パス。 -
OUTPUT_MIMETYPE: 画像の出力ファイル形式を定義する文字列(省略可)。使用できる値は、"image/png"または"image/jpeg"です。デフォルトは"image/png"です。 -
COMPRESSION_QUALITY: モデルが JPEG 画像に対して保持する詳細レベルを指定する省略可能な整数値。指定できる値の範囲は0~100です。値が大きいほど、圧縮レベルが高くなります。デフォルトは75です。 -
UPSCALE_FACTOR: アップスケールされた画像のスケーリング ファクタ。指定できる値は次のとおりです。"x2""x3""x4"
HTTP メソッドと URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview:predict
リクエストの本文(JSON):
{ "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" } } }リクエストを送信するには、次のいずれかのオプションを選択します。
リクエストは画像オブジェクトを返します。この例では、画像オブジェクトが base64 でエンコードされた画像を含む予測オブジェクトとして返されます。curl
リクエスト本文を
request.jsonという名前のファイルに保存して、次のコマンドを実行します。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
リクエスト本文を
request.jsonという名前のファイルに保存して、次のコマンドを実行します。$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" } ] }次のステップ
Imagen や Vertex AI のその他の生成 AI プロダクトに関する次の記事を読む。
- Vertex AI で Imagen 3 を使い始めるためのデベロッパー ガイド
- クリエイターとともにクリエイターのために構築された、新しい生成メディアのモデルとツール
- Gemini の新機能: カスタム Gem と Imagen 3 による画像生成の改善
- Google DeepMind: Imagen 3 - 最も高い品質水準の Text-to-Image モデル
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-11-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-11-27 UTC。"],[],[]]