GroundingDinoSAMSegment (segment anything plus)
The node that cuts anything out of an image by typing what it is
- sam_model
- grounding_dino_model
- image
- IMAGE
- MASK
This is the node the whole pack exists for. Everything else is plumbing: the two loaders arm the models, and this one does the actual "type the thing, get the mask" trick that makes people search for segment-anything-plus in the first place. Instead of hand-drawing a mask or running a one-click background remover that assumes "the subject = the thing you want", you type cat and it finds the cat. Type jacket and it finds the jacket. That text-driven control is what separates this from rembg-style tools, which give you a subject cutout and nothing else - see the KB's background-removal notes for why that distinction keeps mattering.
How it works
Two models cooperate, and the pipeline is worth knowing because your failure modes split along the seam. First, GroundingDINO scans the image with your prompt and returns a set of bounding boxes above a confidence threshold. Then SAM takes each box and produces a precise pixel mask of whatever's inside it. DINO decides where, SAM decides how exactly. If DINO never finds a box, SAM never runs - and a lot of "why is my mask wrong" complaints are really DINO problems, not SAM problems.
The inputs that matter
prompt- what to find. Short, concrete, singular nouns work best (person,head,shirt). This is the knob you'll fiddle with most.threshold- the box-confidence cutoff, default0.3, range 0–1. Lower it and DINO finds more boxes (and more junk); raise it and you get cleaner but may miss things. Start at the default.points- optional SAM click hints, and the most underused input. Format is fraction pairs separated by+, comma-separated:0.5+0.5,0.3+0.7is "the center and a point near the left". Each is a foreground point (fraction of width/height), and they nudge SAM when a box is too loose.sam_modelandgrounding_dino_model- wire in the outputs of the two loaders. Alsoimage, obviously.
The outputs and what they wire into
IMAGE- the subject cut out, one image per detection, everything outside the mask transparent. This is your composite-ready cutout.MASK- the raw mask. This is the one you feed downstream: intoInpaint Crop/Inpaint Stitchfor a masked redraw, into a conditioningSet Mask, into a detail pass, or (with this pack'sInvertMask) inverted to protect the subject and regenerate the background. That crop-and-stitch pattern is where masked inpainting still owns its territory - bit-identical pixels outside the mask, per the inpainting KB doc.
Installing
ComfyUI Manager, search "ComfyUI Segment Anything", or:
cd ComfyUI/custom_nodes
git clone https://github.com/un-seen/comfyui_segment_anything_plus
Dependencies: segment-anything, timm, addict, yapf. Models auto-download to models/sams/ and models/grounding-dino/ (plus a ~440MB BERT text encoder on first run). Plan for ~2GB+ of downloads before your first successful run.
Where people actually get stuck
- Body parts are a real weak spot. The community's experience with this exact node is blunt: "there is no publicly available model that reliably detects limbs." Users report heads and faces detecting fine while arms, waist, and chest come back nothing no matter how they tune
threshold. GroundingDINO is trained on things, not anatomy parts. Workarounds people actually use: remove the background before segmenting so DINO isn't confused by scenery, then apply the mask back to the original for inpainting; or detect what DINO can find and use mask math to get the rest. - A miss returns zeros for both outputs. When nothing is found above threshold, the node returns an all-zero tensor for both
IMAGEandMASK- and it stops processing the batch at the first empty detection. If you feed that straight into an image node you'll get odd errors, so guard withIsMaskEmpty (segment anything plus)before running an inpaint pass. - VRAM. This is a SAM + DINO + checkpoint session. The
vit_hSAM model plus SwinB DINO is a lot; start withvit_b+ SwinT.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| sam_model | SAM_MODEL | — | |
| grounding_dino_model | GROUNDING_DINO_MODEL | — | |
| image | IMAGE | — | |
| prompt | STRING | — | |
| points | STRING | — | |
| threshold | FLOAT | 0.300–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |