SAM Multi-Mask Picker
Choosing between candidate masks without re-running the segmenter
- masks
- selected_mask
Segmenters don't give you the mask. They give you masks - SAM-style models return several valid interpretations of a click, because "the whole person" and "the jacket" and "the arm" are all defensible answers to the same point prompt. Usually you want candidate three, not candidate one.
Multi-Mask Picker takes a stack of candidates and outputs one, by index. That's it. It's a two-input node and its whole value is that it makes the choice explicit, cheap, and re-runnable without re-running the model.
How it works
The interesting part is the shape handling, because ComfyUI's MASK type is overloaded and this node reads the ambiguity correctly:
- A standard 3-D mask batch
(N, H, W)is treated as N candidates for one frame. - A 4-D stack
(B, N, H, W)is treated as B frames, each with N candidates, and picking indexitakes candidateion every frame.
That second case is the one that matters for video. If you select candidate 3 once, you get candidate 3 for the whole clip, consistently. Doing that by hand - slicing masks per frame and hoping your index logic matches - is exactly the kind of thing that produces a matte that flips interpretation halfway through a shot.
picker_index is zero-based, and here's the detail that surprises people: it wraps. It's index % N, not a clamp. Ask for candidate 6 from a 4-candidate stack and you get candidate 2. The author's comment in the source calls the picker "visual" and logs the resolved index - so it is designed to be scrubbed interactively rather than typed precisely, but in a driven/API graph a wrap is a silent wrong answer rather than an error. Keep the index inside the candidate count you actually got.
Inputs and outputs
masks - the candidates, from whatever segmenter you're using. picker_index - 0 to 5 in the widget's range, and it wraps past the end.
One output: selected_mask. From there, mask-feather it and send it to inpainting, or take it into Radiance's Matte node to refine the edge into a soft alpha, or straight into a composite as an alpha.
The SAM-shaped elephant
Radiance 3.5 does not ship a SAM runtime. The SAM Loader and SAM Mask Generator are placeholders - they existed so saved graphs could open, they used to draw discs around click points rather than running a segmentation model, and they now raise a clear error if executed and are hidden from the node menu. The pack says it outright: use a SAM2 node pack.
So in practice you get your candidate stack from somewhere else - a SAM2 pack, a segmentation model from ComfyUI's own nodes, a BiRefNet-style background remover that emits several variants - and this node does the choosing. It's a genuinely useful piece of plumbing that happens to be named after a feature that isn't there. Worth knowing before you go hunting for a missing loader.
Installing Radiance
Manager → search Radiance → install → restart → refresh. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/fxtd-studios/radiance.git
cd radiance
python -m pip install -r requirements.txt
Windows portable: python_embeded\python.exe. This node needs no weights. The pack is GPL-3.0, ~147 visible nodes from FXTD Studios, and brings OpenEXR, OpenImageIO, OpenColorIO, diffusers and accelerate into ComfyUI's Python environment whether you wanted them or not.
Troubleshooting
It picked the wrong candidate. It picked the index you gave it, modulo the count. Print the mask stack's shape upstream, or eyeball it in a Viewer, then set the index deliberately rather than hunting.
Frames in a video use different interpretations. You fed it a 4-D stack and it selected one index across all frames - which is the consistent behaviour. If the candidates themselves vary per frame because the segmenter re-ran, no picker can fix that. Segment once with tracking, or accept the drift.
Downstream node wants an IMAGE, not a MASK. Standard ComfyUI friction. Convert, or look for a Radiance node that takes MASK directly - quite a few of them do, including the composite and matting nodes.
The errors say SAM isn't shipped. Correct, and it's not your install. Get a SAM2 pack and wire its mask outputs here.
One tip. This node is at its best on an interactive graph where you're scrubbing the index and watching the Viewer. In a batch or API run, set the index once, verify it, and freeze it - the wrap behaviour means a driven index that drifts produces plausible-looking wrong output rather than an error.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | Candidate masks. A standard MASK batch (N, H, W) is treated as N candidates for one frame; a 4-D (B, N, H, W) stack picks the same candidate on every frame. | |
| picker_index | INT | 00–5 | Zero-based index of the candidate to output. Wraps around if it is past the number of candidates. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| selected_mask | MASK | — |