Nodes/ComfyUI-ZiYun_LabelKit/Batch Load Images With Names
ComfyUI Node

Batch Load Images With Names

A batch image loader that actually hands you the filenames

By DNPMBHC·Created 11 months ago·Updated 8 months ago· 4
Batch Load Images With Names
    • IMAGES
    • MASKS
    • FILE PATHS
    • FILE NAMES
    • COUNT
    directory
    image_load_cap0
    start_index0
    load_alwaysfalse
    sort_method

    Every ComfyUI install can already batch-load images - core's Load Image takes one file, and the VHS-style folder sweepers turn a whole directory into a tensor batch. So why does a tiny pack called ZiYun LabelKit ship another one? Because the others throw away the one thing a labeling pipeline needs: the filename. Batch Load Images With Names (category ZiYun/Toolbox) reads every image out of a folder and returns it five ways at once - the image tensors, the masks, and the file paths and names as plain strings, all kept in the same order. If your workflow's job is "load 200 photos, run a tagger over them, and write a <filename>.txt caption back for each," this is the node the boring ones were missing. The pack's own one-line description says it plainly: an image-loading node built to "streamline batch labeling workflows by retrieving image filenames." No API, no model download, no key. Just a directory reader with the receipts attached.

    How it works

    Give it an absolute path to a directory and it lists the files, filters to .jpg, .jpeg, .png, and .webp (.jxl too, but only if pillow_jxl happens to be importable - it isn't in the requirements, so JXL is off by default), then optionally sorts them, skips the first start_index files, and decodes. Each image gets exif_transpose applied so phone photos aren't sideways, and is converted to an RGB float tensor scaled to 0–1. The mask output is built from the alpha channel and inverted - white where the image is transparent, matching ComfyUI's usual mask convention - or a zero mask for files with no alpha. One more trick worth knowing: flip load_always on and the node returns NaN from its change-detection hook, which is the ComfyUI idiom for "run me every single time, cache be damned." Handy when the folder changes between runs, but remember it also forces everything downstream to re-execute, so a workflow that feels needlessly slow often has an always-dirty node like this poisoning the graph.

    The inputs and outputs that matter

    Four optional inputs sit on top of the one required field, and honestly only a couple of them matter on day one:

    • directory (required) - paste the full path. It's a text box, not a folder picker, and it does not recurse into subfolders; only files directly inside are loaded.
    • sort_method - this is the one to set if order matters. "None" is raw OS directory order, which is arbitrary. "Numerical (ASC)" pulls the first run of digits out of each filename and sorts on that, so img_2 beats img_10 - exactly what you want for frames or sequential scans.
    • image_load_cap - cap how many images load. 0 means unlimited, not "load zero," which trips people.
    • load_always - re-read the directory on every queue instead of relying on caching.

    The outputs, in order: IMAGES and MASKS (Python lists of tensors, not one stacked batch - see the gotcha below), FILE PATHS (full absolute paths), FILE NAMES (basename without extension), and COUNT as a plain INT. That last trio is the whole point: wire FILE NAMES into a text-handling node while IMAGES feeds the tagger, and every row of your caption file lines up with the right source image.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/DNPMBHC/ComfyUI-ZiYun_LabelKit.git
    

    Restart ComfyUI. It's also listed in ComfyUI Manager if you'd rather search "ZiYun LabelKit" there. Dependencies are numpy, Pillow, and torch - all already present in any working ComfyUI install, so there's nothing extra to download and no models to fetch. The README is Chinese-language and brief; this node is the entire pack.

    Where people get burned

    • Missing or empty directory - the node doesn't error, it silently returns empty lists and a COUNT of 0, with only a warning in the console. If you get zeros, double-check the path.
    • List outputs don't wire into single-tensor inputs. Because the first four outputs are lists, plugging IMAGES straight into a node that expects one image tensor fails type-checking. Feed them into something list-aware, or let a batch node handle the list first.
    • "None" sorting is not random, but it might as well be across OSes and filesystems. Pick a sort method whenever the output order matters downstream.
    • The masks are inverted alpha - if you don't need transparency info, just leave that socket unplugged instead of fighting it.

    It's not the flashiest node in your graph, and with zero community chatter around it, you're mostly on your own beyond this page. But for dataset work it fills a genuinely annoying gap: a batch loader that tells you which image it loaded.

    CategoryZiYun/Toolbox

    Inputs (5)

    NameTypeDefaultDescription
    directorySTRING
    image_load_capoptINT0
    start_indexoptINT0-1–18446744073709550000
    load_alwaysoptBOOLEANfalse
    sort_methodoptCOMBO7 options: None, Alphabetical (ASC), Alphabetical (DESC), Numerical (ASC), Numerical (DESC), Datetime (ASC), +1

    Outputs (5)

    NameTypeDescription
    IMAGESIMAGE
    MASKSMASK
    FILE PATHSSTRING
    FILE NAMESSTRING
    COUNTINT