SAM3 Detect
Text-prompt segmentation and detection in a single core node
- model
- image
- conditioning
- bboxes
- masks
- bboxes
For years, "find this specific object and give me a clean mask" in ComfyUI meant wiring up GroundingDINO for the box plus SAM for the mask - two models, two nodes, two points of failure. SAM3_Detect collapses that into one node. Type a phrase into a CLIPTextEncode, and it returns both the bounding boxes and the per-object masks, with SAM3's open-vocabulary detector doing the whole job natively. That's the upgrade SAM3 brought over SAM 2, and this is the node that exposes it in core.
It's the right tool for targeted selection - the "this cat, not that one" case from the background-removal playbook. If you just want the subject cut off a plain background, a rembg-style node is still less hassle. Reach for SAM3 when you need a named object isolated from a messy scene, ready to feed inpainting, compositing, or a regional prompt.
How it works
SAM3_Detect picks its path based on what you give it. Text conditioning runs the open-vocab detector, which emits boxes, scores, and coarse masks per prompt. Bounding boxes alone route straight into the SAM decoder to segment inside each box. Point prompts - positive and negative - go down the tracker-style decoder path. Then the refine_iterations loop cleans up: it crops around each detection with a little padding, rescales to SAM3's working resolution, and runs the mask decoder repeatedly to tighten the edges. Set it to 0 and you get the raw, less-refined detector masks instead.
The inputs and outputs that matter
- model - the SAM3 checkpoint from
models/checkpoints/(sam3.1_multiplex_fp16.safetensors), loaded with a checkpoint loader. - image - what you're segmenting.
- conditioning - CLIPTextEncode output for text-driven detection. This is the headline feature; "person", "wine glass", "teddy bear" all work.
- bboxes - optional; segment inside existing boxes (handy if you chained from a fast detector).
- positive_coords / negative_coords - JSON point prompts in pixel coordinates, like
[{"x": 240, "y": 180}]. Positive points say "include this", negative say "exclude this". This is the precise click-selection path when text isn't specific enough. - threshold - confidence cutoff for text detections (default 0.5).
- refine_iterations - SAM decoder refinement passes, 0–5 (default 2).
- individual_masks - the switch that bites people. Off (default) = all detections unioned into one mask. On = a separate mask per object, stacked as a batch.
Outputs are masks and bboxes - the bboxes carry label and score, and both wire into anything that eats standard ComfyUI types.
The gotcha
The individual_masks trap is the one worth remembering. With the default union behavior you get a single mask that covers every detected instance, which is what you want for "remove all cars". The moment you need per-object control - different edits for different people - flip it on before you run, because you can't split a union back apart cleanly afterward. Also keep your point-prompt JSON valid; a stray comma turns the whole parse into a silent nothing.
One real-world note: SAM3's VRAM footprint is chunky and it's known to leave memory resident after offload (the community's recurring complaint, especially on 12GB cards). If you're running SAM3_Detect then loading a diffusion model in the same graph, give the diffusion load a fresh step - or expect the occasional OOM.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| image | IMAGE | — | |
| threshold | FLOAT | 0.500–1 | — |
| refine_iterations | INT | 20–5 | SAM decoder refinement passes (0=use raw detector masks) |
| individual_masks | BOOLEAN | false | Output per-object masks instead of union |
| conditioningopt | CONDITIONING | Text conditioning from CLIPTextEncode | |
| bboxesopt | BOUNDING_BOX | [object Object] | Bounding boxes to segment within |
| positive_coordsopt | STRING | Positive point prompts as JSON [{"x": int, "y": int}, ...] (pixel coords) | |
| negative_coordsopt | STRING | Negative point prompts as JSON [{"x": int, "y": int}, ...] (pixel coords) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |
| bboxes | BOUNDING_BOX | — |