YC Image Accumulator
Batch up every generation, then pick the winner after
- image
- images
- masks
The usual way to compare generations in ComfyUI is to run a big batch, save everything, and flip through files. YCImageAccumulator is the in-graph version of that habit: it accumulates images across runs, shows you the whole gallery in the node's preview, and lets you pick any one of them to output - or output a slice as a batch. It's a "run 30 seeds, choose the good one" node, and once you've used it you'll miss it in every other workflow.
How it works
The node is stateful - that's the whole point. Every run, whatever image arrives at its image input gets appended to an in-session gallery stored in ComfyUI's temp folder. Only metadata (filename, size, timestamp) stays in memory; full images are written to disk, so it doesn't balloon your VRAM as the gallery grows. selected_index decides what comes out: -1 means the most recent image, 0 the first, anything else that slot. clear_gallery wipes the accumulated images and starts a fresh session.
Because full-res images are saved to a temp folder, the gallery survives across runs within a session - but it is not a permanent store. Flip save_to_output and a copy also lands in your output directory, which is what you want when you finally pick the keeper.
The inputs that matter
- image - the image to accumulate. Anything: VAE output, an upscaler's result, a composite.
- selected_index - output picker,
-1= latest. You'll set this after eyeballing the gallery. - clear_gallery - set to true once, run, set back to false to start a fresh batch.
- max_images - cap (default 30). When full, new images replace a slot per
update_positioninstead of growing forever. - batch_start / batch_end - switch from single output to a slice.
start=0, end=2outputs images 0,1,2 as a batch. - align_mode / pad_color - when outputting a batch of mixed-aspect images, how to align them (first/largest/smallest) and what color pads the mismatches.
Outputs are images and masks (in batch mode the masks mark the content region versus the padding you added with pad_color - that's how you composite mixed-size results back onto one canvas), and it's marked as an output node so the gallery shows in the UI.
How to actually use it
Wire your sampler's output into it, set clear_gallery true for one run to reset, then loop different seeds/denoise/prompts. The node fills up, you scroll the preview, set selected_index to the winner, and that image flows downstream. It shines in workflows where the "best" choice depends on taste you can't automate - character work, composition roulette - and in any A/B where you don't want to re-render to compare.
Installing it
Part of ComfyUI-YCNodes. ComfyUI Manager → search ComfyUI-YCNodes → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes
Restart. Only torch/PIL needed.
Gotchas
The statefulness cuts both ways. If you're on a fresh session and the gallery is empty, the node doesn't error - it returns a 64×64 black placeholder with a white mask, which can look like a bug if you don't read the console ([ImageAccumulator] 图像库为空). And because it persists per session, a workflow you load later won't magically restore yesterday's gallery; it starts empty. Also note update_position only matters once max_images is hit - set both, or the "replace slot" behavior never triggers. The node's own console logging ([ImageAccumulator]) is surprisingly chatty and tells you exactly what it's replacing, which makes debugging painless.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | 要累积的输入图像 | |
| selected_index | INT | -1-1–999 | 选择要输出的图像索引。-1表示最新图像,0表示第一张 |
| clear_galleryopt | BOOLEAN | false | 清空所有累积的图像 |
| max_imagesopt | INT | 301–100 | 最大累积图像数量,超过后会替换指定位置的图像 |
| update_positionopt | INT | -1-1–99 | 达到上限后,新图像替换的位置。-1=最后一张,0=第1张,1=第2张... |
| batch_startopt | INT | -1-1–99 | 批次输出起始索引。-1=单张输出(使用selected_index),0开始=批次输出 |
| batch_endopt | INT | -1-1–99 | 批次输出结束索引。例如:start=0,end=2输出3张(0,1,2) |
| align_modeopt | COMBO | largest | 批次对齐模式:first=第一张尺寸,largest=最大尺寸,smallest=最小尺寸 |
| pad_coloropt | STRING | #000000 | 扩图填充颜色(十六进制,如 #000000=黑色, #FFFFFF=白色, #808080=灰色) |
| save_to_outputopt | BOOLEAN | false | 是否将累积的图像也保存到output目录(持久化) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |