Nodes/Nilor Nodes by Nilor Corp/๐Ÿ‘บ Repeat, Shuffle, & Trim Image Batch
ComfyUI Node

๐Ÿ‘บ Repeat, Shuffle, & Trim Image Batch

Make a batch of exactly N images from a smaller pile โ€” shuffled, not just tiled

By nilor-corpยทCreated 2 years agoยทUpdated 6 months agoยท 6
๐Ÿ‘บ Repeat, Shuffle, & Trim Image Batch
  • images
  • images
โ—„seed0โ–บ
โ—„count1โ–บ

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 count images, 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.

CategoryNilor Nodes ๐Ÿ‘บ/Utilities

Inputs (3)

NameTypeDefaultDescription
imagesIMAGEโ€”
seedINT00โ€“9007199254740991โ€”
countINT11โ€“9007199254740991โ€”

Outputs (1)

NameTypeDescription
imagesIMAGEโ€”