Image Batch Repeat Interleaving (Swwan)
How to make every frame of a batch hold still for two beats
- images
- mask
- IMAGE
- MASK
The pack's own description is the clearest thing anyone could write about this node, so here it is: a batch of 5 images - 0, 1, 2, 3, 4 - with repeats=2 becomes 10 images: 0, 0, 1, 1, 2, 2, 3, 3, 4, 4.
That's torch.repeat_interleave(..., dim=0), and the word interleaving in the name is doing real work. This is not Repeat Image Batch. Repeat Image Batch (core, and its clones) concatenates the batch with itself: 0,1,2,3,4,0,1,2,3,4. That's a loop. Repeat Interleaving is a hold - every frame gets N consecutive copies, so the sequence stays in time.
Inputs and outputs
Required: images (IMAGE) and repeats (INT, default 1, range 1–4096). Optional: mask (MASK). Outputs: IMAGE and MASK.
That mask output is the interesting half, and it's the reason this node is worth reading the source on. If you wire a mask in, it gets the same interleaving applied - frame-accurate, no surprises. If you don't wire one, the node doesn't return nothing; it builds one. The generated mask is a batch of original_count * repeats frames with a 1.0 on the first frame of each repeat group and 0.0 everywhere else.
Read that again, because it's a genuinely useful convention: the auto-mask marks "this is the real, generated frame; the next N-1 are duplicates." Filter or mask on it and you can process once per source frame while the padded sequence keeps its length. In practice that's how you stop a per-frame effect from being applied twice to identical pixels.
What you'd actually use it for
Three real cases, in descending order of how often they come up:
Frame pacing. rife-style interpolation and Video Combine both eat frame counts. Duplicating each frame 2× or 3× slows a fast sequence down without touching your sampler settings, and unlike resampling it doesn't invent tween pixels. Crude, but sometimes crude is what you want before an actual interpolator.
Per-frame conditioning sweeps. If each image in the batch is a different LoRA weight, prompt variant, or noise level, interleaving gives each variant N rendered frames instead of one, so a downstream video combination shows the variation long enough to judge.
Cache-friendly re-rolls. Some pipelines only re-render frames whose conditioning changed. Duplicate frames with a mask that marks only the group leaders will let you keep the group aligned while skipping work.
The traps
repeats is per-image, not a total count. repeats=3 on a 4-image batch gives you 12 frames, not 3. Everyone gets this wrong once.
The generated mask has shape (B*repeats, H, W) - it expands to the full spatial size of the image, not a single scalar per frame. Some mask consumers are happy with that, some want [B,1,H,W], and a few will happily broadcast the wrong thing without complaining. Check the shape at the consumer if something downstream looks like a uniform grey wash.
And note the leftover print("mask shape", mask.shape) in the implementation - harmless, but it will spam your console on every run and there's nothing wrong with your install.
Install
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan.git
cd ComfyUI_Swwan
python -m pip install -r requirements.txt
Windows portable users run the requirements file with the embedded interpreter:
.\python_embeded\python.exe -m pip install .\ComfyUI\custom_nodes\ComfyUI_Swwan\requirements.txt
Restart, hard refresh the browser, search Swwan - it's under Swwan/Advanced/Batch. It's pure tensor work (torch is already in your ComfyUI environment), so there's nothing to download and nothing that can fail on a missing model.
If you're migrating from an old workflow and get a missing-node box: this ID is a straight rename from KJNodes' ImageBatchRepeatInterleaving in the pack's 1.0.0 namespace migration, and the pack deliberately registers no competing aliases. python scripts/migrate_workflow.py old.json --dry-run from the repo root will show the rewrite before it touches your file.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| repeats | INT | 11–4096 | — |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |