Mie Loop Collect Image ๐
Gather one image per loop pass into a batch
- loop_ctx
- image
- loop_ctx
Looping is only half the story - you also need to keep what each pass produces. MieLoopCollectImage accumulates one image per iteration into the loop's context, so that when the loop finishes you can pull the whole set out as a batch. It's the "append to the results list" step of a MieNodes loop.
Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under the ๐ Loop submenu.
How it works
Each pass, you wire this pass's generated image into the node, and it stashes it inside the loop_ctx alongside everything already collected. The context threads onward, so on the next iteration the new image is added to the growing pile. When MieLoopEnd reports done, MieLoopFinalizeImages reads the accumulator and emits the full image batch. Collect gathers; Finalize hands over.
This is the piece that turns "generate ten images one at a time" into "get ten images out of one run" - the answer to the copy-pasted-sampler-chain problem that sends people to the ComfyUI API.
The inputs and outputs that matter
loop_ctx(MIE_LOOP_CTX) - the loop context.image(IMAGE) - this iteration's image to collect.offload_to_disk(BOOLEAN, default false) - the important one for long loops. Holding many full-resolution images in memory across dozens of passes is how you blow up VRAM/RAM. Turn this on and each collected image is written to disk instead of piling up in memory, then reassembled at finalize time.offload_dir(STRING, default empty) - where those offloaded images go. Leave empty for the default location, or point it at a directory you control.- Output
loop_ctx- the context with this image added, to pass along.
Installing it
ComfyUI Manager โ search ComfyUI-MieNodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
then restart. No model downloads or heavy dependencies. Under ๐ MieNodes โ ๐ Loop.
Common issues
Out-of-memory on a long loop. This is the classic failure. Collecting fifty 1024px images in memory is a lot of VRAM/RAM. Turn on offload_to_disk - that's exactly what it's for. Pair it with MieLoopFinalizeImages's avoid_oom option, which is on by default, to keep the finalize step from re-stacking everything at once.
My batch is empty at the end. The collected images live in the loop_ctx. If the context chain got broken - Collect's output not carried forward, or Finalize reading a different context - you finalize an empty accumulator. Keep loop_ctx threaded from Collect through to Finalize.
Different image sizes. If passes produce different resolutions, stacking them into one batch can be awkward. Resize to a common size before collecting if you need a clean uniform batch out the other end.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ | |
| image | IMAGE | โ | |
| offload_to_diskopt | BOOLEAN | false | โ |
| offload_diropt | STRING | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |