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 2 days agoΒ· 107
πŸ“‚ Load Images From Path
    • image
    • mask
    • current_index
    • total_count
    • output1
    • output2
    • output3
    • output4
    • output5
    • output6
    • output7
    • output8
    • output9
    • output10
    • output11
    • output12
    • output13
    • output14
    • output15
    • output16
    • output17
    • output18
    • output19
    • output20
    • output21
    • output22
    • output23
    • output24
    • output25
    • output26
    • output27
    • output28
    • output29
    • output30
    • output31
    • output32
    β—„include_subfoldersfalseβ–Ί
    β—„seed0β–Ί
    β—„input_pathβ–Ί
    β—„path_formatpath/file.extβ–Ί
    β—„extra_path_formats[]β–Ί

    πŸ“‚ 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 (5)

    NameTypeDefaultDescription
    include_subfoldersBOOLEANfalseInclude images from all subfolders of the selected folder.
    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.
    path_formatCOMBOpath/file.extAbsolute folder path and filename, including the extension. Example: C:/image.png
    extra_path_formatsoptSTRING[]Formats for additional path/file outputs.

    Outputs (36)

    NameTypeDescription
    imageIMAGEThe image at the selected index.
    maskMASKAlpha channel of the image, or fully black if it has none.
    current_indexINTIndex actually loaded: the seed wrapped around the number of files found.
    total_countINTHow many images were found at the path.
    output1STRINGThe loaded image's path or filename in this output's selected format.
    output2STRINGThe loaded image's path or filename in this output's selected format.
    output3STRINGThe loaded image's path or filename in this output's selected format.
    output4STRINGThe loaded image's path or filename in this output's selected format.
    output5STRINGThe loaded image's path or filename in this output's selected format.
    output6STRINGThe loaded image's path or filename in this output's selected format.
    output7STRINGThe loaded image's path or filename in this output's selected format.
    output8STRINGThe loaded image's path or filename in this output's selected format.
    output9STRINGThe loaded image's path or filename in this output's selected format.
    output10STRINGThe loaded image's path or filename in this output's selected format.
    output11STRINGThe loaded image's path or filename in this output's selected format.
    output12STRINGThe loaded image's path or filename in this output's selected format.
    output13STRINGThe loaded image's path or filename in this output's selected format.
    output14STRINGThe loaded image's path or filename in this output's selected format.
    output15STRINGThe loaded image's path or filename in this output's selected format.
    output16STRINGThe loaded image's path or filename in this output's selected format.
    output17STRINGThe loaded image's path or filename in this output's selected format.
    output18STRINGThe loaded image's path or filename in this output's selected format.
    output19STRINGThe loaded image's path or filename in this output's selected format.
    output20STRINGThe loaded image's path or filename in this output's selected format.
    output21STRINGThe loaded image's path or filename in this output's selected format.
    output22STRINGThe loaded image's path or filename in this output's selected format.
    output23STRINGThe loaded image's path or filename in this output's selected format.
    output24STRINGThe loaded image's path or filename in this output's selected format.
    output25STRINGThe loaded image's path or filename in this output's selected format.
    output26STRINGThe loaded image's path or filename in this output's selected format.
    output27STRINGThe loaded image's path or filename in this output's selected format.
    output28STRINGThe loaded image's path or filename in this output's selected format.
    output29STRINGThe loaded image's path or filename in this output's selected format.
    output30STRINGThe loaded image's path or filename in this output's selected format.
    output31STRINGThe loaded image's path or filename in this output's selected format.
    output32STRINGThe loaded image's path or filename in this output's selected format.