Count Objects [LP]
Counting whatever's connected to it, with a running offset
- input
- INT
The README states this one plainly: "counts the number of objects that were fed to the input (this can be a list or one single object). Accepts any type of input." It lives in the pack's Image category, but don't let that fool you - the input type is a bare * (anything), so this works just as well counting text entries, tag lists, or file lists as it does images. It's a general-purpose counter that happens to have been filed next to the image nodes.
Why you'd want this
This pack is built for the loop-and-condition style of automation ComfyUI workflows increasingly lean on - folder-driven batch pipelines, conditional branches, things that need to know "how many" before deciding "what next." A batch of images loaded from a folder, a list of tags assembled from several sources, a set of results accumulated across a loop - all of those are exactly the shape of thing this node measures. Real published automation workflows that chain together folder-based image loading and conditional logic do reach for this pack specifically for utility nodes like this one.
How it works
Feed it anything. If what you connected is list-like, it counts the entries; if it's a single object (one image, one string, whatever), it counts as one. The base_value input then gets added on top of that count - which is the detail that makes this more than a plain len() call. It's built to double as an accumulator: run this node inside a loop, feed the previous iteration's output back in as the next iteration's base_value, and you've got a running total without wiring up separate math nodes to do the addition yourself.
The inputs and outputs that matter
- input - accepts any type (
*), the thing being counted. - base_value - an INT, default
0, minimum0. Added to the count ofinputrather than replacing it - this is your offset or running total, not a base count override. - Output - a single INT: the count of
input, plusbase_value.
How to install it
ComfyUI Manager: search "ComfyUI Level Pixel" or ComfyUI-LevelPixel, install, restart - updates automatically via Manager's "Update ALL." Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git
Restart ComfyUI. No models, nothing else needed - it's pure Python counting logic.
Common issues & troubleshooting
The count is higher than you expected. Check what's plugged into base_value first - it's easy to forget you left an accumulator wired in from a previous experiment, and the output is always count(input) + base_value, not just count(input) alone.
A single object came back as a count of 1 when you expected a list count. That's the "accepts any type" behavior working as documented - a lone image, string, or object that isn't wrapped in a list counts as exactly one item, not zero. If you expected a list and got a single object instead, the mismatch is likely upstream, not in this node.
You want to reset the running total instead of accumulating. Just don't feed a previous count back into base_value - leave it at the default 0 for a plain one-shot count, and only wire in a feedback loop when you actually want accumulation across iterations.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | — | |
| base_value | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |