筛选图像
Keep frames 0, 2 and 5 and bin the rest of the batch
- images
- 筛选图像
A batch in ComfyUI is one tensor with a frame dimension, and there's no index operator in the node graph - you can't just type images[2]. Generated a batch of eight and want frames 3, 5 and 8 to go somewhere else? You need a node that does the indexing. This is that node, and it's small enough to describe completely in a paragraph.
What it does
You give it images (an IMAGE, i.e. a batch tensor) and indexes, a multiline string of comma-separated numbers starting at 0. It returns 筛选图像 - a new IMAGE containing exactly those frames, in the order you wrote them.
That's it. No mode switch, no size handling. It's the read side of a batch, sitting next to 图像批次合并 which is the write side.
The details worth knowing
It does not sort. 5,3,0 gives you frame 5, then 3, then 0. This makes the node an accidental reorderer, which is genuinely useful - a sequence you assembled in the wrong order gets fixed by editing one text field. It also means the common "I expected ascending order" surprise is on you, not a bug.
Bad indexes are skipped, quietly. Out-of-range and non-numeric tokens are dropped, and if nothing survives the whole selection you get frame 0 back - a fallback so the graph keeps moving. Multiline works because each token gets stripped: newlines are only a separator in practice, so keep the commas between your indexes.
The empty case returns the black stub. If the input batch is empty, you get a single 64×64 all-black frame rather than a zero-length batch, because an empty list breaks downstream nodes. That stub is the convention in this pack - 图像批次合并 has a 跳过黑色占位图 switch that detects exactly this 1×64×64 black image and treats it as an empty input. So the two nodes are designed to be wired back to back, and if you feed the filter's output somewhere else, that black frame is your problem to spot. It looks like a tiny legitimate image in a preview grid, which is how people end up with mystery black frames in their batches.
The output is a single IMAGE, not a list. Selecting one frame gives you a batch of one. That's what makes it composable - anything taking IMAGE takes this.
Typical uses
Hitting the sweet spot of a sampler's batch and only keeping the last frame for a hires pass. Picking keyframes out of a video batch for a comparison grid. Feeding the same frame to two different branches by duplicating the wire rather than the node. Or recovering a segment of frames after an upstream node changed count on you.
Paired with a save node, index-based selection is also a cheap way to name outputs: pick frame 0, save it with one prefix, pick frame 3, save it with another - instead of restructuring the graph.
Install
One of 16 nodes in yanhuo-easy-use (category yanhuo, Chinese node labels, MIT, v1.3.1). ComfyUI Manager → search yanhuo-easy-use, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuoxunxianren/yanhuo-easy-use
# restart ComfyUI
No pip install - the pack declares no dependencies and imports only what ComfyUI already ships. No models, no downloads. The pack's nodes are Chinese-labelled in the canvas even though the class names are English.
Common issues
"The output only has one image." Correct if you gave one index. Check the batch size upstream though - if you thought you had a 4-frame batch and you got frame 0, one of your indexes was out of range and the fallback kicked in.
"There's a black 64×64 image in my batch now." Your input batch was empty. Something upstream produced nothing; find it rather than filtering again.
"Frames came out in the wrong order." They came out in the order you typed. Reorder the list.
"I need frames 100–140." Type them out, or restructure so an upstream node outputs just that range. There's no range syntax here.
"I want to drop one frame without listing the rest." No exclusion. Write the include list. Worth knowing before you build a workflow around a 40-frame batch.
The list-versus-single-batch distinction that shows up in every one of these troubleshooting entries is a core ComfyUI convention rather than something this pack invented - docs/knowledge/comfyui-node-plumbing.md explains where it comes from and why empty lists are treated as poison.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | 要筛选的图像批次(batch) | |
| indexes | STRING | 0, 1, 2 | 逗号分隔的索引(从 0 起),如 0,2,5;也支持多行。超出范围的索引会被忽略。 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 筛选图像 | IMAGE | 按指定索引从批量图像中筛选出的帧(顺序保持)。 |