GroundingDinoModelLoader (segment anything2)
GroundingDinoModelLoader (segment anything2)
- GROUNDING_DINO_MODEL
This is the "find the object" half of the pair. It loads GroundingDINO - the text-prompted object detector - and hands it downstream to the segment node. On its own it does nothing visible; its whole job is to pick a GroundingDINO checkpoint, load it once, and keep it ready so the actual masking node doesn't reload it every run. Small node, but it's what makes typing "the dog" and getting a box around the dog possible.
Why you'd reach for it
You reach for it because GroundingDinoSAM2Segment requires it. That segment node needs two models - a detector and a segmenter - and this is the detector loader. GroundingDINO is the piece that turns your text prompt into bounding boxes; SAM 2 then traces the precise outline inside each box. Our masking notes put it plainly: GroundingDINO does text-prompted object detection ("the red dress," "the person on the left") and pairs with SAM to produce a precise mask around whatever it found. Without this loader there's no text-to-box step, and the text-prompt magic of the whole pack disappears.
Keeping it as its own node is the usual ComfyUI move: load the weights once, reuse the handle across your graph instead of paying the load cost on every execution.
How it works
GroundingDINO is a "grounded" detector - it was trained to connect language to image regions, so it can localize objects it was never given a fixed class list for. Feed it a phrase, it returns boxes ranked by confidence. This node reads the config plus the .pth weights, builds that detector, and outputs a handle. It doesn't run detection here; that happens later, inside the segment node, when the image and prompt actually arrive.
The inputs and outputs that matter
One input, model_name, and it's the only real decision. The dropdown offers two checkpoints:
- GroundingDINO_SwinT_OGC (694MB) - the Swin-Tiny backbone. Faster, lighter, and the one to default to. It's what most workflows use and it's plenty for everyday "mask the jacket" work.
- GroundingDINO_SwinB (938MB) - the Swin-Base backbone. A bigger, more capable detector for trickier scenes where Tiny keeps missing the object or boxing the wrong one. Costs you more VRAM and a little speed.
Start on SwinT. Only move up to SwinB if detection is genuinely letting you down on a busy or ambiguous image - it's a detection-quality upgrade, not a mask-quality one, so it won't sharpen edges (that's SAM 2's job).
The single output is GROUNDING_DINO_MODEL, which plugs straight into the grounding_dino_model input of GroundingDinoSAM2Segment. Nowhere else.
How to install it
Ships with the pack, no separate step. ComfyUI Manager: search ComfyUI SAM2 (or "Segment Anything 2"), install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/neverbiasu/ComfyUI-SAM2
then pip install -r requirements.txt and restart. The GroundingDINO weights auto-download the first time you pick one, or pre-place them in models/grounding-dino under your ComfyUI root - and grab both the config file and the .pth, keeping the original filenames (the pack looks them up by name; rename and it won't find them). SwinB is 938MB, so the first pull of the big one isn't instant; set HTTP_PROXY / HTTPS_PROXY if the download is slow to you.
Common issues & troubleshooting
GroundingDINO fails to install. This is the recurring pain with the entire SAM-plus-GroundingDINO family, and it long predates SAM 2 - people constantly report SAM loading fine while GroundingDINO's install throws errors. It ships CUDA ops that sometimes need to compile against your setup, and when that build fails, this loader can't produce a model and the segment node downstream has nothing to work with. If Manager's install errors out, this is almost always the culprit. Managed hosts like comfy.icu pin a known-good environment so it just works; a fresh local install is where it bites.
Node loads but the segment node still can't detect anything. Make sure both the config and the weights actually landed in models/grounding-dino with their original names. A missing or renamed config is a common silent cause of "it loaded but finds nothing."
Downloads stall. Pull the config and .pth by hand from the pack README's links and drop them in models/grounding-dino, or set the proxy env vars. Once the files are present, the node stops trying to fetch them.
One honest note: this pack is one of several ways to run GroundingDINO in ComfyUI, and the broader toolchain has largely been folded into bigger, more actively maintained packs over time. This node still does exactly what it says - but if you're wiring a masking pipeline from scratch today, it's worth knowing you're not locked to this one loader.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 2 options: GroundingDINO_SwinT_OGC (694MB), GroundingDINO_SwinB (938MB) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GROUNDING_DINO_MODEL | GROUNDING_DINO_MODEL | — |