๐บ Repeat, Shuffle, & Trim Image Batch
Make a batch of exactly N images from a smaller pile โ shuffled, not just tiled
- images
- images
Batch-size problems are the most annoying kind of problem in ComfyUI. Some node downstream insists on exactly N images, and you've got 7, or 23, or a number that never divides evenly. ๐บ Repeat, Shuffle, & Trim Image Batch is the sledgehammer for that: it takes whatever batch you have, repeats it as many times as needed, shuffles the result, and cuts it off at exactly the count you asked for.
The useful part is the shuffle. Rather than just tiling your source batch in order - which gives you [1,2,3,1,2,3,1,2], visibly periodic and obviously fake - it re-randomizes each repeat with torch.randperm before stacking. Same seed, same order; change the seed, get a different arrangement. That makes it the right tool for data-loading style jobs: building a training-ish batch, feeding a node that wants a fixed count, or bulk-processing where you want each pass to see a different mix without writing a dataloader. If you need a fixed count but don't want randomness, use the pack's plain Repeat & Trim Image Batch instead - same node minus the shuffle.
One honest caveat: this produces duplicates. With a 3-image source and count of 9, each image appears roughly three times, shuffled. That's fine for augmentation and batch-filling, but it is not a way to invent new data.
Inputs and output
- images - your source IMAGE batch.
- seed - the shuffle seed. Same seed, same shuffle order every run; change it to vary the mix.
- count - the exact number of images you want out. Minimum 1.
- images (output) - a batch of exactly
countimages, same dimensions as the source.
Installing it
Comes with Nilor Nodes (nilor-corp/nilor-nodes):
cd ComfyUI/custom_nodes
git clone https://github.com/nilor-corp/nilor-nodes
or ComfyUI Manager โ search "Nilor Nodes" โ install โ restart. No model downloads. The README lists Kijai's comfyui-kjnodes as a prerequisite, and the pack pulls heavyweight deps (boto3, fastapi, huggingface_hub, openexr) even for a batch utility like this one.
Troubleshooting
The source validates that your input is a non-empty 4D tensor (batch, height, width, channels), so feeding it a single unbatched image or an empty batch raises immediately. Two practical gotchas beyond that. First, an empty check only catches zero frames - if you feed it a batch of 1 and ask for count 10, you get the same image 10 times, shuffled into meaninglessness. Second, this pack has no community presence to ask for help, so read the error messages (they're prefixed ๐ Nilor-Nodes) and trust the source. And remember: duplicates are by design. If you need 10 distinct images, generate them first.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | โ | |
| seed | INT | 00โ9007199254740991 | โ |
| count | INT | 11โ9007199254740991 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | โ |