Nodes/ComfyUI 1hewNodes/Mask Batch Split
ComfyUI Node

Mask Batch Split

Split your mask batch the same way you split the images

By 1hew·Created about a year ago·Updated 7 days ago· 33
Mask Batch Split
  • mask
  • mask_1
  • mask_2
take_count8
from_startfalse

Here's the thing about splitting an image batch: the moment you do it, your mask batch is now the wrong size. If you split 40 frames into 8 and 32, but leave your masks as one 40-frame tensor, every downstream image+mask operation falls apart. Mask Batch Split is the sibling of the pack's Image Batch Split, built so your masks can follow your images through the split without you hand-crafting index ranges.

It does one thing: splits a mask batch into two parts, mask_1 and mask_2, at a take_count you choose, from either the start or the end. Same shape as its image counterpart, which is the entire point - run them side by side with matching parameters and your image/mask pairs stay aligned.

How it works

  • take_count - frames in the "taken" part (1–1024, default 8).
  • from_start - true puts the first take_count in mask_1 (rest in mask_2); false puts the last take_count in mask_2 (everything before it in mask_1).

Edge handling matches the image node exactly: when take_count >= batch_size, one output is the full batch and the other is an empty tensor with the same dtype and shape semantics, so downstream nodes don't crash. Slicing runs in a worker thread to keep the UI responsive.

Inputs: mask, take_count, from_start. Outputs: mask_1, mask_2.

Install

Part of ComfyUI-1hewNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

Restart ComfyUI. No models, no downloads. Needs a current ComfyUI (the pack uses the v3 node API).

Where it fits

The rule of thumb: wherever you drop Image Batch Split, drop Mask Batch Split next to it with identical take_count and from_start. That keeps every image and its mask in lockstep through the split. It's the difference between a graph that silently misaligns masks after frame 8 and one that just works.

Common issues

  • Masks no longer match your images - the classic mistake is splitting images with from_start=true and masks with from_start=false, or using different take_count. Mirror the image node's settings exactly.
  • Empty mask output - take_count >= batch_size yields an empty tensor by design. If a node downstream chokes, that's the cause; it's the documented edge case, not corruption.

That's the whole node. It's boring on purpose - its job is to make sure the interesting split you did to your images doesn't quietly break every mask that depends on them.

Category1hewNodes/batch

Inputs (3)

NameTypeDefaultDescription
maskMASK
take_countINT81–1024
from_startBOOLEANfalse

Outputs (2)

NameTypeDescription
mask_1MASK
mask_2MASK