Mask Repeat Batch
One mask, a batch of frames — repeat it to match
- masks
- repeated_masks
ComfyUI is picky about batch dimensions in a way that costs you whole afternoons. You want to inpaint 8 frames of video with the same mask, so you wire a single mask into a node that expects one mask per frame, and you get a cryptic shape error - or worse, it silently applies the mask to one frame and does nothing for the rest. MaskRepeatBatch exists to close exactly that gap: it takes your mask (or mask batch) and repeats it amount times along the batch axis, so the mask batch lines up with your image batch.
How it works
The implementation is deliberately boring: it unsqueezes a 2D mask into a proper batch if needed, then calls torch.repeat((amount, 1, 1)). Each copy is identical - same shape, same values, repeated along dimension zero. Wire a 512×512 mask in with amount 8 and you get a [8, 512, 512] tensor out. From there it feeds any node that wants per-frame masks: batch inpainting, batch compositing, batch img2img where the same protected region applies to every frame.
It's a sibling of the pack's MaskFromBatch (pulls a slice out of a batch) and MaskBatchComposite (stacks two batches), and they're meant to be used together - pull, repeat, composite is a complete little mask-batch utility set.
The inputs that matter
- masks - a MASK tensor. A single 2D mask or a multi-frame batch both work.
- amount - how many times to repeat, 1–64. If your mask batch is already size 3 and you want 6 total, set amount to 2.
Output is repeated_masks, same dtype and layout, just longer on the batch axis.
When you actually need it
The honest version: with modern ComfyUI you can often get away with a single mask because many nodes broadcast - but plenty still don't, and the failure mode when they don't is silent. If your batch output has the mask effect only on the first frame, this node is the fix. It also shines in video work where you've generated one stable mask from a keyframe and want it applied uniformly across the clip, or in LoRA training prep where you're building a batch of masked crops that all share one protective region. The cost is memory: 8 copies of a full-res mask is still tiny (masks are single-channel), so there's no real downside to over-repeating.
Installing it
It's part of ComfyUI-YCNodes. Install via ComfyUI Manager (search ComfyUI-YCNodes), or:
cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes
Restart ComfyUI, then look under YCNode/Mask/Batch. It only needs torch, so no dependency friction.
Gotchas
Two small ones. First, amount is the repeat factor, not the target size - amount: 2 on a 3-mask batch gives 6, not 2. If you want exactly N, divide first or use MaskFromBatch to size the input. Second, repeating a mask doesn't copy image data - if you repeat a mask to match an image batch, the masks are identical by design, so a "per-frame mask" built this way is only correct when every frame genuinely shares the same protected region. When frames differ, generate per-frame masks instead; this node is the wrong tool and no amount of repeating fixes that.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| amount | INT | 11–64 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| repeated_masks | MASK | — |