Smart Loop Preview Image | akatz-loops
Preview Every Loop Iteration Without the Node Explosion
- images
- images
Put a normal Preview Image inside a loop and you'll quickly learn why that's a mistake: every time the loop's graph expands for a new iteration, ComfyUI treats it like a new node instance, and your preview list becomes a wall of near-identical entries you can't tell apart. SmartLoopPreviewImage is the fix - a preview node built for exactly this, one that knows it lives in a loop and shows you each iteration's result in a way that's actually useful.
It does two things a stock preview can't. It tags every saved image with its loop iteration number (_iter000, _iter001, …) so you can see at a glance which pass produced which result. And it offers two display modes:
- latest (default) - show only the most recent iteration's images.
- gallery - accumulate across all iterations and show the whole run in one preview panel, so a 10-pass loop gives you a 10-image gallery instead of ten separate preview widgets.
The mechanism is grounded in the loop mechanics themselves: the node keys its bookkeeping on ComfyUI's display_id - the stable node identity that survives graph expansion - rather than the per-expansion internal id. That's how it knows two iterations are "the same node," and it's why the accumulators get reset automatically at the start of every execution via a server hook (the pack patches execution_start and also exposes a POST /akatz-loops/reset_preview_accumulators endpoint). On a new run, gallery mode starts clean instead of mixing last run's frames into this one's.
Inputs and outputs
- images (required) - the IMAGE batch from inside your loop body.
- display_mode (required, enum) -
latestorgallery. - images (output) - the input image passed straight through, so the node can sit inline in the loop's data flow without breaking it.
It's an output node (is_output_node), so it runs regardless of caching and shows its results in the UI. That passthrough output is the nice touch: you can preview and keep the data flowing to the loop's accumulator in one wiring.
Install
Part of Akatz-Loop-Nodes (akatz-ai). Via ComfyUI Manager, search "Akatz-Loop-Nodes"; or:
cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/Akatz-Loop-Nodes
Restart ComfyUI. The pack's only dependency is opencv-python (used by its other image nodes), no model downloads. The custom_nodes.ComfyUI-Execution-Inversion module path on listings is lineage from BadCafeCode's execution-inversion demo - not a package you install.
The one gotcha: because it saves to ComfyUI's temp directory and counts iterations per execution, leaving a workflow in gallery mode on a long loop can produce a big preview panel. If that bugs you, flip to latest - the iteration tag on filenames still tells you where each frame came from. And if a stale preview lingers after a failed run, queueing a new execution triggers the reset hook and clears it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| display_mode | COMBO | latest | 2 options: latest, gallery |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |