ComfyUI Node

TK 图像选择

Eight image wires, one output, five ways to choose

By Ararararararaki·Created 3 months ago·Updated about 16 hours ago· 10
TK 图像选择
  • image1
  • image2
  • image3
  • image4
  • image5
  • image6
  • image7
  • image8
  • image
  • source_index
  • source_name
mode优先顺序
priorityimage1
index1
seed0

Image routing is the least glamorous problem in ComfyUI and one of the most annoying. Your workflow has a Danbooru reference, a couple of your own renders you swap between, and a fallback. Which one goes into the sampler this run should not require re-dragging wires across the canvas.

TK 图像选择 is a five-mode image router: image1 through image8 in, one IMAGE out plus provenance. It's in TK Toolkit (anima-toolkit by 时运tk), the pack built around Anima workflows, and it's designed to sit between a reference source and an img2img stage.

The five modes

优先顺序 (priority order) is the default and the one most people settle on. You pick a priority channel in the dropdown; the node takes it if it's wired, and otherwise walks image1image8 and uses the first connected one. That's a fallback chain, not a selector - which is exactly what you want when one of your sources is optional this session. Note it falls through on unconnected inputs; a connected source that happens to be empty is still a connected source.

指定索引 takes index (1–8) literally. If that channel isn't connected, it errors rather than silently grabbing something else - deliberate, and correct. Silent wrong-image selection is a much worse failure than a red node.

随机 picks uniformly from the connected channels, freshly each run.

Seed 稳定 picks deterministically from seed, so the same seed always lands on the same channel. This is how you A/B two reference images reproducibly instead of hoping the RNG cooperates.

轮询 cycles through the connected channels, advancing one per execution. The node forces a re-run for this (IS_CHANGED), otherwise ComfyUI's cache would happily serve you the same image forever. Point it at a folder-ish upstream and you get rotation.

Inputs and outputs

Required widgets: mode, priority (image1–image8), index (1–8), seed. Optional sockets: image1 through image8 - all optional, so you connect two or eight, whatever you actually have.

Outputs are three:

  • image - IMAGE, and it's always a list, with your tensor in slot 0. That's not an eccentricity; it's what makes it drop straight in after a Danbooru gallery node, whose image output is a list, while still feeding ordinary single-image inputs downstream.
  • source_index - INT, 1–8, which channel won.
  • source_name - STRING, imageN.

Those last two are the underrated part. Wire source_index into a primitive and into your save filename, and your outputs tell you which reference produced them. Two weeks later, "why did that batch all look like the same character" has an answer in the filenames.

If every input is empty, the node raises. That's the one case it can't help you with.

The workflow it's built for

The pattern the author describes, and the one that works: gallery image on image1, your own reference on image2, a second custom source on image3. Default mode 优先顺序 with priority on image1. Now "use the booru image" and "use my character sheet" are a dropdown change, not four rewires. Disconnect image1 and the node quietly falls through to image2.

Anima makes this more than convenience. It shipped without ControlNet, so a lot of reference work happens at the img2img/denoise end of the pipeline, which means swapping the reference image is the main control you have. A router that makes that cheap is worth more here than it would be on an SDXL graph with a full ControlNet stack.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Ararararararaki/comfyui-anima-toolkit
# restart ComfyUI

ComfyUI Manager: search TK Toolkit (anima-toolkit). Only aiohttp and requests are required. The node registers under TK/image.

Gotchas

The output being a list trips people up. Feeding a list output into a node that takes a single IMAGE makes ComfyUI iterate, so downstream nodes can run once per image in the list. With one item in it that's invisible; it matters if you chain something that expands the list upstream of this node.

轮询 and caching. Round-robin needs the node to re-execute every queue, which it forces. If you've wrapped it in a group you section-bypass, that behaviour goes away with the bypass - as expected, but worth remembering when the rotation mysteriously stops.

Priority order is a fallback, not a preference ranking. There's exactly one priority value. It doesn't weight the rest; they go in ascending number order.

CategoryTK/image

Inputs (12)

NameTypeDefaultDescription
modeCOMBO优先顺序5 options: 优先顺序, 指定索引, 随机, Seed 稳定, 轮询
priorityCOMBOimage18 options: image1, image2, image3, image4, image5, image6, +2
indexINT11–8
seedINT0-9223372036854776000–9223372036854776000
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE
image6optIMAGE
image7optIMAGE
image8optIMAGE

Outputs (3)

NameTypeDescription
imageIMAGE
source_indexINT
source_nameSTRING