SAM3 Multiprompt Segmentation
Mask several regions in one pass
- sam3_model
- image
- multi_prompts
- masks
- visualization
Most SAM3 nodes segment one thing at a time. This one segments a whole batch of separate regions in a single run - you hand it a bundle of prompts (each a point set or box marking a different object) and it returns a mask for each. If you've ever wired up three copies of the same segmentation node to grab the head, the hands and the jacket, this is the node that collapses that into one.
It exists for the multi-object case: relighting several products in a scene, per-region inpainting where each area gets its own treatment, or any pipeline where you need a stack of distinct masks and don't want three parallel branches doing the same work. It leans on the pack's SAM3_MULTI_PROMPTS type, which is a container of individually-marked regions - built for you by the SAM3 Multi-Region Collector.
How it works
The multi_prompts bundle carries several prompts, each describing one region. The node runs SAM3 once and produces a mask per region, so instead of N segmentation passes with N model calls you get one call that emits N masks. That's both a convenience and a small efficiency win - the model's already resident, so batching the prompts avoids repeated setup.
The inputs and outputs that matter
Three required inputs:
sam3_model- theSAM3_MODELfrom LoadSAM3Model.image- the picture to work on.multi_prompts(SAM3_MULTI_PROMPTS) - the bundle of regions, built by SAM3 Multi-Region Collector. This is the whole reason the node exists; without it there's nothing to segment.
Optionals: refinement_iterations (default 0, up to 10) tightens each mask's edges; use_multimask (default off here, unlike single-object segmentation) lets SAM3 weigh candidate masks per region; offload_model (default off) frees VRAM after the run.
Outputs: masks (MASK) - the batch of masks, one per region, ready for downstream masking work; and visualization (IMAGE) - a single preview with all the regions drawn on so you can eyeball the whole set at once.
How to install it
Comes with the pack. Manager: search SAM3 and install the highest version. 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. sam3.pt needs to live in ComfyUI/models/sam3/; install.py pulls it. The README flags an experimental comfy-env/pixi one-click installer that may run.
Common issues & troubleshooting
"multi_prompts" is empty or the wrong type. This node only accepts the SAM3_MULTI_PROMPTS bundle from SAM3 Multi-Region Collector - you can't feed it a plain points or box prompt. Collect your regions in the Multi-Region Collector first, then wire its output here.
Masks come back mushy or merged between nearby objects. Give each region cleaner, more separated prompts in the collector, and raise refinement_iterations a step or two. If two regions genuinely overlap, the per-region masks will too - that's expected, not a bug.
Downstream node expects one mask, not a batch. The masks output is a stack. If a consumer wants a single mask, index or split the batch first, or route each region where it needs to go rather than treating the whole set as one mask.
VRAM tight when this runs before a diffusion pass. Turn on offload_model so SAM3 clears the GPU once all the masks are out.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| sam3_model | SAM3_MODEL | SAM3 model loaded from LoadSAM3Model node | |
| image | IMAGE | Input image to perform segmentation on | |
| multi_prompts | SAM3_MULTI_PROMPTS | Multi-region prompts from SAM3MultiRegionCollector. Each prompt region produces a separate mask. | |
| refinement_iterationsopt | INT | 00–10 | Number of refinement passes per region. Each pass feeds the mask back for cleaner edges. |
| use_multimaskopt | BOOLEAN | false | If True, generates 3 mask candidates at different granularities for each prompt. If False, generates single mask directly. |
| offload_modelopt | BOOLEAN | false | Move model to CPU after segmentation to free VRAM (slower next run) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |
| visualization | IMAGE | — |