ComfyUI Node

sch_image

Pick one frame out of a batch by index

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
sch_image
  • images
  • selected_image
current_frame0
max_frames99999

A plain, useful little utility: hand it a batch of images and an index, and it hands back the one image at that index. That sounds trivial until you're building anything frame-driven - prompt scheduling across an AnimateDiff run, feeding a different reference image per frame of a longer sequence, driving a loop where each iteration needs to pull the next item out of a batch that was assembled earlier in the graph. This node is the pack's answer to "give me item N," built to live inside that kind of scheduling setup rather than as a one-off. It's the image sibling of sch_mask, which does the identical job for mask batches.

The pack's README lists dedicated batch-loading nodes (IO_LoadImgBatch, IO_LoadTextBatch, IO_LoadShotBatch) alongside its animation-control stack, and this node's data/schedule category places it in that same family - it's meant to sit downstream of a batch assembled elsewhere in the graph, selecting from it frame by frame.

The inputs and outputs that matter

  • images (required, IMAGE) - your image batch. Anything that outputs a batch works: a loader that pulled in a folder of frames, a batch built from an animation pass, or images concatenated together earlier in the graph.
  • current_frame (required, default 0, range 0–99999) - the index into that batch. This is the value you'd typically drive from an external loop counter, a PrimitiveNode incrementing across queue runs, or a sch_image node paired with whatever mechanism is stepping through your sequence.
  • max_frames (required, default 99999, range 1–99999) - an upper bound on the frame range, presumably for clamping current_frame or for coordinating with other schedule-aware nodes that need to know the sequence length. Set it to your actual batch size if you're relying on it for anything beyond the default pass-through.
  • Output: selected_image - a single image, the one at current_frame in the input batch.

How to install it

Search ComfyUI-Apt_Preset in ComfyUI Manager, or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

install.bat handles Windows dependencies; on Linux or Mac, open it, read the pip installs, and run them yourself, or let ComfyUI Manager fill gaps on first load. No model files needed - this is pure batch indexing.

Common issues & troubleshooting

Out-of-range index. If current_frame is set beyond the actual size of your images batch, don't expect a graceful fallback - check what your install actually does (error versus clamping versus wrapping) before relying on it in an automated loop, since batch-index nodes across different packs handle this differently and this pack's README doesn't spell it out.

Same image every time in a loop. This usually means current_frame isn't actually being driven by anything - it's sitting on a fixed widget value rather than being fed from an incrementing source. Wire in whatever's advancing your loop counter, rather than typing a static number into the widget.

Batch order doesn't match what you expected. The index is purely positional - it trusts whatever order the batch arrived in from upstream. If your source loader sorts alphabetically but you assumed chronological order (or vice versa), fix the sort at the loader, not here.

Want to select by something other than a raw index - a timestamp, a percentage through the sequence. This node only does index-based selection; you'd need to convert whatever your actual scheduling logic is into a frame index upstream before it reaches this node.

CategoryApt_Preset/data/schedule

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
current_frameINT00–99999
max_framesINT999991–99999

Outputs (1)

NameTypeDescription
selected_imageIMAGE