Nodes/Comfyui_Gemini2/CXH_Gemini2_Vision
ComfyUI Node

CXH_Gemini2_Vision

A second pair of eyes that talks back about your renders

By StartHua·Created 2 years ago·Updated 2 years ago· 18
CXH_Gemini2_Vision
  • image
  • out
model
prompt

The vision sibling in the Comfyui_Gemini2 pack, and honestly the more fun one. CXH_Gemini2_Vision takes an image plus a prompt, sends both to Google's Gemini, and returns a text answer. It's the node you use when you want a model to actually look at what you just made and say something useful about it.

The classic loop: render an image, wire it into this node straight from VAE Decode (or from Load Image if you're working off a file), ask something like "describe this image in detail" or "what's wrong with the hands," then feed the reply back into the prompt for the next pass. It's also a lazy man's captioner - describe existing reference images for dataset prep, or turn a photo into a prompt that drives a fresh generation. Because it accepts any IMAGE, you can point it at your current render at the end of the graph and treat it as a built-in critic that costs you a few seconds and a few tokens.

Mechanically it's simple. The node converts ComfyUI's IMAGE tensor into a PIL image with a tensor2pil helper, then calls model.generate_content([prompt, pil_image]). Same key-in-key.txt setup as the text node, same hardcoded seven-model dropdown, same out STRING on the other side. If you've used CXH_Gemini2_TX, nothing here is new except the image input.

The inputs that matter: image (any IMAGE - current render, loaded file, whatever), model (the default gemini-2.0-flash-exp is fine for vision too; if one of the ids in the list refuses an image or errors, it's likely an experimental id that never had solid multimodal support, so stick to the flash/pro line), and prompt (multiline, the instruction you're giving Gemini about the image). The output, out, is a STRING you can wire into CLIP Text Encode, a text display node, or back into another LLM step.

Installation is identical to the rest of the pack. In Manager, search "Comfyui_Gemini2"; or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/StartHua/Comfyui_Gemini2
cd Comfyui_Gemini2
pip install -r requirements.txt

Then write your aistudio.google.com key into key.txt, restart, and remember the same rule as the text node: the key is read when the node is created, so put it there before you build the workflow. And the same cv2 caveat - the code imports it but requirements doesn't list it, so if you hit "No module named 'cv2'", run pip install opencv-python-headless.

Two things to think about before you build this into a regular workflow. First, privacy: whatever is in that image leaves your machine and goes to Google. That matters a lot more for a vision node than a text one - if you're generating NSFW or anything client-confidential, decide deliberately whether you want it crossing an API. Second, cost and latency: sending a large image costs more tokens and takes a few seconds, so keep renders reasonably sized if you're looping on critique. Both are the normal trade of closed API models - convenient, but it's their platform and their pricing, and either can change overnight.

CategoryCXH/gemini

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
modelCOMBO7 options: gemini-2.0-flash-exp, gemini-1.5-pro, gemini-1.5-flash, gemini-1.5-flash-8b, learnlm-1.5-pro-experimental, gemini-exp-1114, +1
promptSTRING

Outputs (1)

NameTypeDescription
outSTRING