Nodes/Comfyui_LG_Tools/🎈LG_图像选择器
ComfyUI Node

🎈LG_图像选择器

Pick the keeper out of an 8-image batch — stop upscaling the other seven

By LAOGOU-666·Created 2 years ago·Updated 7 months ago· 366
🎈LG_图像选择器
  • images
  • selected_images
  • selected_indices
modealways_pause

You generated a batch of images and only one of them is actually good. ImageSelector is the node you put in front of everything expensive - the upscaler, the hires-fix pass, the final SaveImage - so only the keeper goes through.

Here's the situation it exists for. ComfyUI just hands you a tensor with N images in it. A batch of 8 comes out of the sampler as one big [8, C, H, W] blob, and every node downstream of it runs on all 8 whether you like it or not. PreviewImage will show you all of them, and SaveImage will save all of them. If you want to hires-fix just the good one, you need to cut the batch down to size first. That's the whole job of this node.

The author's own framing is honest about why it's needed: ComfyUI doesn't handle batch-generation seeds the way A1111 does (the README points at ComfyUI issue #165), so you can't just crank the batch count and expect eight varied images to farm a seed from. Instead, you end up with a batch you've already got - from an img2img run, a grid, multiple queue prompts - and you need to pick from it. The classic loop: PreviewImage to look at everything, then rewire SaveImage through ImageSelector with the index of the one you want.

How the index string works

The input is plain text, and the indexing is 1-based. Not 0-based - the author apologizes in the README, but a beginner will still trip on it. The first image is 1.

  • 1 - first image
  • 1,3,4 - the 1st, 3rd and 4th, in order
  • 2: - everything from the 2nd onward
  • :0 - everything except the last one (left bound inclusive, right bound exclusive, like Python slices)
  • 3:-1 - from the 3rd up to but not including the third-from-last, i.e. drop the first two and last two

A bare -1 as a single index picks the last image, since the resolved index is just handed to Python's tensor indexing. Anything that isn't an integer, or is out of bounds, is silently ignored. And here's a quiet trap: if nothing survives the parse, the node passes your whole batch through unchanged instead of erroring. A typo like 1,2,q doesn't throw - it just selects 1,2 and moves on.

Inputs and outputs

Two inputs, one output:

  • images (IMAGE) - the batch tensor
  • selected_indexes (STRING, default "1,2,3") - the comma/range string above
  • Output: IMAGE, the same tensor type with only the rows you asked for

Wire the output wherever you were sending the full batch - an upscaler, an img2img KSampler, SaveImage. The order of your selection is preserved, so 4,1 gives you the 4th then the 1st.

Install

It's a tiny, dependency-free pack - no requirements.txt, no models to download, nothing but the node code and a torch that ComfyUI already has. Either install it through ComfyUI Manager (search "Image Selector" or SLAPaper), or:

cd ComfyUI/custom_nodes
git clone https://github.com/SLAPaper/ComfyUI-Image-Selector

Restart ComfyUI. It also ships ImageDuplicator and the latent variants (LatentSelector, LatentDuplicator) in the same pack - you get all four for free.

Where people get burned

The big one is that this is a batch index picker, not a click-to-select node. ComfyUI reruns the whole graph when you change any value, so if you pick index 3 and the upstream sampler reruns, you get a new batch - and your chosen image is gone. People hit this constantly; the workaround is muting or bypassing the generation nodes upstream once you're happy with the batch, or just living with re-running. If you genuinely want to click on a preview and have that image continue downstream, there are interactive pickers that do exactly that (Preview chooser in the rgthree pack, cg-image-picker, and similar) - reach for those instead. ImageSelector is for the "I know the index, just gate it" workflow, and within that lane it's about as simple as a node gets.

Category🎈LAOGOU/Image

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
modeCOMBOalways_pause3 options: always_pause, keep_last_selection, passthrough

Outputs (2)

NameTypeDescription
selected_imagesIMAGE
selected_indicesSTRING