LayerUtility: Batch Selector
Batch Selector — pull specific images out of a batch by index
- images
- masks
- image
- mask
You generated a batch of eight, or you've got a stack of video frames, and you only want a few specific ones - the third, the fifth, and the last. Batch Selector is how you grab them by index without splitting the batch by hand. Type the positions you want, wire in your batch of images (and/or masks), and out comes just those.
It's a small plumbing node that saves a lot of fiddling. Anywhere you've got a batch and need a subset - cherry-picking the good seeds from a grid, isolating keyframes from a video batch, feeding one chosen frame downstream while previewing the rest - this is the clean way to do it.
How it works
You give it a selection string of indices, and it returns the images (and masks) at those positions, in the order you listed them. Indexing starts at 0, so the first image is 0. Because you control the order and can repeat entries, it doubles as a reorder/duplicate tool, not just a filter.
The inputs and outputs that matter
select(STRING, default"0,") - the index list, comma-separated.0,2,4pulls the first, third, and fifth. The trailing comma in the default is just the node being forgiving about formatting.images(optional) - the batch to select from.masks(optional) - a matching batch of masks, selected in parallel.
Both inputs are optional so you can run it on images, masks, or both. Outputs are an image batch and a mask batch containing your picks.
How to install it
Part of the LayerStyle pack. Via ComfyUI Manager: search LayerStyle, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt
then restart. Find it under 😺dzNodes → LayerUtility → SystemIO. No model download.
Common issues & troubleshooting
You got the wrong frame - off by one. Indices are zero-based. Image "number 1" in your head is index 0 here. To grab the third image, type 2.
An index is out of range. If you ask for 10 from a batch of 5, that entry has nothing to return. Keep your indices within the batch size; a good habit is to check the batch count from an upstream preview first.
Masks and images don't line up. If you wire both, make sure they're the same batch length and order - the node selects the same indices from each, so a mismatched pair gives you mismatched picks.
The node isn't there. The LayerStyle pack failed to import - usually a broken transformers dependency (a stray TensorFlow is the common one) crashing the whole pack on load, so every LayerStyle node vanishes at once. This node needs none of that itself; it just can't appear if its pack won't load. Read the traceback, use "Try Fix," or repair the library.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| select | STRING | 0, | — |
| imagesopt | IMAGE | — | |
| masksopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |