KY Load Images from Path
Multithreaded bulk loading, with the filtering to actually control it
- image_batch
- file_names
- mask_batch
This is the "load an entire dataset" loader in this pack's trio of image inputs - where KY_ReadImage gets you one file and KY_LoadImageFrom flexibly handles one path/URL/base64 at a time, this one is built for pointing at a folder and pulling in everything inside it as a single batch, in parallel, with real controls over what gets included and in what order.
What "multithreaded" buys you
The node's own description calls out the multithreading directly, and max_workers (default 8, up to 128) is the knob for it. Reading dozens or hundreds of image files off disk is I/O-bound work, and doing it with a thread pool instead of one file at a time is a straightforward, real speedup for a large folder - the kind of difference that matters when you're loading a training dataset rather than a handful of test images.
The filtering and ordering knobs
This is the more interesting half of the node, and worth actually using rather than leaving at defaults for anything beyond a quick test: recursive (default true) walks subfolders, not just the top-level directory - worth knowing up front, since it means a folder with an unrelated subfolder in it (an "originals" backup, a thumbnails cache) gets pulled in too unless you turn it off. extensions (default png,jpg,jpeg,webp,bmp,tif,tiff) is a comma-separated allowlist you can narrow. shuffle, sort_mode (name_natural/name_lex/mtime_asc/mtime_desc), select_every_nth, skip_first_images, skip_last_images, and limit (default 0, meaning no cap) all combine to let you pull a specific slice of a large folder - every 5th file, skip the first 200, cap at 500 - without touching the files themselves or restructuring the directory.
keep_alpha_mask (default true) preserves an image's alpha channel as a separate mask output rather than discarding it or flattening it into the RGB.
Inputs and outputs
Required: input_dir (STRING). Everything else above is optional with the defaults described. Three outputs: image_batch (IMAGE), file_names (STRING, marked as a list - one name per loaded image, in the same order as the batch), and mask_batch (MASK, populated from alpha when keep_alpha_mask is on).
file_names pairs directly with this pack's own KY_FilePathAnalyzer if you need to preserve original filenames through a processing pipeline - the loader gives you the names, the analyzer splits them into stem/extension for reconstructing output paths.
Installing it
ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/yorkane/ComfyUI-KYNode
Restart ComfyUI. No external dependencies beyond standard image libraries - nothing to download for the loader itself.
Common issues
recursive=true by default is the single most likely cause of "why did I get more images than I expected" - if your folder structure has any subfolders you didn't mean to include, set recursive to false or check extensions before assuming the loader is broken.
Every image loaded this way lands in one batched IMAGE tensor, which carries a real constraint worth knowing: ComfyUI image batches generally need matching dimensions across every item in the batch. A folder with mixed image sizes can error or behave unexpectedly here - this node's schema has no resize step of its own, so a mismatched-dimension dataset needs pre-processing (or a resize node inserted after this one) before it'll batch cleanly. That's a general property of how ComfyUI batches work, not something specific this node is failing at.
With limit at its default of 0 (no cap), pointing this at a genuinely large dataset loads the entire thing into one tensor at once - for a few hundred high-resolution images, that can be a real amount of VRAM/RAM. Use limit, skip_first_images/skip_last_images, or select_every_nth to chunk a large dataset into passes rather than loading it all in one shot if you hit memory pressure.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| input_dir | STRING | — | |
| recursiveopt | BOOLEAN | true | — |
| max_workersopt | INT | 81–128 | — |
| limitopt | INT | 00–999999 | — |
| shuffleopt | BOOLEAN | false | — |
| extensionsopt | STRING | png,jpg,jpeg,webp,bmp,tif,tiff | — |
| select_every_nthopt | INT | 11–999999 | — |
| skip_first_imagesopt | INT | 00–999999 | — |
| skip_last_imagesopt | INT | 00–999999 | — |
| sort_modeopt | COMBO | 4 options: name_natural, name_lex, mtime_asc, mtime_desc | |
| keep_alpha_maskopt | BOOLEAN | true | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image_batch | IMAGE | — |
| file_names | STRING | — |
| mask_batch | MASK | — |