Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit dem virtuellen Anprobetool können Sie Bilder von Personen generieren, die Bekleidungsprodukte präsentieren. Sie stellen ein Bild einer Person und ein Beispiel für ein Bekleidungsprodukt bereit und verwenden dann Virtual Try-On, um Bilder der Person zu generieren, die das Produkt trägt.
Unterstützte Modellversionen
Virtual Try-On unterstützt die folgenden Modelle:
virtual-try-on-preview-08-04
Weitere Informationen zu den vom Modell unterstützten Funktionen finden Sie unter Imagen-Modelle.
HTTP-Anfrage
curl-XPOST\-H"Authorization: Bearer $(gcloudauthprint-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 } }}'
Instanzen
personImage
string
Pflichtangabe. Ein Bild einer Person, die das Bekleidungsprodukt anprobiert. Das Bild kann Folgendes zeigen:
Ein bytesBase64Encoded-String, der ein Bild codiert.
Ein gcsUri-String-URI für einen Cloud Storage-Bucket-Speicherort.
productImages
string
Pflichtangabe. Ein Bild eines Produkts, das an einer Person anprobiert werden soll. Das Bild kann Folgendes sein:
Ein bytesBase64Encoded-String, der ein Bild codiert.
Ein gcsUri-String-URI für einen Cloud Storage-Bucket-Speicherort.
Parameter
addWatermark
bool
Optional. Fügen Sie den generierten Bildern ein unsichtbares Wasserzeichen hinzu.
Der Standardwert ist true.
baseSteps
int
Pflichtangabe. Eine Ganzzahl, die die Bildgenerierung steuert. Bei höheren Werten wird eine höhere Qualität gegen eine höhere Latenz eingetauscht.
Ganzzahlwerte größer als 0. Die Standardeinstellung ist 32.
personGeneration
string
Optional. Das Modell darf Bilder von Personen generieren. Folgende Werte werden unterstützt:
"dont_allow": Personen oder Gesichter in Bildern nicht zulassen.
"allow_adult": Nur Generierung von Erwachsenen zulassen.
"allow_all": Ermöglicht die Generierung von Personen aller Altersgruppen.
Der Standardwert ist "allow_adult".
safetySetting
string
Optional. Fügt der Sicherheitsfilterung eine Filterebene hinzu. Folgende Werte werden unterstützt:
"block_medium_and_above": Einige problematische Prompts und Antworten blockieren. Veralteter Wert: "block_some".
"block_only_high": Reduziert die Anzahl der Anfragen, die aufgrund von Sicherheitsfiltern blockiert werden. Kann dazu führen, dass Imagen mehr anstößige Inhalte generiert. Veralteter Wert:
"block_few".
"block_none": Sehr wenige problematische Prompts und Antworten blockieren. Der Zugriff auf diese Funktion ist eingeschränkt. Vorheriger Feldwert: "block_fewest".
Der Standardwert ist "block_medium_and_above".
sampleCount
int
Pflichtangabe. Die Anzahl der zu generierenden Bilder.
Ganzzahliger Wert zwischen 1 und 4 (einschließlich). Der Standardwert ist 1.
seed
Uint32
Optional. Der Zufalls-Seed für die Bildgenerierung. Diese Option ist nicht verfügbar, wenn addWatermark auf true festgelegt ist.
storageUri
string
Optional. Ein String-URI für einen Cloud Storage-Bucket-Speicherort zum Speichern der generierten Bilder.
outputOptions
outputOptions
Optional. Beschreibt das Ausgabeformat des Bildes in einem outputOptions-Objekt.
Objekt für Ausgabeoptionen
Das outputOptions-Objekt beschreibt die Bildausgabe.
Parameter
outputOptions.mimeType
Optional: string
Das Bildausgabeformat. Folgende Werte werden unterstützt:
"image/png": Als PNG-Bild speichern
"image/jpeg": Als JPEG-Bild speichern
Der Standardwert ist "image/png".
outputOptions.compressionQuality
Optional: int
Der Komprimierungsgrad, wenn der Ausgabetyp "image/jpeg" ist. Zulässige Werte sind 0 bis 100. Der Standardwert ist 75.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Virtual Try-On API\n\n| **Preview**\n|\n|\n| This product or feature is a Generative AI Preview offering, subject to\n| the \"Pre-GA Offerings Terms\" of the\n| [Google Cloud Service Specific Terms](/terms/service-terms),\n| as well as the\n| [Additional Terms for Generative AI Preview Products](/trustedtester/aitos). For this\n| Generative AI Preview offering, Customers may elect to use it for\n| production or commercial purposes, or disclose Generated Output to\n| third-parties, and may process personal data as outlined in the\n| [Cloud Data Processing\n| Addendum](/terms/data-processing-addendum),\n| subject to the obligations and restrictions described in the agreement\n| under which you access Google Cloud. Pre-GA products are available \"as is\"\n| and might have limited support. For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nVirtual Try-On lets you generate images of people modeling clothing products. You\nprovide an image of a person and a sample clothing product, and then you use\nVirtual Try-On to generate images of the person wearing the product.\n\nSupported model versions\n------------------------\n\nVirtual Try-On supports the following models:\n\n- `virtual-try-on-preview-08-04`\n\nFor more information about the features that the model supports, see\n[Imagen\nmodels](/vertex-ai/generative-ai/docs/models#imagen-models).\n\nHTTP request\n------------\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n https://\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e-aiplatform.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/publishers/google/models/\u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e:predict \\\n\n -d '{\n \"instances\": [\n {\n \"personImage\": {\n \"image\": {\n // Union field can be only one of the following:\n \"bytesBase64Encoded\": string,\n \"gcsUri\": string,\n }\n },\n \"productImages\": [\n {\n \"image\": {\n // Union field can be only one of the following:\n \"bytesBase64Encoded\": string,\n \"gcsUri\": string,\n }\n }\n ]\n }\n ],\n \"parameters\": {\n \"addWatermark\": boolean,\n \"baseSteps\": integer,\n \"personGeneration\": string,\n \"safetySetting\": string,\n \"sampleCount\": integer,\n \"seed\": integer,\n \"storageUri\": string,\n \"outputOptions\": {\n \"mimeType\": string,\n \"compressionQuality\": integer\n }\n }\n }'\n\n### Output options object\n\nThe `outputOptions` object describes the image output.\n\nSample request\n--------------\n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: The region that your project is located in. For more information about supported regions, see [Generative AI on Vertex AI\n locations](/vertex-ai/generative-ai/docs/learn/locations).\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\"\u003eBASE64_PERSON_IMAGE\u003c/var\u003e: The Base64-encoded image of the person image.\n- \u003cvar translate=\"no\"\u003eBASE64_PRODUCT_IMAGE\u003c/var\u003e: The Base64-encoded image of the product image.\n- \u003cvar translate=\"no\"\u003eIMAGE_COUNT\u003c/var\u003e: The number of images to generate. The accepted range of values is `1` to `4`.\n- \u003cvar translate=\"no\"\u003eGCS_OUTPUT_PATH\u003c/var\u003e: The Cloud Storage path to store the virtual try-on output to.\n\n\nHTTP method and URL:\n\n```\nPOST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-preview-08-04:predict\n```\n\n\nRequest JSON body:\n\n```\n{\n \"instances\": [\n {\n \"personImage\": {\n \"image\": {\n \"bytesBase64Encoded\": \"BASE64_PERSON_IMAGE\"\n }\n },\n \"productImages\": [\n {\n \"image\": {\n \"bytesBase64Encoded\": \"BASE64_PRODUCT_IMAGE\"\n }\n }\n ]\n }\n ],\n \"parameters\": {\n \"sampleCount\": IMAGE_COUNT,\n \"storageUri\": \"GCS_OUTPUT_PATH\"\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://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-preview-08-04: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://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-preview-08-04:predict\" | Select-Object -Expand Content\n```\nThe request returns image objects. In this example, two image objects are returned, with two prediction objects as base64-encoded images.\n\n```\n{\n \"predictions\": [\n {\n \"mimeType\": \"image/png\",\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\"\n },\n {\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\",\n \"mimeType\": \"image/png\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e"]]