ScarlotSoft Grounded-SAM
Point at objects with text, get masks — the ScarlotSoft Grounded-SAM node
- image
- batch_masks
Segmentation without training a detector or painting a mask: that's what Grounded-SAM gives you, and ScarlotSoft GroundedSAM packages the whole thing into one node. You feed it an image and a plain-text description - the default is 1girl. 1boy. - and it hands back a batch of masks for every object matching that text. The machinery is the famous pair: Grounding DINO finds boxes from your words, SAM cuts the precise silhouette inside each box. DINO's the eyes, SAM's the scalpel.
The inputs: image, the prompt (multi-line, so list several objects separated by periods), box_threshold (0–1, default 0.3 - how confident DINO must be about a box), text_threshold (0–1, default 0.25 - how confident the text-match must be), invert_mask, and sam_model, a dropdown of SAM weights. Output is a single batch_masks MASK, one mask per detected object, stacked. Lower the thresholds if it's missing things; raise them if you're drowning in boxes. Invert is there when you want everything except the detected object.
Now the parts that will actually bite you, because this node has real setup weight. The sam_model dropdown needs a SAM checkpoint in ComfyUI/models/sams/ - the code even shows a placeholder message ("¡Pon tu sam_vit_b.pth en models/sams!") when the folder's empty. Grab sam_vit_b.pth (the base model; vit_h also works, it's slower and heavier) and drop it there. Then the node auto-installs its own Python deps - segment-anything and transformers - via pip on first run, which means the first execution can sit there for minutes while it installs and then downloads IDEA-Research/grounding-dino-base from Hugging Face. No internet, no first run. The code also guards against DINO's 256-token limit by truncating prompts past 150 words, so you can't easily crash it with a novel - a thoughtful touch, and it'll log a warning when it truncates.
You wire the masks out into inpainting - mask to SetMask/Easy Mask Conditioning, image to a VAE encode, sampler at a moderate denoise. This is the same detect-mask-inpaint loop from the detailing playbook, except the detector is your text instead of a YOLO model, which makes it the tool for "isolate everything but the car" or "mask all the people" without hunting for the right detector weights. It also frees you from the AGPL baggage of the Ultralytics detector path, since DINO and SAM are Apache/BSD-family models.
Install the node itself the usual way:
cd ComfyUI/custom_nodes
git clone https://github.com/scarlotsoft/ComfyUI_ScarlotSoft
via Manager (search ScarlotSoft), or the above, then restart. The model downloads are the real install step.
Reality check: this is the heaviest node in the suite and the most impressive when it works. It's also the one where a missing checkpoint or a first-run pip hang looks like a crash. Give it the SAM file, let the first run finish, and it rewards you with masks you couldn't otherwise get without hand-painting - a genuinely different segmentation workflow.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| prompt | STRING | 1girl. 1boy. | — |
| box_threshold | FLOAT | 0.300–1 | — |
| text_threshold | FLOAT | 0.250–1 | — |
| invert_mask | BOOLEAN | false | — |
| sam_model | COMBO | 1 options: ¡Pon tu sam_vit_b.pth en models/sams! |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| batch_masks | MASK | — |