Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit Imagen on Vertex AI können Sie dem Modell Anweisungen geben, wie die Motive in einem Bild an einen Stil angepasst und transformiert werden sollen, den Sie in einem Text-Prompt angeben.
Der Prompt, den Sie für die Imagen 3-Anpassung verwenden, kann sich auf die Qualität der generierten Bilder auswirken. Verwenden Sie die folgenden Prompt-Vorlagen als Ausgangspunkt für das Schreiben von Anpassungs-Prompts. Möglicherweise müssen Sie mehrere Anfragen senden, um die gewünschte Ausgabe zu erhalten.
Anwendungsfall
Referenzbilder
Prompt-Vorlage
Beispiel
Anpassung von Prompts – Stilübertragung
Bild (1)
Transformiere das subject in image [1] in den Stil ${STYLE_DESCRIPTION}. Das Bild zeigt
${IMAGE_DESCRIPTION}.
Verwandle das subject in image [1] in ein Aquarellgemälde mit lockeren Aquarelltechniken, sanften Tönen, Pastellfarben, Pinselstrichen, einem zarten, sauberen Hintergrund, Spontaneität, einer analogen Zeichnung und einem aufwendigen, sehr detaillierten Gemälde. Das Bild zeigt ein Porträt einer stolzen Frau.
Mit der Anleitung zur Anpassung für Stilübertragung anpassen
Verwenden Sie die folgenden Codebeispiele, um den Stil der Ausgabebilder basierend auf dem im Textprompt beschriebenen Stil festzulegen.
REST
Ersetzen Sie diese Werte in den folgenden Anfragedaten:
LOCATION: Die Region Ihres Projekts. Beispiel: us-central1, europe-west2 oder asia-northeast3. Eine Liste der verfügbaren Regionen finden Sie unter Generative AI an Vertex AI-Standorten.
TEXT_PROMPT ist der Text-Prompt, der bestimmt, welche Bilder das Modell generiert. Wenn Sie die Imagen 3-Anpassung verwenden möchten, geben Sie die referenceId des Referenzbilds oder der Referenzbilder, die Sie bereitstellen, im Format [$referenceId] an. Beispiel:
Transformiere das Motiv auf Bild [1] in einen Digital Stained Glass-Bildstil.
Füge der Katze im Bild [1] einen roten Cowboyhut hinzu.
Entferne den Corgi auf dem Bild [1].
Ändere den roten Ball im Bild [1] in einen blauen Kasten.
"referenceId": Die ID des Referenzbilds oder die ID einer Reihe von Referenzbildern, die demselben Motiv oder Stil entsprechen.
BASE64_REFERENCE_IMAGE: Ein Referenzbild, das als Grundlage für die Bildgenerierung dient. Das Bild muss als base64-codierter Bytestring angegeben werden.
IMAGE_COUNT ist die Anzahl der generierten Bilder.
Zulässige Ganzzahlwerte: 1–4. Standardwert: 4
HTTP-Methode und URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict
Die folgende Beispielantwort bezieht sich auf eine Anfrage mit "sampleCount": 2. Die Antwort gibt zwei Vorhersageobjekte zurück, wobei die generierten Bildbyte base64-codiert sind.
[[["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-08-25 (UTC)."],[],[],null,["# Instruct Customization\n\n| **Caution:** Starting on June 24, 2025, Imagen versions 1 and 2 are deprecated. Imagen models `imagegeneration@002`, `imagegeneration@005`, and `imagegeneration@006` will be removed on September 24, 2025 . For more information about migrating to Imagen 3, see [Migrate to\n| Imagen 3](/vertex-ai/generative-ai/docs/image/migrate-to-imagen-3).\n\n\u003cbr /\u003e\n\nYou can use Imagen on Vertex AI to instruct the model how to customize and transform\nthe subjects in an image to a style that you specify in a text prompt.\n\n\n[View Imagen for Editing and Customization model card](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/imagen-3.0-capability-001)\n\nCustomization prompt writing\n----------------------------\n\nThe prompt that you use with Imagen 3 Customization might affect the\nquality of your generated images. Use the following prompt templates as a\nstarting point for writing customization prompts. You might need to send several\nrequests to get your targeted output.\n\nCustomize using instruct customization for style transfer\n---------------------------------------------------------\n\n\n| To see an example of Imagen 3 Customization,\n| run the \"Imagen 3 Customized Images\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/vision/getting-started/imagen3_customization.ipynb)\n|\n|\n| \\|\n|\n| [Open in Colab Enterprise](https://console.cloud.google.com/vertex-ai/colab/import/https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fvision%2Fgetting-started%2Fimagen3_customization.ipynb)\n|\n|\n| \\|\n|\n| [Open\n| in Vertex AI Workbench](https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fgenerative-ai%2Fmain%2Fvision%2Fgetting-started%2Fimagen3_customization.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/vision/getting-started/imagen3_customization.ipynb)\n\n\u003cbr /\u003e\n\nUse the following code samples to specify the style of the output images based\non the style described in the text prompt. \n\n### REST\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nBefore using any of the request data,\nmake the following replacements:\n\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\"\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\"\u003eTEXT_PROMPT\u003c/var\u003e: The text prompt guides what images the model generates. To use Imagen 3 Customization, include the `referenceId` of the reference image or images you provide in the format \u003cvar translate=\"no\"\u003e[$referenceId]\u003c/var\u003e. For example:\n - *Transform the subject in image \u003cvar translate=\"no\"\u003e[1]\u003c/var\u003e to have a Digital Stained Glass style\n image style.*\n - *Add a red cowboy hat to the cat in the image \u003cvar translate=\"no\"\u003e[1]\u003c/var\u003e.*\n - *Remove the corgi dog in the image \u003cvar translate=\"no\"\u003e[1]\u003c/var\u003e.*\n - *Change the red ball in the image \u003cvar translate=\"no\"\u003e[1]\u003c/var\u003e to a blue box.*\n- `\"referenceId\"`: The ID of the reference image, or the ID for a series of reference images that correspond to the same subject or style.\n- \u003cvar translate=\"no\"\u003eBASE64_REFERENCE_IMAGE\u003c/var\u003e: A reference image to guide image generation. The image must be specified as a [base64-encoded](/vertex-ai/generative-ai/docs/image/base64-encode) byte string.\n- \u003cvar translate=\"no\"\u003eIMAGE_COUNT\u003c/var\u003e: The number of generated images. Accepted integer values: 1-4. Default value: 4.\n\n\nHTTP method and URL:\n\n```\nPOST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict\n```\n\n\nRequest JSON body:\n\n```\n{\n \"instances\": [\n {\n \"prompt\": \"TEXT_PROMPT\",\n \"referenceImages\": [\n {\n \"referenceType\": \"REFERENCE_TYPE_RAW\",\n \"referenceId\": 1,\n \"referenceImage\": {\n \"bytesBase64Encoded\": \"BASE64_REFERENCE_IMAGE\"\n }\n }\n ]\n }\n ],\n \"parameters\": {\n \"sampleCount\": IMAGE_COUNT\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/imagen-3.0-capability-001: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/imagen-3.0-capability-001:predict\" | Select-Object -Expand Content\n```\nThe following sample response is for a request with `\"sampleCount\": 2`. The response returns two prediction objects, with the generated image bytes base64-encoded.\n\n```\n{\n \"predictions\": [\n {\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\",\n \"mimeType\": \"image/png\"\n },\n {\n \"mimeType\": \"image/png\",\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\nProduct usage\n-------------\n\nTo view usage standards and content restrictions associated with\nImagen on Vertex AI, see the\n[usage guidelines](/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#imagen-guidelines).\n\nModel versions\n--------------\n\nThere are multiple image generation models that you can use. For more\ninformation, see [Imagen\nmodels](/vertex-ai/generative-ai/docs/models#imagen-models).\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/)"]]