Nodes/ComfyUI_Auto_Caption/Load Many Images
ComfyUI Node

Load Many Images

Load a whole folder of images in the order you actually exported them

By the-hexer·Created 2 years ago·Updated 10 months ago· 19
Load Many Images
    • image
    • mask
    • count
    • image_path
    folder
    image_load_cap50
    start_index0

    The folder loader that respects your numbering

    If you've ever fed a folder into ComfyUI's Load Image (dir) and watched it load img2 before img10, you already know the exact problem this node exists to fix. Batch captioning - which is what this pack is for - quietly breaks when images load out of order, because your captions stop matching your images. LoadManyImages ships inside Cyber-BlackCat's ComfyUI_Auto_Caption as the batch front end for the caption nodes: point it at a folder, and every image comes back as a list, sorted the way a human would sort it.

    How it loads

    Three inputs, all simple:

    • folder (required) - an absolute path to the directory. Missing folder or an empty one raises FileNotFoundError, so this isn't the place for a relative path.
    • image_load_cap (default 50, 0 = no limit) - and here's the trap: the default of 50 will silently truncate a folder with 200 images in it. There's no warning. If you're captioning a real dataset, set this to 0 or to your actual image count.
    • start_index (default 0) - skips the first N files. Handy for resuming a partially-captioned folder.

    Under the hood it filters to .jpg/.jpeg/.png/.webp, then sorts by the first number found in the filename - that's the part that beats a naive string sort, which is what gets you the 2-before-10 mess. Files with no number get pushed to the end. It also handles EXIF orientation, which folder loaders often forget.

    Outputs are all lists: image (the tensors), mask, count, and image_path (full paths - gold for pairing captions back to filenames when you save your .txt files).

    The catch, straight from the source

    As the code ships, load_images() returns a three-value tuple while the node declares four outputs (image, mask, count, image_path). That mismatch means ComfyUI can throw a "expected 4 outputs, got 3" error the moment the node executes. If you hit it, it's the pack, not you - the fix is a one-line edit in auto_caption.py:

    return (images, masks, len(images), image_path_list)
    

    Worth knowing before you build a whole dataset pipeline on this node, because "this loader is silently broken" is a bad discovery to make mid-batch.

    Wiring it up

    The intended flow: image (as a list) into the Auto Caption 2 node's image input - that node batch-processes lists, so one run captions the whole folder - then save each caption next to its image_path. The mask output is only meaningful for images with an alpha channel (it's the inverted alpha); images without one get a fixed 64×64 zero tensor, so don't build anything that assumes real masks.

    Installing

    Same pack as the loader's sibling nodes: ComfyUI Manager (search "ComfyUI_Auto_Caption") or

    cd ComfyUI/custom_nodes
    git clone https://github.com/Cyber-BlackCat/ComfyUI_Auto_Caption
    

    then restart. No model downloads needed for this node - it runs on the torch and Pillow ComfyUI already has, even though the pack's overall requirements.txt is heavy thanks to the captioning half. If you only want the loader, you don't need bitsandbytes or an 8B LLM anywhere near this.

    CategoryAuto Caption

    Inputs (3)

    NameTypeDefaultDescription
    folderSTRING
    image_load_capoptINT50
    start_indexoptINT0

    Outputs (4)

    NameTypeDescription
    imageIMAGE
    maskMASK
    countINT
    image_pathSTRING