Image Batch Filter
Scrubbing dead-black frames out of a batch
- images
- replacement_image
- images
- removed_indices
Anyone who's run a big batch job has hit this: somewhere in a hundred generated frames, a handful come back solid black (or whatever your "nothing here" color is) - a failed VAE decode, a masked-out region, a step that just didn't produce anything. Image Batch Filter's whole job is finding those and dealing with them, so you don't have to eyeball the whole batch yourself.
Why you'd want this
It's a cleanup step for batch pipelines: video frame sequences, img2img sweeps, anything where you're generating many images at once and some non-trivial fraction can come back essentially empty. Rather than manually scanning for blanks, this node compares every image in the batch against a reference "empty" color and either drops the bad ones or swaps in a replacement - and, importantly, tells you which indices it touched, so you can keep other batch-aligned data (masks, captions, metadata) in sync with whatever got removed.
That last part matters more than it sounds. If you strip frames 12 and 47 out of an image batch but you've got a parallel mask batch or a caption list running alongside it, silently dropping indices without reporting them would desync everything downstream. The removed_indices output exists specifically so you can propagate the same removal elsewhere in your graph.
How it works
For each image in the batch, the node checks how close it is to empty_color within empty_threshold tolerance. Anything close enough counts as "empty." What happens next depends on whether you've supplied a replacement_image: with one connected, empty frames get swapped for it; without one, they're simply dropped from the output batch.
The inputs and outputs that matter
images- your input batch (required).empty_color(default"0, 0, 0", i.e. black) - the RGB reference value that counts as "empty."empty_threshold(0–1, default 0.01) - how close a frame has to be toempty_colorto be flagged. Small values mean only near-perfect matches count; raise it if your "blank" frames aren't pure black but close to it (compression artifacts, near-black noise).replacement_image(optional) - if connected, empty frames are replaced with this instead of being removed outright, which keeps your batch length constant.
Two outputs: images (the filtered or replaced batch) and removed_indices - a string listing which positions in the original batch were flagged, so you can align other data to the change.
How to install it
- ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, thenpip install -r ComfyUI-KJNodes/requirements.txt(portable:python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart.
No models needed - this is a straightforward pixel-comparison filter.
Common issues & troubleshooting
Frames that look blank aren't getting caught. If your "empty" frames aren't pure black - a near-black gradient, slight noise, a different fill color entirely - either raise empty_threshold so near-matches count, or change empty_color to match what your actual blank frames look like. The default (0,0,0 at a tight 0.01 threshold) only catches near-exact black.
Good frames are getting removed. The opposite problem: if empty_threshold is too generous, legitimately dark images (a night scene, a mostly-black composition) can get misidentified as empty. Tighten the threshold, or check whether your actual dark frames are the ones disappearing before assuming they're broken.
Downstream batch-aligned data is now out of sync. This is the thing to build around from the start, not fix after the fact - use removed_indices to drop or replace the same positions in any parallel batch (masks, prompts, filenames) rather than assuming batch lengths still line up after filtering.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| empty_color | STRING | 0, 0, 0 | — |
| empty_threshold | FLOAT | 0.010–1 | — |
| replacement_imageopt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| removed_indices | STRING | — |