Nodes/Claude CLI (Vision+Text)/Image Batch Current Index
ComfyUI Node

Image Batch Current Index

Your per-frame iteration, with a number attached

By RandyHaylor·Created 4 months ago·Updated 4 months ago· 1
Image Batch Current Index
  • images
  • image
  • index
index_offset0

ComfyUI is happy to loop over a batch for you - that's the whole point of a node graph that iterates per item. What it doesn't do is tell you which item you're on. Image Batch Current Index is the missing counter: it turns an IMAGE batch into a list of single-frame tensors while emitting the matching frame number as a parallel list of INTs. One input, two synchronized outputs, and any downstream node that takes a single IMAGE and a single INT gets called once per (frame, index) pair.

Why does the index matter? Because a per-frame analysis usually wants to know where it is. "Describe frame 7," not just "describe this." You wire the image output into whatever consumes frames, and route index wherever the number needs to live - into a text-formatting node that builds "frame N" into your prompt, into save/filename logic, or into any decision that depends on position in the clip. It's the kind of node that seems pointless until the day you're trying to figure out which of 200 frames produced that weird generation, and suddenly it's the whole workflow.

How it works

The trick is a ComfyUI flag called OUTPUT_IS_LIST - set on both outputs, which tells the scheduler to iterate downstream once per list item. The node also sets INPUT_IS_LIST, so it tolerates either a single batch or a list of batches and flattens them into frames in order. The index_offset input is the whole feature in one knob: default 0 means frames are numbered 0, 1, 2…; set it to 1 and they start at 1 (nicer for humans); run a second instance with offset 1 alongside your first and you get "current + 1" for pair-consecutive workflows.

Inputs and outputs

  • images - an IMAGE batch, a single image, or a list of batches.
  • index_offset - INT, default 0, range minus-a-million to plus-a-million. The starting number for the emitted indices.

Outputs are just the two:

  • image - list of single-frame tensors, one per frame in the flattened batch.
  • index - list of INTs, one per frame, starting at index_offset.

Installing it

Part of the same small pack as the Claude node, but like the other utility nodes here it's pure tensor handling - no Claude Code, no login, no API key. Grab it from ComfyUI Manager by searching "Claude CLI (Vision+Text)" or clone directly:

cd <ComfyUI>/custom_nodes
git clone https://github.com/RandyHaylor/comfyui-claude-cli-vision-text-node.git

Restart ComfyUI and hard-refresh the browser tab (Ctrl+Shift+R). No extra pip install - numpy, torch, and Pillow are already in ComfyUI's environment, and that's the entire dependency list.

The traps

  • The iteration only fires when something downstream actually consumes the list output. If you wire only image and ignore index, you still get per-frame iteration - the two lists stay in lockstep, so you can add the index wire later without reworking anything.
  • index_offset counts from zero by default. If your "frame 1" mental model keeps colliding with 0-based reality, that +1 isn't a bug - it's the knob.
  • This node gives you one integer per frame. If you need a pair of consecutive indices in one call, the source's own docstring suggests the clean route: a parallel instance with offset 1, or add 1 downstream with a math node.
Categoryutility

Inputs (2)

NameTypeDefaultDescription
imagesIMAGE
index_offsetINT0-1000000–1000000

Outputs (2)

NameTypeDescription
imageIMAGE
indexINT