LayerMask: Object Detector Gemini(Advance)
Object detection with zero local models, just a Gemini API key
- image
- bboxes
- preview
Every other object detector in LayerStyle Advance needs something downloaded first - GroundingDINO and SAM weights for SegmentAnythingUltra, EVF-SAM's checkpoints, YOLO models. ObjectDetectorGemini needs none of that. It sends your image and a text description to Google's Gemini API and gets bounding boxes back, so the entire "installation" for this specific node is an API key. If you're on a machine that can't spare several GB of VRAM or disk for local detection weights, this is the path of least resistance.
The trade-off is the usual one for any API-backed node in this pack: you need internet access at inference time, you're bound by whatever rate limits or costs Gemini's API has, and your image data is leaving your machine.
The inputs and outputs that matter
image/prompt(default"subject") - required. Describe what you want found, same free-text style as the pack's other prompt-driven detectors.model- four Gemini choices:gemini-1.5-flash,gemini-1.5-pro,gemini-1.5-flash-8b,gemini-2.0-flash-exp. Flash variants are faster and cheaper;1.5-proreasons better about cluttered scenes or ambiguous prompts.
Two outputs: bboxes (type BBOXES, ready to feed into DrawBBoxMask, SAM2UltraV2, or BBoxJoin) and preview - an image showing where the detection landed. Use the preview as your sanity check before trusting the boxes downstream; it's the fastest way to catch a detector that found the wrong thing.
Installing it
ComfyUI Manager: search "ComfyUI Layer Style Advance". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance.git
Run install_requirements.bat (portable) or install requirements.txt yourself, then restart.
The actual setup step: get a free key from Google AI Studio, then rename the plugin's api_key.ini.example (in its own folder inside custom_nodes) to api_key.ini, open it, and fill in google_api_key=. This is shared across every Gemini node in the pack (Gemini, GeminiV2, PromptTagger, and this one) - one setup step covers all of them.
Common issues
Node fails silently or with a vague error. The api_key.ini rename step is the single most common trip-up for every Gemini-backed node in this pack - check the file exists (not just .ini.example) with your key correctly filled in before assuming anything's broken at the node level.
Detection found the wrong object, or nothing. Unlike GroundingDINO, which is trained specifically for grounding text to boxes, Gemini is a general-purpose multimodal model doing detection as one of many capabilities - it's often good, but not infallible on cluttered scenes or vague prompts. Tighten prompt to something concrete ("the blue mug", not "the object on the table") and check the preview output before trusting the result.
Want a newer Gemini model than what's listed. This node's model list is fixed to four specific versions. If you need the newest Gemini release, check whether ObjectDetectorGeminiV2 - the pack's sibling node, built on a different underlying Google SDK - has it instead.
Rate limits or unexpected cost. All four listed models are metered past whatever free tier Google currently offers; if you're running this across a large batch, keep an eye on your Google AI Studio usage dashboard rather than assuming it's free the way Zhipu's glm-4v-flash is elsewhere in this pack.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | 4 options: gemini-1.5-flash, gemini-1.5-pro, gemini-1.5-flash-8b, gemini-2.0-flash-exp | |
| prompt | STRING | subject | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| bboxes | BBOXES | — |
| preview | IMAGE | — |