ZML_多图选择
Pick one of five images by index — or by luck
- 图像1
- 图像2
- 图像3
- 图像4
- 图像5
- 选择的图像
ZML_ImageSelectorNode (ZML_多图选择, "multi-image select") is a tiny routing node with one job: you feed it up to five images and it outputs exactly one, chosen either by an index you set or at random. It's the kind of node that looks like filler until you realize random selection is genuinely useful, and then it's the node you reach for constantly.
It's from ComfyUI-ZML-Image, zml-w's 160+ node pack, added in an October 2025 update. It lives in the plain image subcategory.
How it works
Wire up to five images into 图像1 through 图像5 - only 图像1 is required; the rest are optional. Set 索引选择 (index, 1–5) to output a specific input, or flip 随机选择 (random) on to pick one at random. The backend just clamps the index into the list of connected images and passes the winner straight through, no re-encoding, no resize.
The one subtle mechanism is caching. When random selection is on, the node returns a special "always changed" marker so ComfyUI re-executes it every run - that's what makes it actually re-roll instead of caching the first pick forever. It's the same trick every random node in the ecosystem uses under the hood; this one just does it for images.
What it's actually for
The README's own suggestion is the fun one: combine it with the pack's YOLO auto-censor node - run content detection, and if the image is "unsafe," output a random safe image instead. The selector becomes a cheap content-filter gate.
More boringly, it's great for:
- A/B testing on autopilot - feed five variations, enable random, and let every run show a different one.
- Random reference for img2img - pick a random reference from a small set to vary output.
- Index-driven switching - drive the index from another node (an integer node, a step counter) to sequence through images deterministically.
- Gacha workflows - the pack is built around "text block" images and prompt libraries; random-selecting between saved samples is a natural fit.
The inputs and outputs that matter
- 图像1 (required IMAGE), 图像2–5 (optional IMAGE) - your pool. Only connected inputs count toward the selection.
- 索引选择 - 1–5; values beyond the number of connected images clamp to the last one.
- 随机选择 - boolean; on overrides the index.
- Output: 选择的图像 (the chosen IMAGE). Single image, always.
Installing it
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
restart ComfyUI, or ComfyUI Manager → search "ComfyUI-ZML-Image". No models needed for this node itself; the pack's heavy requirements (OpenCV, scipy, ultralytics) belong to siblings like the YOLO censor it's meant to pair with.
Where people get caught
The index counts connected inputs, not "1–5 in your head." If only 图像1 and 图像3 are wired, index 3 points at 图像3's position in the list, not "third connected image." And because random mode forces a re-run every execution, a workflow with this node will happily re-roll downstream stuff too - put it before the expensive parts only if you actually want a fresh pick each run. If you want to hold a choice, turn random off and lock the index.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| 图像1 | IMAGE | — | |
| 索引选择 | INT | 11–5 | — |
| 随机选择 | BOOLEAN | false | — |
| 图像2opt | IMAGE | — | |
| 图像3opt | IMAGE | — | |
| 图像4opt | IMAGE | — | |
| 图像5opt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 选择的图像 | IMAGE | — |