Nodes/WWAA-CustomNodes/🪠️ WWAA Image Batch Loader
ComfyUI Node

🪠️ WWAA Image Batch Loader

A batch image loader that remembers where it left off

By hgabha·Created 2 years ago·Updated 5 months ago· 36
🪠️ WWAA Image Batch Loader
    • image
    • current_index
    • total_images
    • filename
    • caption
    directory_path
    file_extensionALL
    reset_indexfalse
    sort_methodnumerical
    reload_directoryfalse
    read_captionfalse
    starting_index0

    The WWAA Image Batch Loader is the node that walks a folder of images in order and hands you one at a time - and it's the rare loader that remembers its position between runs. Point it at a directory, and every time your workflow executes it returns the next image in the sequence, wrapping around to the start when it runs out. That makes it the backbone of a batch-processing workflow: load image 1, process it, save it, re-run, load image 2, and so on, without you touching the graph.

    It's built by the WeirdWonderfulAI.Art team (the same people behind the LLM Prompt To Text File node), and those two slot together neatly for captioning and LoRA-testing pipelines: the loader feeds each image to a vision model, and the writer logs the result.

    How it works

    The node keeps its state on the instance: current index, the sorted file list, and the settings it last scanned with. It only rescans the directory when the path, extension filter, or sort method changes, or when you toggle reload_directory - so it's cheap to re-run. Sorting is where this stands out from ComfyUI's basic loader: numerical does a natural sort so img2.png comes before img10.png, alphabetical is plain A–Z, creation_time and modification_time order by file timestamps, and windows_sort mimics Windows Explorer ordering (it falls back to a natural sort on non-Windows). Handy when you have a folder of frames or renders you want processed in a specific order.

    Each run returns image, current_index, total_images, filename, and - if you enable read_caption - caption, which looks for a same-named .txt file next to the image and reads it. That caption output wires straight into captioning workflows or prompt conditioning.

    Inputs worth knowing

    • directory_path - where your images live.
    • file_extension - PNG, JPG, JPEG, WEBP, or ALL.
    • sort_method - set this once; default numerical is usually right.
    • reset_index - flip to True to start over from starting_index (defaults to 0).
    • read_caption - read matching .txt captions when present.

    Installing it

    It ships inside WWAA-CustomNodes, so install the pack, not a standalone node:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hgabha/WWAA-CustomNodes
    

    Restart ComfyUI. Easier via ComfyUI Manager: search "WWAA Custom Nodes", install, restart. It sits under 🪠️ WWAA/image. No models to download, and the pack claims no extra dependencies.

    Where people get burned

    There are two real-world gotchas, and one of them is documented by an actual user thread. First, a Reddit user trying to chain this into a VAE Encode after Grounding DINO and SAM hit expected all tensors to be on the same device. Cause: the loader moves the image tensor to CUDA unconditionally when a GPU is available, and if your downstream nodes are sitting on CPU (or mixed-device), you get device mismatches. Fix is to keep model loaders and the loader on the same device, or add a node that normalizes device placement before encoding.

    Second, remember it's stateful - rerunning a workflow continues from where the last run stopped, not from image 1. If you expected a clean start, hit reset_index (or reload_directory to force a rescan). And note the pack's image nodes import OpenCV at module load; if the whole 🪠️ WWAA image menu is missing after install, check that your ComfyUI Python environment has opencv - the pack's README is silent about it but the code needs it.

    Category🪠️ WWAA/image

    Inputs (7)

    NameTypeDefaultDescription
    directory_pathSTRING
    file_extensionCOMBOALL5 options: PNG, JPG, JPEG, WEBP, ALL
    reset_indexBOOLEANfalse
    sort_methodCOMBOnumerical5 options: alphabetical, numerical, windows_sort, creation_time, modification_time
    reload_directoryBOOLEANfalse
    read_captionBOOLEANfalse
    starting_indexoptINT0

    Outputs (5)

    NameTypeDescription
    imageIMAGE
    current_indexINT
    total_imagesINT
    filenameSTRING
    captionSTRING