Nodes/SDVN Segment Anything/🧩 Dino SAMSegment
ComfyUI Node

🧩 Dino SAMSegment

The segment node you actually wire into a real workflow

By StableDiffusionVNΒ·Created 7 months agoΒ·Updated 7 months agoΒ· 1
🧩 Dino SAMSegment
  • sam_model
  • grounding_dino_model
  • image
  • IMAGE
  • MASK
β—„promptβ€”β–Ί
β—„threshold0.30β–Ί
β—„text_threshold0.25β–Ί

Same two models as the pack's all-in-one node, but you bring the models yourself. That sounds like extra work until you hit your first workflow with three segment steps in it - then it's the difference between loading two big models three times and loading them once. SDVN DinoSAMSegment takes an already-loaded SAM_MODEL and GROUNDING_DINO_MODEL as inputs, runs the GroundingDINO β†’ SAM pipeline, and hands you IMAGE and MASK outputs. It's the node the loaders were built for.

Why it beats the all-in-one

The pack's SegmentAnything node loads both models internally every single run. Fine for a one-off cutout. But if you're segmenting several regions of the same image, or feeding a batch through, you want the models loaded once and wired to several DinoSAMSegment nodes. That's exactly what the model-object inputs buy you: plug the same SAM_MODEL and GROUNDING_DINO_MODEL wires into as many segment nodes as you like, and the loaded checkpoints sit in VRAM and get reused. Same mechanism - GroundingDINO proposes text-grounded boxes, SAM refines each box into a mask - but you control the loading, and you control which checkpoint each step uses.

The inputs

  • sam_model / grounding_dino_model - the two loader outputs (SDVN SAMModelLoader and SDVN DinoModelLoader). No dropdowns here; they arrive as objects.
  • image - the image (or batch) to segment.
  • prompt - what to look for. dog, person, or several at once: dog . cat . person.
  • threshold (0.3) - box confidence cut. Lower it when detections are being missed.
  • text_threshold (0.25) - phrase-match confidence. Lower it when the right region is found but the label doesn't quite match your words.

Outputs and what they do

IMAGE and MASK. The image is the subject isolated with everything outside the mask zeroed to black; the mask is what you'll route into VAEEncodeForInpaint, a composite, or a save node. One thing worth knowing before you use it: this node returns one image/mask pair per detection, not per input image. Feed it one photo with three dogs and you get three masks. That's usually what you want, and it's a pleasant surprise until you were expecting one.

Two landmines in the source

If the prompt matches nothing, the node doesn't error - it returns an empty (all-zero) mask for both outputs. Worse, in that empty case the IMAGE output is also just that blank tensor, not a real image, so don't blindly feed the image output into a VAE and expect it to survive. Check your prompt and thresholds first; the mask being black is the node's way of saying "found nothing."

There's also a quirk in the batch loop: if a match fails partway through a batch, processing stops at that image and you get a shorter result than you fed in. In practice, keep batches of segment work small or check the output count.

Install

It ships in the same pack, so there's nothing extra to fetch:

cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Segment_Anything
cd SDVN_Segment_Anything
pip install -r requirements.txt

then restart and load the pack from Manager as SDVN Segment Anything. The first run still needs your SAM and GroundingDINO checkpoints downloaded (they land in ComfyUI/models/sams and ComfyUI/models/grounding-dino), plus bert-base-uncased for the text side. Give the first run time and bandwidth; everything after that is fast.

This is the node I'd reach for in a kept workflow. The all-in-one is a demo; this one is the tool.

CategoryπŸ“‚ SDVN/🎭 Mask

Inputs (6)

NameTypeDefaultDescription
sam_modelSAM_MODELβ€”
grounding_dino_modelGROUNDING_DINO_MODELβ€”
imageIMAGEβ€”
promptSTRINGβ€”
thresholdFLOAT0.300–1β€”
text_thresholdFLOAT0.250–1β€”

Outputs (2)

NameTypeDescription
IMAGEIMAGEβ€”
MASKMASKβ€”