๐บ Shuffle Image Batch
Shuffle the order of an image batch, reproducibly, with one seed
- images
- images
Sometimes the fix for a weird result is just "the order was wrong." ComfyUI processes batches in order, and when a batch gets reused across passes - training-data style workflows, prompt-variation sweeps, feeding a batch through an upscaler twice - the same images keep meeting in the same pairs. ๐บ Shuffle Image Batch reorders your batch so that doesn't happen, and it does it reproducibly: one seed, one shuffle, every time.
Under the hood it's as simple as it gets. The node generates a random permutation of the batch indices with torch.randperm, seeded from your seed, then indexes the batch with it. Same seed โ same order, always, which means you can shuffle for variety but still reproduce a run exactly when you need to. That seedability is the difference between this being a debugging tool and a data pipeline tool. Set a fixed seed, and the shuffle becomes part of your workflow's identity - the same input batch always gets the same reshuffle, so results stay comparable across runs. Change the seed and you get a fresh arrangement.
It also plays well with the rest of this pack's batch utilities. Shuffle a batch before tiling it up with Repeat & Trim, and you get a pseudo-random spread instead of a periodic tile. Wire a seed from the pack's ๐บ User Input (Seed) node and you can randomize it from the UI each pass. The pieces are meant to chain.
Inputs and output
- images - the IMAGE batch to reorder.
- seed - shuffle seed, 0 to a very large number.
- images (output) - the same images, same count, different order.
Installing it
Part of 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 a heavy dependency set (boto3, fastapi, huggingface_hub, openexr) regardless - par for the course with this pack.
Troubleshooting
The source validates the batch is non-empty and 4D, so an unbatched image or empty tensor errors immediately. The only real gotcha is expectation: a shuffle is a permutation, not a change - every image still appears exactly once, and a batch of 1 or 2 "shuffles" into itself. And a shuffle gives you variety, not new data; if you wanted more images than you started with, this isn't the node. As with everything in this pack, there's no community support to lean on - the ๐ Nilor-Nodes error prefixes and the source are what you have. One nice property to exploit: because the seed fully determines the order, two identical runs with the same seed are bit-for-bit identical, which is exactly what you want when you're hunting down a non-deterministic bug upstream.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | โ | |
| seed | INT | 00โ9007199254740991 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | โ |