A partir de 29 de abril de 2025, os modelos Gemini 1.5 Pro e Gemini 1.5 Flash não estarão disponíveis em projetos que não os usaram antes, incluindo novos projetos. Para mais detalhes, consulte Versões e ciclo de vida do modelo.
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
É possível usar o Imagen na Vertex AI para instruir o modelo a personalizar e transformar
os assuntos em uma imagem para um estilo especificado em um comando de texto.
O comando usado com a personalização do Imagen 3 pode afetar a qualidade das imagens geradas. Use os modelos de comando a seguir como ponto de partida para escrever comandos de personalização. Talvez seja necessário enviar várias solicitações para receber o resultado desejado.
Caso de uso
Imagens de referência
Modelo de comando
Exemplo
Personalização de instruções: transferência de estilo
Imagem (1)
Transforme o subject in image [1] para ter um estilo de
${STYLE_DESCRIPTION}. A imagem mostra
${IMAGE_DESCRIPTION}.
Transforme o subject in image [1] para ter um estilo de uma pintura em aquarela da imagem com técnicas soltas, tom suave, cores pastel, pinceladas, delicado, fundo limpo, espontaneidade, desenho de estilo analógico, pintura intrincada e altamente detalhada. A imagem mostra o retrato de uma mulher orgulhosa.
Personalizar usando a personalização de instruções para transferência de estilo
Use os exemplos de código a seguir para especificar o estilo das imagens de saída com base no estilo descrito no comando de texto.
REST
Antes de usar os dados da solicitação,
faça as seguintes substituições:
LOCATION: a região do seu projeto. Por exemplo, us-central1, europe-west2 ou asia-northeast3. Para uma lista
de regiões disponíveis, consulte
IA generativa em locais da Vertex AI.
TEXT_PROMPT: o prompt de texto fornece orientações sobre quais imagens o modelo gera. Para usar a personalização do Imagen 3, inclua o referenceId da imagem ou imagens de referência que você fornecer no formato [$referenceId]. Por exemplo:
Transforme o assunto na imagem [1] para ter um estilo de imagem de vitral digital.
Adicione um chapéu de cowboy vermelho ao gato na imagem [1].
Remova o cachorro corgi na imagem [1].
Mude a bola vermelha na imagem [1] para uma caixa azul.
"referenceId": o ID da imagem de referência ou de uma série de imagens de referência
que correspondem ao mesmo assunto ou estilo.
BASE64_REFERENCE_IMAGE: uma imagem de referência para orientar a geração de imagens. A imagem precisa ser especificada como uma string de bytes codificada em base64.
IMAGE_COUNT: o número de imagens geradas.
Valores inteiros aceitos: 1 a 4. Valor padrão: 4.
Método HTTP e URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict
O exemplo de resposta a seguir é para uma solicitação com "sampleCount": 2. A resposta retorna dois objetos de previsão, com os bytes de imagem gerados codificados em base64.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-04 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/)"]]