Nodes/ComfyUI_Gemini/πŸ” Gemini Object Detection
ComfyUI Node

πŸ” Gemini Object Detection

Object detection with no YOLO, no AGPL, no training

By aarnoatchiΒ·Created 2 months agoΒ·Updated 2 months agoΒ· 0
πŸ” Gemini Object Detection
  • image
  • annotated_image
  • masks
  • union_mask
  • detections_json
  • summary
β—„modelgemini-3.1-pro-previewβ–Ί
β—„detection_promptDetect all objects in this image.β–Ί
β—„output_modebothβ–Ί
β—„annotation_styleboxes_labelsβ–Ί
β—„seed0β–Ί
β—„use_descriptive_labelstrueβ–Ί
β—„confidence_threshold0.00β–Ί
β—„box_thickness3β–Ί
β—„font_size20β–Ί
β—„box_color#00FF00β–Ί
β—„temperature0.2β–Ί

Gemini Object Detection is the "find things in a picture" node that doesn't need a downloaded model at all. You type what you're looking for in plain English - "detect all people and vehicles" - and Google's Gemini looks at the image over the API and hands back bounding boxes, labels, and masks. No YOLO weights, no Ultralytics install, no AGPL licensing question hanging over your workflow. The trade is that it's a cloud call: it needs a Google API key, it costs per image, and your image leaves your machine.

That trade is worth making in two situations. First, when your detection classes are arbitrary - Gemini understands natural language, so "find the color-matching chart and the hang tag" works without training a detector on them. Second, when you're already in the closed-model world and don't want to bolt a whole local detection stack onto the side of it. If you want the local, free, privacy-preserving alternative, the KB's detection doc lays out the YOLO/MediaPipe landscape; this node is the no-install cloud lane.

How it works

The node sends your image plus the detection_prompt to Gemini, gets back a set of detections with bounding boxes and labels, and does the drawing locally with PIL - boxes, labels, and optionally the annotated image only, JSON only, or both (output_mode). It also converts each detection into a mask and unions them into a single union_mask, which is what makes this slot into the detect β†’ crop β†’ refine β†’ stitch loop from the KB: wire masks into Gemini Mask Crop, refine the crops with Gemini Batch Refine, and paste back with Gemini Mask Stitch.

Two things worth knowing before you queue. First, the seed isn't just for reproducibility - it's a cache key. The node hashes image bytes + seed + params (IS_CHANGED), so the same image with the same seed skips the API call entirely and serves the cached result. That's a real money saver when you're iterating on annotation style. Second, model choice is a real speed/accuracy dial: the default gemini-3.1-pro-preview has the strongest spatial accuracy, 3.5 Flash is faster, and the 2.5 models are the stable fallback if the newer ones act up.

The inputs that matter

  • detection_prompt - the whole point. Be specific: "Detect all people and vehicles" beats "Detect all objects."
  • model - default 3.1 Pro. Drop to a Flash tier for bulk runs.
  • output_mode - annotated_image, json_only, or both. For piping into a workflow you want both; for data extraction, json_only saves the drawing step.
  • annotation_style - boxes, boxes_labels, or labels_only.
  • confidence_threshold - default 0 keeps everything; raise it to filter weak detections. Note it filters, but Gemini doesn't give you calibrated confidences the way YOLO does, so treat it loosely.

Outputs: annotated_image, masks, union_mask, detections_json, and a summary string.

Install, key, and gotchas

Same pack as the rest of the suite: ComfyUI Manager search "ComfyUI_Gemini", or clone into custom_nodes and pip install -r requirements.txt - google-genai (not google-generativeai), python-dotenv, scipy. Put GOOGLE_API_KEY in the pack's .env so the key stays out of your workflow files. Common complaints: "API key is missing" (check the .env placeholder), safety blocks on sketchy prompts, and preview-model names getting retired. And budget - this pack is a small single-author project, so when something breaks, the console logs are your support ticket; they're detailed, which helps.

CategoryAI/Image Analysis/Google

Inputs (12)

NameTypeDefaultDescription
imageIMAGEInput image for object detection
modelCOMBOgemini-3.1-pro-previewGemini model for detection. 3.1 Pro gives the strongest spatial accuracy; 3 Flash is faster; 2.5 models are the stable fallback.
detection_promptSTRINGDetect all objects in this image.Describe what objects to detect (e.g., 'Detect all people and vehicles')
output_modeCOMBObothOutput format: annotated image, JSON data, or both
annotation_styleCOMBOboxes_labelsHow to draw annotations
seedINT00–2147483647Same seed + same image + same params β†’ cached (no API call). Set 'control after generate' to 'fixed' to keep the result; 'increment'/'randomize' to re-run on each queue.
use_descriptive_labelsoptBOOLEANtrueUse descriptive labels instead of generic ones
confidence_thresholdoptFLOAT0.000–1Minimum confidence for detections (0 = all detections)
box_thicknessoptINT31–20Thickness of bounding box lines
font_sizeoptINT2010–100Font size for labels
box_coloroptSTRING#00FF00Hex color for bounding boxes (e.g., #00FF00 for green)
temperatureoptFLOAT0.20–2Lower = more consistent, Higher = more creative

Outputs (5)

NameTypeDescription
annotated_imageIMAGEβ€”
masksMASKβ€”
union_maskMASKβ€”
detections_jsonSTRINGβ€”
summarySTRINGβ€”