SAM3 Detect (Tiled)
Text-prompted SAM3 segmentation that doesn't lose the small stuff on big images
- model
- image
- conditioning
- bboxes
- masks
- bboxes
SAM 3 is the masking step that ate the old GroundingDINO-plus-SAM two-model pipeline: type "yellow school bus" or feed an exemplar, and it masks every matching object in one pass. The catch is that it's not really designed to see whole huge images. Like most promptable segmenters it works on a fixed-size input - here about 1008×1008 - so feed it a 4K frame and something has to shrink, and the shrinking is exactly what makes small text and small objects invisible to the detector. This node from silveroxides' ComfyUI-UtilsCollection exists to fix that: it tiles the image and runs SAM3 on each tile at full working resolution, then hands you back masks that line up with the original image, pixel for pixel.
How the tiling works. When you drive SAM3 with a text prompt (the common case), the image gets split into overlapping, aspect-preserving tiles along its longer axis - minimum three, always an odd count so there's a clean center - and processed center-first, working outward. Each tile is padded to a square, rescaled to SAM3's 1008 working size, and run through the detector on its own, so a logo that would vanish in a whole-frame downscale stays resolvable inside its tile. Tile results are then mapped back to global coordinates and stitched, and edge_padding (on by default) replicates 32px of the image edge before tiling and discards it afterward so border objects aren't cut off mid-tile. Emitted masks always match the input dimensions.
Inputs that matter.
model- aMODELwrapping the SAM3 checkpoint. The pack's own Load SAM 3.1 Checkpoint (UC_SAM31CheckpointLoader) is the natural pairing: it defaults to fp32 precisely to stop ComfyUI Core downcasting the weights, which SAM3 needs.conditioning(optional) - text from aCLIPTextEncodeusing the SAM3 clip. This is the open-vocabulary part; skip it and the node falls back to plain promptable segmentation.threshold- detection score cutoff, default 0.5. Raise it if you're drowning in spurious matches.refine_iterations- SAM decoder refinement passes, default 2; 0 gives you the raw detector masks. A pass or two tightens edges to actual object boundaries.individual_masks- off gives you one union mask per frame; on returns per-object masks.bboxesand thepositive_coords/negative_coordsJSON point prompts - the box-and-click way to tell SAM "this thing, here," e.g.[{"x": 100, "y": 200}, {"x": 300, "y": 250}]for two positive points. These run on the single downscaled working frame rather than through the tile path.
Outputs. masks (MASK, same resolution as your input image) and bboxes (BOUNDING_BOX) for every detection. Wire masks into your inpainting, compositing, or a detailer-style crop-edit-paste loop - this is exactly the "name a region, mask it, fix it" workflow the ecosystem uses SAM3 for.
Install. ComfyUI Manager → search ComfyUI-UtilsCollection, or
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
then restart. The pack's own deps are light (opencv-python, unifiedefficientloader), but you'll need the SAM3/SAM 3.1 checkpoint yourself in ComfyUI/models/checkpoints. Note the licence shift: SAM and SAM 2 are Apache 2.0, but SAM 3 ships under Meta's custom SAM Licence, which is worth reading before you build a product on it.
Where people get burned. If your text conditioning isn't coming from the SAM3 text encoder, the concept part silently won't work the way you expect - match the clip to the checkpoint. Threshold too low and "refine_iterations" can't save a mask from a garbage detection; drop the threshold, not the iterations. And keep expectations honest about tiled open-vocabulary detection: it's more robust on big images than a single whole-frame pass, not magic - genuinely tiny far-field text may still need a closer crop. The center-first order is a nice touch: if you're running a batch and want to cancel, the middle of the frame - usually the subject - is already done.
Inputs (10)
| 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) |
| edge_padding | BOOLEAN | true | Replicate 32px of the outer image edge before tiling, then discard it from the returned masks. Tile overlap is calculated from the image dimensions. |
| 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 | — |