Tensor Index Switch
Pick one picture from a stack by number
- index
- input_a
- input_b
- input_c
- input_d
- input_e
- input_f
- input_g
- input_h
- input_i
- input_j
- input_k
- input_l
- input_m
- input_n
- input_o
- input_p
- input_q
- input_r
- input_s
- input_t
- input_u
- input_v
- input_w
- input_x
- input_y
- input_z
- output
- resolved_index
- count
If a boolean switch is a fork in the road, this is a railway turntable: up to 26 candidate pictures in, one number in, and exactly the picture you pointed at comes out. It's the node you reach for when the choice isn't a clean true/false but "which of these many images do I process this run?"
What it is
"Tensor image" is WAS Node Suite's slightly formal way of saying an image, a mask or a latent - the three things that live on the wire as tensors. The switch accepts all three, and here's the neat part: the first connection fixes the type. Plug an IMAGE into slot A and every other slot and the output lock to IMAGE, so you can't quietly mix a latent into an image chain. Anything else gets refused at the socket, which catches the mistake while you're drawing the wire instead of at run time.
You drive it with the index input (INT, NUMBER or FLOAT all accepted; decimals just get truncated). Feed it a Number Counter or a loop's index and you can step through a stack of images one per run. Two niceties make it genuinely useful in loops:
- Negative indices count from the end.
-1is the last connected slot, so you don't need to know the count to grab the final picture. - Out-of-range handling is your choice.
wrapcycles round again (index 4 of 3 slots gives slot 1 - perfect for a counter that only climbs),clampsticks at the first or last slot, anderrorstops the prompt. If a missing entry means something's broken upstream,erroris the honest setting.
What comes out
The obvious output is output - the selected image/mask/latent. But it also reports resolved_index (the slot actually read, after wrap or clamp - genuinely useful when a counter drives the index and you want to know which frame you got) and count (how many slots are actually connected, since an unconnected slot isn't counted and index 0 is the first slot wired).
That last detail trips people up once: this is not a "connected slots a–z all counted" node. If you leave input_d empty, index 3 selects nothing useful, because only connected slots count. Wire them up in order and the indices line up with the letters.
Lazy, and why that matters
The unselected inputs aren't evaluated. If slot A runs a whole img2img pass and you pick slot B, the work behind A is simply skipped - no wasted VRAM or time. That's the difference between this and a "collect everything then pick" approach, and it's why these typed switches are the right tool for branching heavy pipelines.
It's a sibling of the two-way Tensor Image Switch (boolean, A/B) and the Any Switch / Any Input Switch family for untyped values. If your stack is a handful of pictures and a loop index, this is the one you want.
Installing it
Part of WAS Node Suite v3 (WASasquatch's was-node-suite-comfyui, MIT). Search "WAS Node Suite v3" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git
Restart ComfyUI afterward. Requires ComfyUI 0.14.0+ and Python 3.10+; no extra packages to install for this node.
Inputs (28)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT,NUMBER,FLOAT | 0-99999999–99999999 | Slot to pass on, from 0. Negative counts from the end: -1 = last. A decimal is truncated: 2.7 = 2. |
| out_of_range | COMBO | wrap | Index outside 0..count-1. With 3 slots and index 4: `wrap` = slot 1, `clamp` = slot 2, `error` stops the prompt. |
| input_aopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_bopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_copt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_dopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_eopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_fopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_gopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_hopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_iopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_jopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_kopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_lopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_mopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_nopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_oopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_popt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_qopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_ropt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_sopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_topt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_uopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_vopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_wopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_xopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_yopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_zopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Takes IMAGE, MASK or LATENT. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output | COMFY_MATCHTYPE_V3 | The selected input, typed to whatever was connected. |
| resolved_index | INT | Slot actually read, from 0, after wrap or clamp. |
| count | INT | Connected slots. The index runs 0..count-1. |