list_fliter
The batch cleaner that drops dead frames before they poison your loop
- images
- masks
- images
- masks
If you've ever run a batch loop where a segmentation node quietly returns nothing for one frame, or a video-splitting step hands you an empty tensor, you know the failure mode: one bad item in a batch poisons everything downstream, and the error message tells you nothing. list_fliter (yes, "fliter" - the author's typo, and it's in the class name so it's permanent) is the pack's answer. It takes an image list and/or a mask list and drops the dead entries before they reach the rest of the graph.
It lives in the Apt_Preset/data/list|Batch category, which is exactly the kind of plumbing you rarely think about until you need it - and then you're glad it's there.
How it works
The node splits a batch tensor into individual items, then validates each one:
- Always filtered:
None, non-tensor values, empty tensors, and tensors with a zero-sized dimension. - Type-checked: items must be a valid IMAGE (3D or 4D) or MASK (2D or 3D) shape for the socket they arrive on.
filter_zero_content(default on): also drops fully-black images and fully-zero masks. The author's own description calls this out explicitly - when enabled, "全0图像、全0遮罩也会被过滤" (all-zero images and masks get filtered too).
The output order is preserved; only the dead weight is removed. And it returns proper lists (both outputs are OUTPUT_IS_LIST), so it plays correctly with ComfyUI's batch/list loop machinery.
Inputs and outputs
- filter_zero_content (BOOLEAN, default true) - the only required input. On = also strip all-zero content; off = only strip structurally invalid items.
- images (IMAGE, optional) - an image batch or list to clean.
- masks (MASK, optional) - a mask batch or list to clean.
Outputs: images (IMAGE list) and masks (MASK list). Feed the outputs into whatever consumes the batch downstream.
Installing it
It's part of ComfyUI-Apt_Preset:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
# install.bat or pip install -r requirements.txt, restart
Or ComfyUI Manager → search "ComfyUI-Apt_Preset".
Where it earns its keep
The classic scenario is an inpainting or segmentation loop where a frame has nothing to detect - the upstream node returns an all-black mask, and the next node either chokes or hallucinates. Drop list_fliter between them and the empty frames vanish instead of crashing your queue.
The one thing to be careful about: the filter only drops, it never repairs. If you filter out the all-zero masks and then try to zip the surviving images with surviving masks by index, the alignment shifts - mask #3 in the output corresponds to whatever image it actually came from, not to image #3 in the original batch. If your downstream logic assumes aligned indices, re-run the pairing through the same filter, or turn filter_zero_content off and handle empties yourself.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| filter_zero_content | BOOLEAN | true | — |
| imagesopt | IMAGE | — | |
| masksopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |