Nodes/Claude CLI (Vision+Text)/Split Image Batch to List of Image Batches
ComfyUI Node

Split Image Batch to List of Image Batches

Turn a wall of frames into pairs Claude can actually chew on

By RandyHaylor·Created 4 months ago·Updated 4 months ago· 1
Split Image Batch to List of Image Batches
  • images
  • sub_batches
  • start_index
  • end_index
  • sub_batch_count
sub_batch_size2
stride0
last_sub_batch_policykeep_remainder

This is the quiet workhorse of the pack, and honestly the one you'll reach for even if you never touch the Claude node. Split Image Batch to List of Image Batches takes one IMAGE batch and hands you a list of smaller batches. That one word - list - is doing all the work: in ComfyUI, a node that outputs a list makes the scheduler call everything downstream once per item. So feed it a 240-frame video and you get, say, 120 calls of 2 frames each, instead of one call with 240 frames stuffed in.

Why care? Because this pack's headline node, ClaudeCliVisionText, runs claude -p once per call. Feed it a giant batch with send_all_frames on and you're asking Claude to think about hundreds of images in a single prompt - slow, expensive, and worse output. Feed it pairs and you get cross-frame reasoning ("do these two frames show the same person?") at a fraction of the cost. The splitter is the piece that makes that workflow sane.

How it works

Three knobs, and only one of them is confusing:

  • sub_batch_size (default 2) - frames per sub-batch. That's your pair.
  • stride (default 0) - how many frames to advance between sub-batches. 0 means "same as sub-batch size," i.e. a clean non-overlapping partition. 1 gives a sliding window. Any other value is a custom stride. The node even prints a hint under it: "stride 0: stride = sub-batch size."
  • last_sub_batch_policy (default keep_remainder) - what to do with the ragged tail. keep_remainder returns whatever's left as a short final batch; drop_remainder throws it away; pad_with_last pads the tail by repeating the final frame.

For a batch of 8 with size 3 and keep_remainder, you get [0:3], [3:6], [6:8] - with each sub-batch's original start and end indices reported alongside.

Inputs and outputs

The inputs are the three above plus images. The outputs are the part people miss:

  • sub_batches - the list of IMAGE sub-batches (this is the one you wire into Claude, or anything that takes an IMAGE).
  • start_index / end_index - parallel lists of INTs giving each sub-batch's original-batch position, for labeling or tracking.
  • sub_batch_count - a single INT, handy for reporting.

Installing it

Same as the rest of the pack - and note the nice part: this node is pure torch slicing. It does not need Claude Code installed, no claude login, nothing. Clone it or grab it from ComfyUI Manager (search "Claude CLI (Vision+Text)"):

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

Restart, hard-refresh the browser tab (Ctrl+Shift+R). No pip install - just numpy, torch, and Pillow, which ComfyUI already has.

The traps

  • keep_remainder gives you a ragged last batch. Claude handles it fine, but if you're doing anything that expects uniform sizes, reach for pad_with_last - and know that it repeats the final frame, which is a duplicate image, not a new one.
  • drop_remainder silently eats your tail frames. If you need full coverage of the video, that's how you quietly lose the last N seconds.
  • With stride smaller than the batch size, frames overlap between sub-batches and get analyzed more than once. Sometimes that's the point (sliding windows); if you're counting tokens per frame, it's a leak.
  • The node expects a proper (N,H,W,C) tensor and will tell you off in plain English if you hand it something flattened.
Categoryutility

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
sub_batch_sizeINT21–1024
strideINT00–10240 = non-overlapping (same as sub_batch_size). 1 = sliding window. Any other value = custom stride.
last_sub_batch_policyCOMBOkeep_remainder3 options: keep_remainder, drop_remainder, pad_with_last

Outputs (4)

NameTypeDescription
sub_batchesIMAGE
start_indexINT
end_indexINT
sub_batch_countINT