SAM3 Text Segmentation
Segment anything by typing what you want
- sam3_model
- image
- positive_boxes
- negative_boxes
- masks
- visualization
- boxes
- scores
This is the node most people actually came to SAM3 for. Displayed as "SAM3 Text Segmentation," it takes an image plus a text prompt like dog or red car and hands you back a mask of every matching thing in the frame. No clicking, no drawing boxes, no separate GroundingDINO node feeding it - SAM3 does the open-vocabulary detection and the masking in one shot. Type the noun, get the mask.
That's the leap over the old workflow. The classic setup was two models bolted together: GroundingDINO to turn text into bounding boxes, then SAM to turn boxes into precise masks. SAM3 folds both jobs into one model, which is why "text segmentation" is now a single node instead of a chain. Where you'd use it: pull the subject out for inpainting, isolate a product for compositing, build an automated batch pipeline that finds and masks the same object across a hundred images. It's overkill if you just want foreground-vs-background - grab BiRefNet for that - but it's exactly right when you need a specific named thing.
How it works
Under the hood it's grounded segmentation: the text prompt conditions the model to localize matching regions, and SAM3 produces a pixel mask for each. Because it's open-vocabulary, you're not limited to a fixed label set - describe the object in plain words. The confidence_threshold decides how sure the model has to be before it keeps a detection, so it's your main dial for "found nothing" versus "masked half the image."
The inputs and outputs that matter
The three you'll actually touch:
sam3_model- theSAM3_MODELfrom LoadSAM3Model. Required.image- the picture to segment.text_prompt- what to find, e.g.person,left hand,yellow flower. Keep it a concrete noun phrase.confidence_threshold(default0.2) - the keep/drop bar, 0–1. Low catches more but risks junk; raise it when you're getting false positives.
Two optionals worth knowing: max_detections (default -1 = unlimited) caps how many instances come back, handy when you want just the biggest few; and offload_model (default off) pushes the model off the GPU after the run to reclaim VRAM. There are also optional positive_boxes / negative_boxes inputs (SAM3_BOXES_PROMPT) if you want to constrain the search region with a box on top of the text.
Outputs: masks (MASK) - the thing you feed into inpainting or compositing; visualization (IMAGE) - a preview with the masks drawn on, wire it to a Preview Image to sanity-check; and boxes / scores (both STRING, JSON) - the detected boxes and their confidence numbers for debugging or downstream logic.
How to install it
It comes with the pack. ComfyUI Manager: search SAM3, install the highest version (nightly if the release misbehaves). Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-SAM3.git
cd ComfyUI-SAM3
pip install -r requirements.txt --upgrade
python install.py
then restart. You need sam3.pt in ComfyUI/models/sam3/; the install.py step fetches it. Note the README's warning that the pack may try an experimental comfy-env/pixi one-click install.
Common issues & troubleshooting
It masks nothing. Your confidence_threshold is too high for that image, or the prompt doesn't match how the model "sees" the object. Drop the threshold toward 0.1, and simplify the wording - one clear noun beats a long descriptive sentence.
It masks too much / grabs the wrong stuff. Raise the threshold, or cap max_detections so you only keep the strongest hits. If there are several similar objects and you want one, add a positive_boxes prompt around the region you care about.
VRAM pressure in a bigger graph. Flip offload_model on so SAM3 leaves the GPU once the mask is out - useful when a diffusion model needs the room right after.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_model | SAM3_MODEL | SAM3 model loaded from LoadSAM3Model node | |
| image | IMAGE | Input image to perform segmentation on | |
| confidence_threshold | FLOAT | 0.200–1 | Minimum confidence score to keep detections. Lower threshold (0.2) works better with SAM3's presence scoring |
| text_promptopt | STRING | Describe what to segment using natural language (e.g., 'person', 'cat', 'red car', 'shoes') | |
| positive_boxesopt | SAM3_BOXES_PROMPT | Optional box prompts to focus detection on specific regions. Connect from SAM3CombineBoxes node. | |
| negative_boxesopt | SAM3_BOXES_PROMPT | Optional box prompts to exclude specific regions from detection. Connect from SAM3CombineBoxes node. | |
| max_detectionsopt | INT | -1-1–100 | Maximum number of detections to return (-1 for all) |
| offload_modelopt | BOOLEAN | false | Move model to CPU after segmentation to free VRAM (slower next run) |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |
| visualization | IMAGE | — |
| boxes | STRING | — |
| scores | STRING | — |