AIMods_Nano_Banana + PROTOTYPING_UI - V1
Nano Banana, Google's new model (officially named gemini-2.5-flash-image-preview), was released a few days ago. It made quite an impression with its ability to precisely edit images using text or other images.
Back in July, during the TouchDesigner event in Paris, I presented a series of components (AIMods) I've been working on for a few months and that I use in my installations and performances. These components allow the integration of different AI modalities indide TouchDesigner. When I saw Nano Banana, I figured it was a great opportunity to release a first version of the AIMods to bring Nano Banana into TouchDesigner.
You'll find the TouchDesigner network for Nano Banana integration for free on my Patreon, including:
-
AIMOD_NANO_BANANA that integrates the inference API for gemini-2.5-flash-image-preview (TXT2IMG, IMG2IMG) and gemini-2.5-flash TXT2TXT (super useful for complex pipelines).
-
PROTOTYPING_UI : A small UI I quickly put code, but which works quite efficiently.
-
This Doc
Nano Banana QUICK Overview
It's everywhere, so I'll keep this quick. Nano Banana is a new image generation and editing model. It combines TXT2IMG and IMG2IMG capabilities, can merge images, supports multi-step editing, allows retouching with a “virtual mask” (semantic mask) to modify only targeted parts of an image, and has strong semantic understanding. Plus, It's relatively affordable for now, It integrates configurable invisible watermarking. API calls take around 10 seconds (so not blazing fast for highly interactive uses, but very reasonable given its potential).
With TouchDesigner, it becomes possible to orchestrate these features through pipelines, for installations or personal creative use. This allows combining them with interactive interfaces and exploring creative workflows that simple prompting alone cannot achieve.
Examples of NANO BANANA Usages
Image Editing
From a single image, you can request iterative edits with high accuracy to your instructions. Within TouchDesigner, you can for example manage camera inputs and get a convenient live visualization of iterations.
Image Combination
You can input multiple images (up to 3 recommended) and combine them through instructions. This opens the door to highly creative combinatorial pipelines.
Style Transfer
Style transfer can be performed from either text or image. It's fairly faithful and high quality, and particularly useful for generating textures that can later be used in 3D pipelines (just as an Example).
Sketch-Based Work
I always have a camera TOP connected to my workspace, and I found it particularly fun to work with whiteboard or tablette drawings, then prompt modifications based on those sketches.
Installing AIMods_Nano_Banana in TouchDesigner
1. Create a Google Cloud Nano Banana Account
-
To use Nano Banana from the Gemini API, create a Google Cloud account: https://console.cloud.google.com/welcome
-
Then, create a project and configure billing (new accounts get free credits allowing lots of testing).
-
Go to Google AI Studio and create an API key: https://aistudio.google.com/
-
(More info on API keys: https://ai.google.dev/gemini-api/docs/api-key)
2. Install Your Python Environment & Make it accessible from TouchDesigner
To run AI inference from TouchDesigner, you need a Python environment accessible from TouchDesigner. It's highly recommended to use a virtual environment (venv, Conda…) to keep things clean and organized. Each environment is isolated, with its own Python version, libraries, and scripts. This makes it easy to set up different environments for different projects, prevent library conflicts, and make possible to share work setups.
Let's present two methods :
Method 1 : Install and manage External environment with Anaconda
It a centralized environments that you install outside TouchDesigner accessible by modifying TouchDesigner's environment variables. This is the 'old' method, but still relevant if you use your environment for other project than those inside TouchDesigner. Note that it's often recommended to create the environment with the same Python version that ships with your TouchDesigner build. To check which version that is, open the TextPort and DAT : the Python version appears on the first line.
You can Follow this tutorial to set it up : https://derivative.ca/community-post/tutorial/anaconda-miniconda-managing-python-environments-and-3rd-party-libraries
To use this Method in the project
-
This project is configured to use this method by default
-
Once your Conda environement is Installed
-
You can load the environment at startup via op('/project1/START_TOOLS/Load_env').
-
You can configure Conda directly in the CONDA tab of op('/project1/START_TOOLS') (it's somthing like : C:\\Users\\username\\anaconda3\\envs\\Gemini) and reload the project. it will automatically be loaded at each startup.
-
Install your Library under anaconda CLI
Method 2 : Using the TDPYENVMANAGER component (available in experimental 2025 builds)
It's simpler if you are beginner and it's officially from TouchDesigner. It install a per-project environments in their subdirectory with venv (you can also use conda). it is only available in the Experimental build.
Here is the tutorial : https://derivative.ca/community-post/introducing-touchdesigner-python-environment-manager-tdpyenvmanager/72024
To use the method in the project
-
do not use the /project1/START_TOOLS/load_env script. To do so : Load the project, disable the call to this componant by commenting the line #op('load_env').run() in /project1/START_TOOLS/execute_on_start
-
Save and reload your project
-
Configure your environment with TDPYENVMANAGER
-
Run your environment
-
Install your Library opening Virtual environement CLI
NOTE : This task around Python environement can be a bit tedious and often the cause of many misunderstandings and bugs. However, if you want to seriously use AI models within TouchDesigner, it's important to have a solid grasp of the following concepts: using the CLI (Command Line Interface), creating virtual environments (venv, Conda, etc.), the main Conda commands (for those who use it), installing packages (pip, Conda Forge, uv, etc.), and best practices for maintaining library compatibility. There are plenty of resources online, and your favorite LLM can be a good tutor.
3. Install Python Library
IN YOUR ENVIRONEMENT CLI (Command Line Interace) : Once your Python environment is set up, you need to install the Google Gemini library:
pip install -U google-genai
Puis Une autre librairie pour la gestion des images :
pip install Pillow
IN YOUR TOUCHDESIGNER TEXT PORT : After installation, you can verify from the Textport that the library is accessible by entering:
python >>> import google.genai
If no error appears, it means the library is properly loaded. For final confirmation, you can also check the version:
python >>> google.genai.__version__
'1.33.0
4. Configure API Key in TouchDesigner
You can enter the API key directly in the API_KEY menu of the component Project1/START_TOOL. Save your project and restart it: the key will then be loaded automatically at each startup.
NOTE : This is not the most secure way to integrate your API key. For more information, refer to the documentation: https://ai.google.dev/gemini-api/docs/api-key
Simplified Use: PROTOTYPING_UI
So, we've installed our environment, made it available from TouchDesigner, installed the library, and configured the API key. We should now finally be ready to use Nano Banana within TouchDesigner.
For simplified use, I quickly coded a small UI, it's quite simple but it does the job. This UI relies on the central node AIMOD_NANO_BANANA (which is completely independent from this UI).
You can open the PROTOTYPING_UI component in View mode to use it. It's fairly straightforward, as you'll see:
On the left
-
You have three possible image inputs that will be injected to the model:
-
NONE : does not include any image in the process
-
FILE: loads an image (when you first clic it open the fileselector. As it's a radio button, clic on another option and clic again to reopen the fileselector)
-
LAST: injects the last generated image (don't forget to inject the last image if you prompt modification on the result images
-
CAM: uses the camera input (see the configuration of Videodevicein1 in /Project1 for camera setup)
-
-
Within each source image windows, you can zoom and pan each image to inject the most relevant part for your needs. Double-clicking on an image resets its zoom and position.
In the middle, the generated image.
On the right
-
-
Prompt navigation to recall previous prompts
-
Your current prompt input
-
Image navigation to recall previously generated images (handy for injecting a specific image into input images)
-
The Run button sends the request to the API and starts generation (when it turns pink-orange, generation is in progress)
-
A small log window displays returned messages and errors
-
Using the TouchDesigner Component: AIMods_Nano_Banana
Many of you will probably want to use the AIMod directly in your own pipelines without necessarily relying on the UI. AIMods are independent components that perform inference based on AI models. They generally share a similar structure, with some variations depending on the modality. The processus is fully asynchronous, but it still depends of your hardware.
Let's start with the Nano Banana AIMod (independent from the UI presented earlier).
Inputs
-
In1 CHOP: External trigger pulse (0 → 1) to start inference
-
In2 DAT: External table with prompt in [0,0] (takes priority over the parameter prompt)
-
In3 TOP: Image1 (1024x1024)
-
In4 TOP: Image2 (1024x1024)
-
In5 TOP: Image3 (1024x1024)
Outputs
-
Out1 CHOP: Trigger pulse (0 - 1) indicating the end of inference. Useful for chaining the AIMod with other Mods or processes
-
Out2 DAT: External table with text result in [0,0] (if any)
-
Out3 TOP: Result image (1024x1024)
Component PARAM Tab
-
Run: Starts inference (same as In1 CHOP)
-
Stop: Forces the termination of the current process
-
Mode: Selects the inference modality
-
TXT2IMG2IMG_NANOBANANA: Image generation from text and/or image (see usage below)
-
TXT2TXT_GEMINI25_FLASH_ASYNC: Text generation (handy to need an LLM TXT2TXT in pipelines)
-
-
User Prompt Input: User prompt (note: this field is ignored if a table is connected to In2 DAT)
File System
This AIMod comes with a small file system, as temporary images are used. You have to set up this two directory in order to make the project working :
-
/Temp: Temporary images (for AIMod)
-
/Export: Saved images (for PROTOTYPING_UI)
Usage
-
When the process is launched (via the Run button in PARAM or the external trigger), the component turns red, indicating it is running in the background.
-
When the process receives a response from the API, outputs are updated, Out1 CHOP pulses, and the component returns to its normal color.
-
A running process cannot be relaunched until it has been stopped (this is very useful for agent-based orchestration).
-
At launch, the module analyzes connected TOP inputs and automatically selects the modality depending on the connections:
-
If no images are connected : TXT2IMG is called.
-
If one or more images are connected : TXT+IMG2IMG is called.
-
It's recommended to connect images in order.
-
-
If the process encounters an error, it should display a message in the PARAM tab, stop the background process, and return to normal color.
-
BUT, this doesn't always happen. Sometimes, in case of certain errors, the node may remain red—you'll need to manually stop the process by pressing STOP before launching a new one.
Prompting Guide
-
To generate an image from text: disconnect all inputs and use only text prompt
-
To apply a prompt to a specific image: connect the image to input 1 and prompt your modification
-
Inputs 2 and 3 are typically used for adding objects or style transfer.
-
You can explicitly reference an image in the prompt, for example: “insert the element from image 1 into image 2.”
Notes
-
'code': 500, 'message': 'Internal error encountered.' : Mean you have to retry later. The API is not 100% reliable, especially if requests are sent at short intervals.
-
Images are sent (and reveived) in 1024x1024 pixels.
-
The model appears to have specific internal modes, chosen autonomously depending on prompts. In one of these modes, it essentially performs compositions using masks, which can lead to "ugly collage-like" results. In that case, don't hesitate to rechallenge the model using the initial image with a refined prompt.
-
The model has safety filters (even if none are explicitly enabled on the API call by default), so sometimes you'll get errors simply because “Computer Says No.”
License of AIMods_Nano_Banana + PROTOTYPING_UI
-
This code is provided as is (aka AS IS).
-
It may crash or behave oddly… that's life.
-
Copyright (c) 2025 Infratonal
-
Licensed under the MIT License
Asset Downloads
AIMods_Nano_Banana_v1.zip (40.25 KB)













