Nodes/OmniNodes/Batch Counter πŸ”’
ComfyUI Node

Batch Counter πŸ”’

A Counter That Survives Restarts β€” and Hands You a Fresh Seed Every Run

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Batch Counter πŸ”’
    • count
    • derived_seed
    β—„counter_iddefaultβ–Ί
    β—„step1β–Ί
    β—„resetfalseβ–Ί
    β—„base_seed0β–Ί
    β—„seed_step1β–Ί

    Every ComfyUI user eventually wants the same thing: hit "Queue" ten times, get ten different images without touching anything. The built-in way is the seed widget's control_after_generate = randomize, but that's a random roll every run - you can't predict or reproduce the sequence, and if you're farming variations you often want a pattern, not chaos. Batch Counter is the deterministic answer: a counter that increments once per queued run and derives a seed from its count, so run N always uses the seed you expect.

    The mechanism is the part that makes it trustworthy. Most counter nodes keep their state in memory, which means they reset every time ComfyUI restarts - or worse, when another node unloads models and the garbage collector clears them. This one writes a tiny counter file into ComfyUI's output/ folder and reads it back on every execution. The count survives restarts, crashes, and midnight ComfyUI updates. That file persistence is the whole selling point.

    The inputs that matter

    • counter_id - names the counter file (<id>.counter under output/), so you can run several independent counters side by side, one per workflow. Change it and the count starts fresh.
    • step - how much the counter advances each run (default 1).
    • reset - zeroes the counter on this execution. Nice touch: a reset run still counts, ending at step rather than 0, so you never get handed a useless zero seed.
    • base_seed and seed_step - these are how you get the actual seed. derived_seed = base_seed + count * seed_step. Keep seed_step at 1 for consecutive seeds, or bump it to skip around.

    The two outputs are count and derived_seed. Wire derived_seed into any seed input (or a KSampler's seed socket) and the graph gives you a new, reproducible seed on every queue run - no manual incrementing, and you can predict exactly what seed run #7 used by doing the arithmetic in your head.

    Pairing it

    The README's own suggestion is the good one: pair it with OmniNodes' Prompt List Iterator, which reads prompts from a file and returns the Nth one. Feed the counter's count into the iterator's index and each queue run steps through a prompt list and rolls a fresh seed - a poor man's batch queue without any extra infrastructure.

    Install

    In ComfyUI Manager search for OmniNodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TensorVizion/OmniNodes
    

    Restart ComfyUI, find it under TensorVizion/Workflow. No extra dependencies.

    Gotchas

    This node forces itself to run every execution (it returns NaN from IS_CHANGED, the standard "always re-run" trick), so it will never be skipped by ComfyUI's caching. That's correct behavior - but if you're chasing a mysterious slowdown, know that any node wired behind a counter like this also re-runs every time, because its input changed. And if you want the same seed twice, remember the counter doesn't care: it increments unconditionally, so use a fixed seed or reset instead of expecting it to hold still.

    CategoryTensorVizion/Workflow

    Inputs (5)

    NameTypeDefaultDescription
    counter_idSTRINGdefaultβ€”
    stepINT11–100000β€”
    resetBOOLEANfalseβ€”
    base_seedINT00–18446744073709550000β€”
    seed_stepINT10–1000000β€”

    Outputs (2)

    NameTypeDescription
    countINTβ€”
    derived_seedINTβ€”