「バーチャルでお試し」では、衣料品を着用している人物の画像を生成できます。人物の画像と衣料品のサンプル画像を提供すると、「バーチャルでお試し」機能がその衣料品を着用している人物の画像を生成します。
サポートされているモデル バージョン
バーチャルでお試しは、次のモデルに対応しています。
virtual-try-on-preview-08-04
モデルでサポートされている機能の詳細については、Imagen モデルをご覧ください。
HTTP リクエスト
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:predict \
-d '{
"instances": [
{
"personImage": {
"image": {
// Union field can be only one of the following:
"bytesBase64Encoded": string,
"gcsUri": string,
}
},
"productImages": [
{
"image": {
// Union field can be only one of the following:
"bytesBase64Encoded": string,
"gcsUri": string,
}
}
]
}
],
"parameters": {
"addWatermark": boolean,
"baseSteps": integer,
"personGeneration": string,
"safetySetting": string,
"sampleCount": integer,
"seed": integer,
"storageUri": string,
"outputOptions": {
"mimeType": string,
"compressionQuality": integer
}
}
}'
インスタンス | |
---|---|
|
必須。衣料品を試着する人物の画像。次のいずれかになります。
|
|
必須。人物に試着させる商品の画像。次のいずれかになります。
|
パラメータ | |
---|---|
addWatermark |
省略可。生成された画像に目に見えない透かしを追加します。
デフォルト値は |
|
必須。画像生成を制御する整数。ステップ数を増やすと、レイテンシが増加しますが、画質が向上します。
|
personGeneration |
省略可。モデルによって人物の画像が生成されるようにします。次の値を使用できます。
デフォルト値は |
safetySetting |
省略可。安全フィルタリングにフィルタレベルを追加します。次の値を使用できます。
デフォルト値は |
|
必須。生成する画像の数。
|
seed |
省略可。画像生成用の乱数シード。 |
storageUri |
省略可。生成された画像を保存する Cloud Storage バケットの場所への文字列 URI。 |
outputOptions |
省略可。 |
出力オプション オブジェクト
outputOptions
オブジェクトは画像出力を記述します。
パラメータ | |
---|---|
outputOptions.mimeType |
省略可: 画像出力形式。次の値を使用できます。
デフォルト値は |
outputOptions.compressionQuality |
省略可:
出力タイプが |
リクエストの例
REST
リクエストのデータを使用する前に、次のように置き換えます。
- REGION: プロジェクトが配置されているリージョン。サポートされているリージョンの詳細については、Vertex AI の生成 AI のロケーションをご覧ください。
- PROJECT_ID: 実際の Google Cloud プロジェクト ID。
- BASE64_PERSON_IMAGE: base64 でエンコードされた人物の画像。
- BASE64_PRODUCT_IMAGE: base64 でエンコードされた商品の画像。
-
IMAGE_COUNT: 生成する画像の数。指定できる値の範囲は
1
~4
です。 - GCS_OUTPUT_PATH: 「バーチャルでお試し」の出力を保存する Cloud Storage パス。
HTTP メソッドと URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-preview-08-04:predict
リクエストの本文(JSON):
{ "instances": [ { "personImage": { "image": { "bytesBase64Encoded": "BASE64_PERSON_IMAGE" } }, "productImages": [ { "image": { "bytesBase64Encoded": "BASE64_PRODUCT_IMAGE" } } ] } ], "parameters": { "sampleCount": IMAGE_COUNT, "storageUri": "GCS_OUTPUT_PATH" } }
リクエストを送信するには、次のいずれかのオプションを選択します。
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/virtual-try-on-preview-08-04: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/virtual-try-on-preview-08-04:predict" | Select-Object -Expand Content
{ "predictions": [ { "mimeType": "image/png", "bytesBase64Encoded": "BASE64_IMG_BYTES" }, { "bytesBase64Encoded": "BASE64_IMG_BYTES", "mimeType": "image/png" } ] }