🔢 智绘_计数器加载
A folder stepper that remembers where it was
- 图像
- 文件名
- 当前索引
Most loaders give you one image, full stop. This one gives you one image and a counter, then steps forward through a folder every time it runs. Wire it into a workflow that executes repeatedly - a batch loop, an animation pass, an A/B session where you want the next reference each run - and it feeds you frame 1, then 2, then 3, without you touching anything.
It's from ComfyUI-ZhiHui (智绘灵箱), a small Chinese-language utility pack that borrows freely from the Dapao-Toolbox project. It's genuinely obscure in English-speaking circles - the pack gets zero mentions across the r/comfyui / r/StableDiffusion corpus - so expect the node to work fine but the docs to be in Chinese. The display name is "🔢 智绘_计数器加载".
How it works
The node keeps a counter as state on the node object. Each run it picks an index based on counter_mode, loads that file, then advances the counter by step. Because that state lives in memory, the counter survives between runs but resets on a ComfyUI restart - and it resets automatically if you point it at a different folder.
The modes matter more than you'd think:
- 循环递增 (default) -
index = counter % total, then increment. This is the one you want for looping animations; it wraps forever and never throws. - 顺序递增 / 顺序递减 - steps through and clamps at either end instead of wrapping, so the last frame just sits there.
- 随机选择 - ignores the counter and rolls a random index. Handy, though at that point you might as well use the pack's dedicated random loaders.
If the folder path doesn't exist or is empty, it returns a 512×512 black image plus an error message string instead of crashing the graph - the "safe" pattern you'll see all over this pack.
The inputs and outputs that matter
- folder_path - raw OS path to the folder. Leave it blank and it falls back to
ComfyUI/input, which is the classic default behavior. - counter_mode, step, start_index - the stepping behavior.
- reset_counter - flip this to true to snap the counter back to
start_index. - file_filter - optional, comma-separated globs like
*.png,*.jpg; defaults to the usual raster formats.
Outputs: 图像 (IMAGE), 文件名 (STRING, the bare filename), and 当前索引 (INT, the 0-based index that was loaded). The index is the useful one - feed it into a filename node or a text splitter to keep names in sync with what got loaded.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git
Restart ComfyUI (or reload via ComfyUI Manager). This node only needs the pack's base deps - torch, numpy, Pillow - so there are no model downloads here. ComfyUI Manager search works too: look for "ComfyUI-ZhiHui" or "智绘灵箱".
Where people get burned
The big one: this node has no IS_CHANGED hook, and ComfyUI caches results by input values. If you re-run the same workflow with identical inputs, ComfyUI may hand you the cached frame instead of re-executing the node - so the counter looks stuck at frame 1. The plumbing rule that bites here is the same one from comfyui-node-plumbing.md: a node that must fire every run needs to tell the engine it changed, and this one doesn't bother. Workaround: nudge any widget (toggle reset_counter off and on), or convert a widget to input and vary it per run. Also remember the counter resets when the graph reloads, so a "resume where I left off" workflow across sessions won't actually resume.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | 图片文件夹路径(留空使用ComfyUI/input) | |
| counter_mode | COMBO | 循环递增 | 5 options: 顺序递增, 顺序递减, 循环递增, 循环递减, 随机选择 |
| step | INT | 11–100 | 每次步进数量 |
| start_index | INT | 00–10000 | 起始索引 |
| reset_counter | BOOLEAN | false | 重置计数器到起始位置 |
| file_filteropt | STRING | *.png,*.jpg,*.jpeg,*.webp | 文件过滤器(用逗号分隔) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |
| 文件名 | STRING | — |
| 当前索引 | INT | — |