Nodes/ComfyUI-CustomNodePacks/LocateAnything Grounding (MEC)
ComfyUI Node

LocateAnything Grounding (MEC)

LocateAnything Grounding (MEC) turns a phrase into bounding boxes

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
LocateAnything Grounding (MEC)
  • image
  • bboxes
  • annotated_image
  • raw_response
promptperson
model_pathnvidia/LocateAnything-3B
generation_modehybrid
max_new_tokens2048
devicecuda
confidence_threshold0.00

You type "the red car on the left" and this node hands you back the pixel coordinates of every red car. That's the whole pitch of LocateAnything Grounding (MEC), and it's the missing front-end for all the SAM machinery in the MaskEditControl pack.

It wraps NVIDIA's LocateAnything-3B, an open-vocabulary grounding model. Where GroundingDINO needs a big pretrained model plus a matching prompt format, this is a single transformer that reads your phrase, looks at the image, and emits bounding boxes - plus a drawn-over preview and the model's raw text output. It's the "name the thing" step that makes the rest of the pack feel almost magical: phrase → boxes → mask → inpaint, no training data, no per-object detector.

How it works

The node loads the model through HuggingFace transformers (AutoModel/AutoTokenizer/AutoProcessor) with trust_remote_code, generates a structured response from your image + prompt, and parses boxes out of it. The generation_mode combo (default hybrid) trades speed for accuracy - fast for quick passes, slow when you need the boxes to actually be right. max_new_tokens caps the generation (2048 by default, up to 8192) and confidence_threshold drops boxes below a score; leave it at 0 to keep everything the model returns.

The three inputs that matter:

  • image - what you're pointing at.
  • prompt - a plain-language description, default "person", multiline so you can be specific.
  • model_path - defaults to nvidia/LocateAnything-3B; change it if you've got a local copy.

Outputs: bboxes (a BBOX_LIST), annotated_image (the preview with boxes drawn), and raw_response (the model's text, handy when you want to know why it chose those boxes).

Where it slots in

The natural wire is LocateAnything → LocateAnything → SAM Prompt (MEC), which converts the BBOX_LIST into a filled mask, then into a SAM box prompt. From there it's the standard SAM pipeline: box prompt → clean mask → inpaint or composite. It's a promptable alternative to GroundingDINO, and if you've read the KB's masking doc you know the drill - grounding boxes come back tighter than you expect, so pad them (the companion node's expand_ratio does exactly that).

Install and gotchas

Install is the pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git

or ComfyUI Manager → search "CustomNodePacks". The catch here: this node needs transformers, which the pack's requirements.txt marks optional (it's called out for ViTMatte). This node won't run without it:

pip install transformers

The model itself (~3B params) auto-downloads from HuggingFace on first run, so the first execution is slow and eats several gigabytes. It caches after that. On CPU (device = cpu) it's slow enough to be painful - budget for it or skip if you only have a small GPU. Also, if you're shipping anything commercial, glance at NOTICE.md before building a pipeline on a downloaded model - the RMBG-2.0 backend in this pack carries a non-commercial license, and it's worth knowing which of the models you actually use is under what terms.

If you get boxes everywhere including junk, raise confidence_threshold to ~0.3–0.5 before blaming the model. And if the download errors mid-way, model_path lets you point at a local HF cache copy instead.

CategoryMaskEnhancedControl/Grounding

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
promptSTRINGperson
model_pathoptSTRINGnvidia/LocateAnything-3B
generation_modeoptCOMBOhybrid3 options: hybrid, fast, slow
max_new_tokensoptINT2048256–8192
deviceoptCOMBOcuda2 options: cuda, cpu
confidence_thresholdoptFLOAT0.000–1

Outputs (3)

NameTypeDescription
bboxesBBOX_LIST
annotated_imageIMAGE
raw_responseSTRING