Multiband to Masks
Pull your segmentation channels back out, by hand or by name
- multiband
- masks
Multiband to Masks is the extractor. A MULTIBAND_IMAGE in, a batch of standard ComfyUI MASKs out - the reverse of Mask to Multiband, and the node that closes the loop on the pack's most natural workflow: stack masks, save the stack, and later pull the masks back out for the ordinary mask-consuming nodes.
Its party trick is auto_detect_masks. Instead of you remembering that the segmentation channels are 3 and 5, the node looks at the channel names, finds every channel containing "mask" (case-insensitive), and returns all of them as one mask batch. That's the feature that makes the pack feel like it was built for people who don't want to babysit channel indices. Compose your stack with sensibly named masks, and this node finds them later no matter how the stack grew.
How it works
Two mutually exclusive paths:
- Manual:
channelstakes a comma-separated list of indices (1, or0,1,2,3). Each listed channel is extracted and stacked into one MASK batch - if the multiband has batch 1 you get(N, H, W), otherwise(N*B, H, W). - Auto-detect: flip
auto_detect_maskson and it scans the channel names for "mask," overridingchannelsentirely. If nothing matches, it falls back to the manual list with a console warning.
Output is a single masks MASK tensor, which wires straight into inpainting, masking, or any node that takes a mask batch.
The inputs
- multiband - required, the stack to mine.
- channels - optional, default
0. Indices, ignored when auto-detect is on. - auto_detect_masks - optional boolean, default off. The better mode, once your names are sane.
Installing the pack
Part of ComfyUI-Multiband. ComfyUI Manager → search "ComfyUI-Multiband" → Install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/PozzettiAndrea/ComfyUI-Multiband.git
pip install -r ComfyUI-Multiband/requirements.txt
Deps: numpy, torch, tifffile. No models.
The workflow it's built for
The pattern that makes this pack worth installing: batch of SAM masks → Batch to Multiband (names them mask_01, mask_02…) → Save Multiband Image as .npz → later Load → Multiband to Masks with auto-detect → your mask batch is back, names intact, zero index bookkeeping. The one failure mode is naming: if channels were auto-named channel_0 or came in without "mask" in the name, auto-detect quietly falls back to manual indices. Run Rename Multiband Channels once at compose time and this node just works.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| multiband | MULTIBAND_IMAGE | — | |
| channelsopt | STRING | 0 | Channel indices to extract. Single (e.g., '1') or comma-separated (e.g., '0,1,2,3'). Ignored if auto_detect_masks is enabled. |
| auto_detect_masksopt | BOOLEAN | false | When enabled, automatically finds all channels with 'mask' in their name and returns them. Overrides the 'channels' parameter. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |