Nodes/ComfyUI-MultiMaskOps/Mask Batch To List
ComfyUI Node

Mask Batch To List

Split one mask batch into per-subject masks, the front door to this pack

By INuBq8·Created 2 months ago·Updated 2 months ago· 0
Mask Batch To List
  • masks
  • masks

Mask Batch To List is the node you'll actually reach for first in this pack, because it's the front door. Segment an image into multiple subjects - SAM through Impact Pack, BiRefNet, a YOLO with mask output - and you get back a single mask batch: one [N, H, W] tensor with N masks welded together. That's great for "here's everything," useless for "give me the third person." This node splits the batch into a list of N individual [1, H, W] masks, one per downstream execution.

Why does that distinction matter? ComfyUI masks come in two shapes: a batch tensor and a Python list of separate tensors. Most of the real work in this pack - Mask Sort By Position, Mask Pick By Index, Mask Deduplicate, Mask Expand Without Overlap - operates on lists, because lists let a node handle each mask on its own terms instead of as row N of one tensor. This node is how you get from what your segmenter produces to what those nodes eat. Its mirror image, Mask List To Batch, puts everything back at the end.

How it works

It's aggressively simple under the hood: if the input is a flat 2D mask it gets a batch dimension added, then each slice masks[i:i+1] is pulled out as its own [1, H, W] tensor. That's it - no resizing, no interpolation, no data lost.

The inputs and outputs that matter

One input, one output, both named masks:

  • masks - the mask batch from your segmenter, SAM, or any node that emits multiple masks as one tensor.
  • masks (output) - a list. Because the output is flagged as a list, ComfyUI will execute whatever you connect downstream once per mask. That per-item execution is the entire point: it's how the pack sorts, expands and deduplicates each subject independently.

Installation

The pack-wide story applies here: clone it in, restart, done. No model downloads, and requirements.txt is empty - it uses torch, scipy and torchvision, all present in a stock ComfyUI.

cd ComfyUI/custom_nodes
git clone https://github.com/INuBq8/ComfyUI-MultiMaskOps

Restart and you'll find the nodes under MultiMaskOps (Manager search "MultiMaskOps" should also work; the README says the listing is "soon", so the clone is the sure thing).

Troubleshooting

The classic mistake is skipping this node entirely and wiring a raw batch into a list-only node. The error messages tend to be cryptic shape mismatches, and the fix is almost always "forgot Mask Batch To List." If you don't actually have multiple subjects, note that a single mask fed here just becomes a one-item list - harmless, and the list-based nodes handle it fine.

A small caveat: this pack is young (a single commit as of mid-2026), so treat it as a sharp utility rather than battle-tested infrastructure. For the narrow job of "unpack my segmenter's output so I can work per-subject," though, it does exactly what it says with nothing extra to configure.

CategoryMultiMaskOps

Inputs (1)

NameTypeDefaultDescription
masksMASKA mask batch [N, H, W]. Output is a list of N individual masks, one per downstream execution.

Outputs (1)

NameTypeDescription
masksMASK