selectLatentFromBatch _O
Pick one latent out of a batch
- samples
- LATENT
You set a batch size of 4 in the KSampler and got a batch of latents back. Now you want to run a second pass, an upscale, or a detail pass on just one of those four images - not the whole batch. ComfyUI has no obvious "pick image #2 out of this tensor" node at the front door, and that's exactly the hole selectLatentFromBatch _O fills. Feed it a batch LATENT and an index, get back a single-image LATENT.
It lives in the O/latent folder of the Quality of Life Suit pack, alongside the latent upscalers. If you've ever generated a batch, loved #3, and wished you could cheaply push only that one through a hi-res fix - this is the node.
How it works
The source does the simple tensor thing: it reads the batch size, checks your index, and slices out one sample with samples[index].unsqueeze(0) - which reshapes a single item back into a batch of one so downstream nodes still see a valid LATENT. It's exactly what you'd hope: no interpolation, no blending, just selection.
samples(LATENT) - a batched latent, e.g. from a KSampler with batch size > 1.index(INT) - which one to pick, zero-based. Index 0 is the first image, index 3 is the fourth. Default 0, min 0.
One output: LATENT, a batch-of-one containing your chosen sample.
The one behaviour worth knowing: if you give it an index beyond the batch size, it silently clamps to the last image (batch_size - 1) instead of erroring. So index = 99 on a batch of 4 gives you image #4, not a crash. Convenient, but it also means a typo in the index can quietly pick the wrong frame - check your numbers if the output surprises you.
Where it fits
This is the enabler for selective second-pass workflows. Batch-generate a few variations, pick the winner by index, then run only that latent through a low-denoise resample or a latent upscale followed by VAE decode. It's also handy for iterating: keep the batch node, try different index values to push each candidate through the detail pass without regenerating.
Honest limits: there's no visual preview of "which one is index 2," so you'll often identify the winner by counting the preview grid (and the console printouts from the upscale nodes can help you confirm which sample you grabbed). If you need to see candidates first, decode the whole batch to images, pick a number, then come back to this node.
Installing it
Part of the Quality of Life Suit pack (omar92/ComfyUI-QualityOfLifeSuit_Omar92). Install via ComfyUI Manager (search "Quality of Life Suit") or clone:
cd <ComfyUI>/custom_nodes
git clone https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92.git
Restart ComfyUI properly. No models, no dependencies.
Common issues
- "The output is a different size than the input." It's not - it's a single frame where the input was a batch. If it looks different in size, check what you're comparing against.
- "I keep picking the wrong one." Zero-based indexing. Batch of 4 → valid indices are 0–3, and out-of-range values silently clamp to the last frame. Count from zero, not one.
- "I wanted multiple images." This node returns one. Repeat it per index or look at batch-splitting nodes if you need several.
- "Can I feed it a computed index?" Yes -
indexaccepts wire input, so feed it fromEquation1param _Oorint _Oif your pick is derived.
It's a one-liner wrapped in a node, and one-liners are exactly what a batch workflow is missing when it's four images deep.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| samples | LATENT | — | |
| index | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |