Nodes/ComfyUI-mnemic-nodes/πŸ“‚ Load Images From Path
ComfyUI Node

πŸ“‚ Load Images From Path

Walk a whole folder of images one queue at a time

By MNeMoNiCuZΒ·Created 3 years agoΒ·Updated a day agoΒ· 105
πŸ“‚ Load Images From Path
    • image
    • mask
    • image_path
    • current_index
    • total_count
    β—„seed0β–Ί
    β—„input_pathβ–Ί

    πŸ“‚ Load Images From Path points at a directory and loads one image from it - whichever one the index says. Queue again and the index moves on. That's the whole design, and it's the thing the stock Load Image node can't do: iterate.

    The obvious workflows: running a batch of references through an img2img or ControlNet pipeline, captioning a dataset folder one image at a time, or turning a folder of frames into something. Instead of wiring twelve Load Image nodes and un-muting one at a time, you write one graph and let the queue walk the directory.

    Inputs

    input_path is the folder (or a single image file, which is the degenerate case). Relative paths resolve against ComfyUI's input/ directory. Supported extensions are PNG, JPG, JPEG, WEBP, BMP and GIF.

    One correction to the documentation, because it'll waste your time otherwise: the README says leaving the path empty defaults to the input directory. The shipped code raises Input path cannot be empty instead. Put a path in.

    seed is not a random seed at all - it's the index. The node does seed % total_count, so it wraps: on a 5-image folder, index 5 loads the first image again. To actually iterate, set the seed's Control After Generate to increment and queue repeatedly; each queue loads the next file and wraps around at the end.

    Outputs

    image is the tensor. mask is the alpha channel - or a solid black mask at image size if there isn't one, which is the sane behaviour for the majority of files that have no alpha.

    image_path gives you the full path of whatever it loaded, which is how you pair this with a metadata-extraction or caption-writing step per image. current_index is the index that actually got loaded after wrapping (useful when your seed has runaway), and total_count is how many files the node found - feed that into a random-pick node if you'd rather sample than sweep.

    Where people get burned

    Files load in alphabetical order, not numeric order. The node sorts the directory listing as strings, so 10.png, 11.png, 2.png is the order you'll get - not 2, 10, 11. If your folder is numbered frames or dataset images, zero-pad the names (002.png) or rename them before you rely on the sequence. This bites everyone once.

    No recursion into subfolders. The directory listing isn't walked; anything in a nested folder is invisible. Flatten your folder first.

    An empty or wrong-result folder fails quietly-ish. If no supported files are found, the node returns an empty image output rather than an exception, so an unhelpful type error shows up further down the graph. If your queue dies immediately with a complaint about None, count the images in the folder before suspecting the image itself.

    Watch out for files changing under it. Adding an image to the folder mid-run shifts every index after it, so your increment walk suddenly skips or repeats. Sort that out before long queues, not during.

    Install

    ComfyUI Manager β†’ search ComfyUI-mnemic-nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
    

    Restart ComfyUI. opencv-python and the rest of the pack's requirements come along for the ride; there's nothing to download for this node itself.

    Category⚑ MNeMiC Nodes

    Inputs (2)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000Index of the image to load, starting at 0. Increments every run by default to step through the folder.
    input_pathSTRINGPath to a folder containing images or a single image file.

    Outputs (5)

    NameTypeDescription
    imageIMAGEThe image at the selected index.
    maskMASKAlpha channel of the image, or fully black if it has none.
    image_pathSTRINGFull path of the file that was loaded.
    current_indexINTIndex actually loaded: the seed wrapped around the number of files found.
    total_countINTHow many images were found at the path.