Load Image as Mask without Listing Input Dir
The mask loader for when your input folder has thousands of files
- mask
- enabled
Stock ComfyUI's Load Image (as Mask) node has a quiet performance problem: every time it needs to build its file dropdown, it runs os.listdir on your entire input/ folder. That's instant with a few dozen files. It's noticeably not instant once you're running a batch pipeline that's dumped thousands of frames or masks into that directory - which is exactly the situation this node exists to fix.
What it's for
If you're doing anything programmatic - a script pushing hundreds of pre-rendered masks into ComfyUI's input folder, a video pipeline processing frame-by-frame, an automation loop calling the API repeatedly - the built-in loader's directory scan becomes a real, repeated cost on every single load. LoadImageMaskWithoutListDir avoids os.listdir entirely, so it stays fast regardless of how many files are sitting in the folder. For a one-off manual workflow with a handful of images, you won't notice a difference; this node earns its keep specifically at scale.
How it works
It's a drop-in replacement for the official Load Image Mask node with the slow directory enumeration removed - same job, same MASK output, just a different (and cheaper) way of resolving the file. On top of that it adds two conveniences the stock node doesn't have: a toggle to skip loading entirely, and a way to repeat the loaded mask into a batch.
The inputs and outputs that matter
image- the file picker, same as the stock node.channel(red/green/blue/alpha) - which channel of the source image becomes your mask. Alpha is the usual pick if your source has real transparency baked in; red/green/blue let you pull a mask out of a plain RGB image where one channel happens to encode what you want.enabled(default true) - flip this off and the node skips loading, which pairs with the node's ownenabledoutput: wire that into a downstream switch (like this same pack'sReferenceLatentSwitchor any bypass-style node) to conditionally skip a whole branch of your graph based on one toggle.mask_repeat_number(default 1) - repeats the loaded mask this many times to build a batch, useful when you need the same mask applied across a batch of images without a separate repeat node.
Outputs: mask (MASK) and enabled (BOOLEAN, the passthrough of your toggle).
How to install it
Via ComfyUI Manager: search "ComfyUI-utils-nodes," install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/zhangp365/ComfyUI-utils-nodes
Restart ComfyUI. No model downloads - this is a filesystem-access change, not a new capability, so there's nothing extra to fetch.
Common issues & troubleshooting
The custom-node ecosystem in general has a reputation for dependency headaches (conflicting requirements.txt across packs is a recurring community complaint), but this specific node doesn't add any Python dependencies of its own - it's a lighter-weight rewrite of functionality ComfyUI already ships, so it shouldn't introduce new conflicts.
The main thing to actually watch for is behavioral, not an error: because it deliberately avoids scanning the directory, don't expect the file dropdown to necessarily refresh and show a brand-new file the instant it lands on disk the same way the stock node's listdir-based picker would. If a file you just added doesn't show up immediately, that's the performance trade-off working as intended, not a bug - give the UI a refresh or restart if you're actively adding files mid-session rather than pre-populating the folder before you start.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 0 options: | |
| channel | COMBO | 4 options: red, green, blue, alpha | |
| enabledopt | BOOLEAN | true | — |
| mask_repeat_numberopt | INT | 1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| enabled | BOOLEAN | — |