A partire dal 29 aprile 2025, i modelli Gemini 1.5 Pro e Gemini 1.5 Flash non sono disponibili nei progetti che non li hanno mai utilizzati, inclusi i nuovi progetti. Per maggiori dettagli, vedi Versioni e ciclo di vita dei modelli.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'anteprima di Gemini 2.5 Flash Image supporta più tipi di modifica delle immagini.
Modifica delle immagini
L'anteprima pubblica di Gemini 2.5 Flash Image per la generazione di immagini
(gemini-2.5-flash-image-preview) supporta la possibilità di modificare
le immagini oltre a generarle. Con questa release di anteprima pubblica, l'immagine Gemini 2.5 Flash supporta la modifica migliorata delle immagini e la modifica multi-turno e contiene filtri di sicurezza aggiornati che offrono un'esperienza utente più flessibile e meno restrittiva.
Supporta le seguenti modalità e funzionalità:
Modifica delle immagini (da testo a immagine e da immagine a immagine)
Prompt di esempio: "Modifica questa immagine per farla sembrare un cartone animato"
Prompt di esempio: [immagine di un gatto] + [immagine di un cuscino] +
"Crea un punto croce del mio gatto su questo cuscino".
Modifica di immagini in più passaggi (chat)
Prompt di esempio: [carica un'immagine di un'auto blu.] "Trasforma
questa auto in una cabriolet." "Ora cambia il colore in giallo."
"Aggiungi uno spoiler".
Fai clic su Cambia modello e seleziona gemini-2.5-flash-image-preview
dal menu.
Nel riquadro Output, seleziona Immagine e testo dal menu a discesa.
Fai clic su Inserisci contenuti multimediali (add_photo_alternate) e
seleziona un'origine dal menu, poi segui le istruzioni della finestra di dialogo.
Scrivi le modifiche che vuoi apportare all'immagine nell'area di testo Scrivi un prompt.
Fai clic sul pulsante Prompt (send).
Gemini genererà una versione modificata dell'immagine fornita in base alla tua descrizione. Questa procedura dovrebbe richiedere pochi secondi, ma potrebbe essere
più lenta a seconda della capacità.
Imposta le variabili di ambiente per utilizzare l'SDK Gen AI con Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
fromgoogleimportgenaifromgoogle.genai.typesimportGenerateContentConfig,ModalityfromPILimportImagefromioimportBytesIOclient=genai.Client()# Using an image of Eiffel tower, with fireworks in the background.image=Image.open("test_resources/example-image-eiffel-tower.png")response=client.models.generate_content(model="gemini-2.5-flash-image-preview",contents=[image,"Edit this image to make it look like a cartoon."],config=GenerateContentConfig(response_modalities=[Modality.TEXT,Modality.IMAGE]),)forpartinresponse.candidates[0].content.parts:ifpart.text:print(part.text)elifpart.inline_data:image=Image.open(BytesIO((part.inline_data.data)))image.save("output_folder/bw-example-image.png")# Example response:# Here's the cartoon-style edit of the image:# Cartoon-style edit:# - Simplified the Eiffel Tower with bolder lines and slightly exaggerated proportions.# - Brightened and saturated the colors of the sky, fireworks, and foliage for a more vibrant, cartoonish look.# ....
REST
Esegui questo comando nel terminale per creare o sovrascrivere questo file nella
directory corrente:
curl-XPOST\-H"Authorization: Bearer $(gcloudauthprint-access-token)"\-H"Content-Type: application/json"\https://${API_ENDPOINT}:generateContent\-d'{ "contents": { "role": "USER", "parts": [ {"file_data": { "mime_type": "image/jpg", "file_uri": "<var>FILE_NAME</var>" } }, {"text": "Convert this photo to black and white, in a cartoonish style."}, ] }, "generation_config": { "response_modalities": ["TEXT", "IMAGE"], }, "safetySettings": { "method": "PROBABILITY", "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" }, }'2>/dev/null>response.json
Gemini genererà un'immagine in base alla tua descrizione. Questa
procedura dovrebbe richiedere alcuni secondi, ma potrebbe essere relativamente più lenta a seconda
della capacità.
Modifica di immagini in più passaggi
L'anteprima delle immagini di Gemini 2.5 Flash supporta anche la modifica in più passaggi migliorata, consentendoti
di rispondere al modello con le modifiche dopo aver ricevuto una risposta con un'immagine modificata.
In questo modo potrai continuare a modificare l'immagine in modo conversazionale.
Tieni presente che è consigliabile limitare la dimensione totale del file di richiesta a un massimo di 50 MB.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Edit images with Gemini\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\n\u003cbr /\u003e\n\nGemini 2.5 Flash Image Preview supports multiple types of image editing.\n| **Note:** Image editing and multi-turn image editing are only supported in `gemini-2.5-flash-image-preview`, not `gemini-2.5-flash`.\n\nImage editing\n-------------\n\n| To see an example of image editing with Gemini,\n| run the \"Gemini 2.5 Flash Image Generation in Vertex AI\" notebook in one of the following\n| environments:\n|\n| [Open in Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.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%2Fgemini%2Fgetting-started%2Fintro_gemini_2_5_image_gen.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%2Fgemini%2Fgetting-started%2Fintro_gemini_2_5_image_gen.ipynb)\n|\n|\n| \\|\n|\n| [View on GitHub](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.ipynb)\n\nGemini 2.5 Flash Image's public preview for image generation\n(`gemini-2.5-flash-image-preview`) supports the ability to edit\nimages in addition generating them. With this public preview release,\nGemini 2.5 Flash Image supports improved editing of images and\nmulti-turn editing and contains updated safety filters that provide a more\nflexible and less restrictive user experience.\n\nIt supports the following modalities and capabilities:\n\n- Image editing (text and image to image)\n\n - **Example prompt:** \"Edit this image to make it look like a cartoon\"\n - **Example prompt:** \\[image of a cat\\] + \\[image of a pillow\\] + \"Create a cross stitch of my cat on this pillow.\"\n- Multi-turn image editing (chat)\n\n - **Example prompts:** \\[upload an image of a blue car.\\] \"Turn this car into a convertible.\" \"Now change the color to yellow.\" \"Add a spoiler.\"\n\nEdit an image\n-------------\n\n### Console\n\nTo edit images:\n\n1. Open [**Vertex AI Studio \\\u003e Create prompt**](https://console.cloud.google.com/vertex-ai/studio/multimodal).\n2. Click **Switch model** and select **`gemini-2.5-flash-image-preview`** from the menu.\n3. In the **Outputs** panel, select **Image and text** from the drop-down menu.\n4. Click **Insert media** (add_photo_alternate) and select a source from the menu, then follow the dialog's instructions.\n5. Write what edits you want to make to the image in the **Write a prompt** text area.\n6. Click the **Prompt** (send) button.\n\n\nGemini will generate an edited version of the provided image based on\nyour description. This process should take a few seconds, but may be\ncomparatively slower depending on capacity.\n\n### Python\n\n#### Install\n\n```\npip install --upgrade google-genai\n```\n\n\nTo learn more, see the\n[SDK reference documentation](https://googleapis.github.io/python-genai/).\n\n\nSet environment variables to use the Gen AI SDK with Vertex AI:\n\n```bash\n# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values\n# with appropriate values for your project.\nexport GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT\nexport GOOGLE_CLOUD_LOCATION=global\nexport GOOGLE_GENAI_USE_VERTEXAI=True\n```\n\n\u003cbr /\u003e\n\n from google import genai\n from google.genai.types import GenerateContentConfig, Modality\n from PIL import Image\n from io import BytesIO\n\n client = genai.Client()\n\n # Using an image of Eiffel tower, with fireworks in the background.\n image = Image.open(\"test_resources/example-image-eiffel-tower.png\")\n\n response = client.models.generate_content(\n model=\"gemini-2.5-flash-image-preview\",\n contents=[image, \"Edit this image to make it look like a cartoon.\"],\n config=GenerateContentConfig(response_modalities=[Modality.TEXT, Modality.IMAGE]),\n )\n for part in response.candidates[0].content.parts:\n if part.text:\n print(part.text)\n elif part.inline_data:\n image = Image.open(BytesIO((part.inline_data.data)))\n image.save(\"output_folder/bw-example-image.png\")\n # Example response:\n # Here's the cartoon-style edit of the image:\n # Cartoon-style edit:\n # - Simplified the Eiffel Tower with bolder lines and slightly exaggerated proportions.\n # - Brightened and saturated the colors of the sky, fireworks, and foliage for a more vibrant, cartoonish look.\n # ....\n\n### REST\n\n\nRun the following command in the terminal to create or overwrite this file in\nthe current directory: \n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n https://${API_ENDPOINT}:generateContent \\\n -d '{\n \"contents\": {\n \"role\": \"USER\",\n \"parts\": [\n {\"file\u003c_da\u003eta\":\u003c {\n \u003e \"mime_type\": \"image/jpg\",\n \"file_uri\": \"varFILE_NAME/var\"\n }\n },\n {\"text\": \"Convert this photo to black and white, in a cartoonish style.\"},\n ]\n\n },\n \"generation_config\": {\n \"response_modalities\": [\"TEXT\", \"IMAGE\"]\u003e,\n },\n \u003e \"safetySettings\": {\n \"method\": \"PROBABILITY\",\n \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n \"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"\n },\n }' 2/dev/null response.json\n\n| **Note:** You **must** include `responseModalities: [\"TEXT\", \"IMAGE\"]` in your configuration. Image-only output is not supported with these models.\n\n\nGemini will generate an image based on your description. This\nprocess should take a few seconds, but may be comparatively slower depending on\ncapacity.\n\n\u003cbr /\u003e\n\nMulti-turn image editing\n------------------------\n\nGemini 2.5 Flash Image Preview also supports improved multi-turn editing, allowing\nyou to respond to the model with changes after receiving an edited image response.\nThis will allow you to continue to make edits to the image conversationally.\n\nNote that is recommended to limit the entire request file size to 50MB maximum.\n\nTo test out multi-turn image editing, try our\n[Gemini 2.5 Flash Image Preview notebook](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_2_5_image_gen.ipynb)."]]