MatteAnything_DinoBoxes
Type what you want, get red boxes
- image
- dino_model
- IMAGE
- DINO_BOXES
This is the node that makes Matte Anything feel like you're talking to it. MatteAnything_DinoBoxes takes your image, a GroundingDINO model, and a plain-English caption, then draws a red rectangle around whatever you asked for. "the person on the left", "a wine glass", "the logo on the shirt" - the caption is the entire interface. It's the text-to-selection step that the whole pack is built around.
How it works
The caption goes into GroundingDINO's predict_with_caption, and the detector returns one or more xyxy bounding boxes plus the label each box matched. The node draws those boxes onto a copy of your image in red, and returns two things at once:
- IMAGE - the annotated image, so you can see what got detected. This is your feedback loop; if the box is wrong, your caption was wrong.
- DINO_BOXES - the raw detection data, which is what the rest of the pipeline actually consumes. These get fed to
MatteAnything_SAMMaskFromBoxes.
That split is worth internalizing: the red-boxed image is for your eyes, the DINO_BOXES is for the graph. Both come out of the same node, so you don't have to choose.
What you actually set
Just three inputs, and two of them come from earlier nodes:
- image - from your
LoadImage. - dino_model - from
MatteAnything_LoadDINO. - caption - the text describing what to find. This is the only thing you'll be editing repeatedly.
One thing you'll notice is missing: confidence thresholds. The original Matte Anything app exposed box_threshold and text_threshold sliders so you could tune how aggressively GroundingDINO matched. This node hardcodes those and doesn't expose them, which means on a genuinely ambiguous caption you can't rescue a missed detection by lowering the bar - you have to reword the caption instead. It's the pack's biggest "this was a port, not a redesign" tell.
The trap in the output
The annotated IMAGE is a new image - the original with red rectangles painted over it. It's not your input passed through; it's a debug view. Plenty of people wire it straight into SaveImage and then wonder why their "cutout" has red borders. If you want the subject without the boxes, you take the DINO_BOXES down the SAM path and leave the annotated image alone.
Installing this pack
ComfyUI Manager, search Comfy_KepMatteAnything, install. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/M1kep/Comfy_KepMatteAnything
then restart ComfyUI. This node needs the full dependency trio (segment-anything, detectron2, groundingdino-py), and the GroundingDINO weights in ComfyUI/models/dino/:
mkdir -p ComfyUI/models/dino
# groundingdino_swint_ogc.pth into ComfyUI/models/dino/
Gotchas
- Vague captions get vague boxes. GroundingDINO matches words, not intent. "the person" with three people in frame gives you three boxes, and
SAMMaskFromBoxeswill happily mask all of them. Be specific: "the person in the red jacket" beats "the person" every time. - No matches isn't an error, it's an empty result. If the caption detects nothing, you get an image with no boxes and an empty
DINO_BOXES- which then fails downstream inSAMMaskFromBoxeswhen it tries to stack zero boxes. Watch for that when a workflow dies mid-graph for no visible reason.
Honest take: when the caption works, it's the closest this pack gets to magic - zero manual masking, just words. When it doesn't, you'll miss the threshold sliders the original app had. Reword, don't rage.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| dino_model | DINO_MODEL | — | |
| caption | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| DINO_BOXES | DINO_BOXES | — |