Repeat Mask Batch
Duplicating masks so they match your frames
- mask
- mask
Repeat Mask Batch takes one mask and repeats it amount times along the batch dimension. That sounds like a party trick, but it's fixing one of ComfyUI's least-fun silent failures: tensor batch-size mismatches.
ComfyUI's pixel nodes love to broadcast, but not always, and nowhere is that more visible than with masks. You've drawn one mask, or detected one subject region, and you want to composite or inpaint over a batch of images - a stack of frames, several patches, a grid of variations. Many mask-consuming nodes (blend ops, compositors, inpainting prep) expect the mask batch to line up with the image batch. Give them a single mask against 8 frames and you'll either get a shape error or, worse, a silent broadcast that applies your mask to the wrong frames. This node is the fix: repeat the mask to match the count, and the two tensors line up.
It's the mask sibling of the "make one value fit N consumers" instinct that runs through the whole plumbing layer - except here the value is a pixel tensor and the consumers are the batch-aware parts of your graph. If you've done video or batch work at all, you've hit this exact wall.
How it works
Mechanically it's one call: mask.repeat(amount, 1, 1, ...) - the mask is repeated amount times along dimension zero. The amount widget is clamped to a max of 4096, which is plenty generous. A few things to keep straight, because the name trips people:
- It repeats the whole input, not "fills up to" a target. If your input mask already has a batch of 3 and you set
amountto 2, the output has 6 masks - not 3. There's no "how many total do I want" logic; it's literally multiplication along the batch axis. - A single mask in, N masks out. Feed it one
[1, H, W]mask andamount8 and you get 8 identical masks, perfect for matching 8 frames.
The inputs and outputs that matter
- mask - the input MASK. One mask or a batch.
- amount - the repetition count, min 1, max 4096, default 1. Set it to your frame/batch count.
- mask (output) - the repeated batch, ready to feed mask-requiring composite, inpaint, or blend nodes.
How to install it
Part of ComfyUI-Practical-Tools by wenchengxiang. ComfyUI Manager → search ComfyUI-Practical-Tools → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
Pure torch, no extra downloads or requirements.
Common issues
- "The output batch is bigger than I expected." That's the multiply-not-fill behavior above. If you need exactly N masks and your input already carries a batch, compute
amountasN / input_batch- or use a mask-to-list and re-batch node if you'd rather not do arithmetic in your head. - Wrong-dimension masks. ComfyUI MASK tensors are
[B, H, W]. If the node upstream handed you something with a channel dimension, the repeat still works but the shape may not be what a downstream compositor expects - check the batch and the rank if you get a cryptic shape error. - Nothing to preview. There's no preview on this node, so you can't eyeball the result. When in doubt, pipe the output into a mask preview node to confirm it looks like N copies of your mask and not a smear.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| amount | INT | 11–4096 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |