小珠光列表计数
How many images are in that list? One ANY input, one INT out, done
- 列表
- 数量
The moment a workflow hands you a variable number of images - a multi-image loader, a stack of video frames, an img2img batch - you'll need "how many are there?" as a plain integer. To loop over them, to sanity-check a count, to drive a progress readout. That's the entire job of 小珠光列表计数 - XiaozhuguangListCount: one ANY input, one INT output, zero opinion about what the list contains.
It's a ten-line node and it's supposed to be. The pack's own image loader has a "list" mode that emits however many images you dropped in, and its sibling XiaozhuguangImageFromList slices that list - but both leave you guessing at the total. This node closes that loop, and because it's tiny, it's also a nice window into how ComfyUI's list plumbing works.
How it works
The 列表 input is declared input_is_list, which is the important bit: the execution engine passes the node the entire list in one call rather than fanning each element out to it (the engine's broadcast behavior). Then it's just counting:
- a list or tuple →
len() - a single stacked batch tensor (the loader's "batch" mode output) → the batch dimension, so the number you get equals the number of images, not 1
- any tensor with a
.shape→ the first dimension - a dict → its length
None→ 0 (silently)
That batch-tensor special case is the part that actually matters. Without it, a batch-mode loader output wrapped in a one-element list would count as "1 image" and every downstream loop would silently run once. The author explicitly wrote this so "total = image count" holds in both list and batch modes.
Wiring it
One input (列表, type * - accepts anything), one output (数量, INT). Plug the pack's image loader list-mode output, or XiaozhuguangImageFromList's output, or really any multi-element IMAGE source, and feed the integer wherever a count belongs. It pairs naturally with the list-slicing node above: ask for a slice, and know how long the list actually was.
Installing it
It ships inside the ComfyUI-xiaozhuguang pack (小珠光) - a Chinese-community enhancement pack with a Bilibili tutorial and proper i18n. Install the pack, not the node:
cd ComfyUI/custom_nodes
git clone https://github.com/xiaozhuguang/ComfyUI-xiaozhuguang.git
then restart ComfyUI, or find ComfyUI-xiaozhuguang in ComfyUI Manager's custom-node installer. The pack's requirements.txt declares heavy dependencies (transformers, llama-cpp-python, librosa, bitsandbytes), but those are for its Qwen and TTS nodes - this counter needs nothing beyond what your ComfyUI already runs, and there are no model files involved.
Gotchas
Honestly, not much to trip over. None silently becomes 0, so a workflow that doesn't feed it anything reports zero rather than erroring - worth knowing if you're debugging a loop that isn't running. And because it counts by len(), it counts whatever the upstream node actually emitted, not what you think it should have emitted. If the number looks wrong, check the list upstream - the node is almost certainly counting correctly.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| 列表 | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 数量 | INT | — |