🧩 Sam Segment
Type “cat”, get a mask — SAM 3.1 with three inputs and no GroundingDINO
- image
- IMAGE
- MASK
The mask you want, described in one word
Text-to-mask used to be a two-model chain: GroundingDINO finds a box for "the red dress", SAM turns the box into a precise mask, and you wire five nodes together hoping detector and segmenter agree. SAM 3 ended that in November 2025 by doing open-vocabulary concept segmentation natively. This node is the shortest possible front end to it - three inputs, two outputs, no model selector, no GroundingDINO, no Hugging Face login.
Reach for it when the thing you want to mask has no trained detector. YOLO is still faster and more reliable for faces, hands and people, because purpose-trained weights beat a noun phrase every time. But "the stained cup on the left", "the second dog", "that one shoe" - nobody trained a YOLO for those, and this will find them.
It deliberately does not do background removal. SAM selects a named object; it doesn't decide foreground from background. For a product cutout, BiRefNet or rembg is the right tool and this is overkill.
How it works
On first execution the node downloads Comfy-Org's sam3.1_multiplex_fp16.safetensors into ComfyUI/models/sam3, anonymously, and reuses any copy already there. It loads it through ComfyUI's own checkpoint loader and hands the model to ComfyUI's native SAM3 Detect node, where the actual segmentation happens. A thin wrapper, in the good sense: no bundled inference code, no Triton of its own, no extra gigabyte of Python.
Your prompt is split on commas into concepts, then each is expanded to concept:200 before tokenisation - 200 being the per-concept detection cap, roughly what a GroundingDINO box pass gives you. Write cat:2 and that concept stops at two detections, which is how you avoid masking every cat in a crowded photo.
Inputs and outputs
image- single or batch, RGB or RGBA. Alpha is discarded before segmentation, so a transparent PNG gets masked on colour content only.prompt- plain noun phrases:cat,cat, dog,red car:1. Sentences work worse than a comma-separated list of things. Describe the object, not the scene.threshold- detection confidence, 0.3 by default. Lower it when you get nothing and the object is genuinely there; raise it when the mask creeps onto the tablecloth.
Outputs are IMAGE and MASK.
MASK is usually what you want: one union mask per image, ready for VAE-encode-for-inpainting, a SetLatentNoiseMask, this pack's own Crop Inpaint, or Mask Regions if you need several objects split apart. Be clear that it's a union - three cats in frame gives one blob covering all three, not three masks.
IMAGE is the input frame multiplied by the mask, so unselected area goes black rather than transparent. Great for a visual check of what you caught, not a compositing cutout; for real alpha, route MASK into a join-with-alpha node. The node also saves its own preview to the UI at runtime, so you can verify a run without adding a preview node.
Install
Same pack as the rest of SDVN. Manager: search SDVN_Comfy_node. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
cd ../..
pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt
Restart, then run the node once - the checkpoint downloads itself. Nothing to place by hand.
The one hard prerequisite: your ComfyUI must be new enough to have the native SAM3 Detect node and SAM31 in its supported model list. The node checks both and refuses with an explicit "update ComfyUI and restart" error rather than emitting garbage.
Where people get burned
"ComfyUI has no native SAM3 Detect." You're on an older ComfyUI. git pull the main repo and restart. No custom node can satisfy this - it needs core support.
INT8/INT4 quants won't be picked up. Quantised SAM 3.1 checkpoints exist, work fine with the native loader, and save real VRAM. This node has no model field: it looks for that exact fp16 filename in models/sam3 and re-downloads it otherwise. Tight on VRAM? Use the native SAM3 nodes directly and skip this wrapper.
Duplicate node registrations. The pack absorbed the old standalone SDVN_Segment_Anything node. If it's still installed, disable or remove it before restarting.
Empty masks on reasonable prompts. Usually phrasing or threshold, not the model. Try threshold near 0.2 and a bare noun. Tiny object in a big frame? Crop first.
Masks that leak. Low threshold plus an ambiguous noun ("shoe" in a shop) grabs everything eligible. The :N cap is the cheap fix; raising threshold is the other.
Video. Frames are processed independently, with no tracking between them, so a frame batch flickers. That's a SAM 2.1 tracker job, not this node.
And the licence, easy to miss: SAM 1 and 2 are Apache 2.0; SAM 3.x isn't. Meta's own SAM License permits broad commercial use but adds field-of-use restrictions, share-alike on derivatives, and revocation. Fine inside ComfyUI, worth reading before you ship a product on it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| prompt | STRING | Vật cần chọn, ví dụ cat, dog. Dùng cat:2 để giới hạn số vật. | |
| threshold | FLOAT | 0.300–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |