Nodes/ComfyUI-ZFRNodes/Reference Image Loader (Path)
ComfyUI Node

Reference Image Loader (Path)

Load a whole folder of reference images as one batch

By zfrsgtcu·Created 3 months ago·Updated 13 days ago· 32
Reference Image Loader (Path)
    • images
    • folder_path
    • image_count
    folder_path
    max_images0

    The most boring node in the pack, and one of the most useful. Reference Image Loader (Path) is the folder-based twin of ZFRNodes' upload-style Reference Image Loader: point it at a directory on disk and it loads every image inside as one IMAGE batch. No multi-file upload dialogs, no chains of Load Image nodes, no drag-and-dropping forty files one at a time. Pick a folder, done.

    It exists because the rest of this pack is built around folders. It's the front end of the dataset pipeline (feed it into Dataset Prep to batch-generate a LoRA training set), and it's the quick way to dump a folder of references into the multi-reference generators' reference_images inputs. If you're working with a real corpus on disk rather than hand-picked uploads, this is the loader you want.

    How it works

    A "Select folder" button opens your OS's native folder picker - the pack registers a small server route to do this, so it works on Windows, macOS, and Linux - or you can paste a path straight into the field. The frontend then shows the folder's contents as a carousel: file name, resolution, arrow navigation, click-to-zoom, open-in-new-tab. The backend loads each image and combines them into one batch, letterboxing different-sized images onto a transparent canvas with their aspect ratios preserved - no cropping, no stretching, same approach as the upload loader.

    It also re-runs automatically when the folder's contents change. The node tracks the files by name, modification time, and size, so add or remove a file and the next queue run picks it up without you touching anything.

    The inputs that matter

    There are only two:

    • folder_path - filled by the folder picker, or paste one yourself.
    • max_images - cap how many images to load (0 = all). Worth setting while you're testing a big folder, so you're not processing everything on the first run.

    Outputs: images (one IMAGE batch, ready for Dataset Prep or any reference_images input), folder_path (the resolved path as a STRING - this is what feeds Dataset Prep's output naming), and image_count.

    Install

    Same pack either way - search ComfyUI-ZFRNodes in ComfyUI Manager, or:

    cd /path/to/ComfyUI/custom_nodes
    git clone https://github.com/zfrsgtcu/ComfyUI-ZFRNodes.git
    

    Dependencies are just numpy, torch, and Pillow, already present in ComfyUI. Do a full restart after installing - the carousel UI comes from a frontend script, and a browser refresh isn't enough for it to register.

    Common issues

    • image_count is 0 - the path is wrong or the folder holds no images (the node returns an empty 64×64 tensor in that case, which will silently feed whatever comes next). Check the path, and note it only picks up common image extensions - PNG, JPG/JPEG, WebP, BMP, GIF, TIFF.
    • Batch looks letterboxed - that's the transparent-letterbox behavior doing its job, not a bug; it's how images of different sizes coexist in one IMAGE tensor.

    Typical wiring: Reference Image Loader (Path) → Dataset Prep, or into Simple Image Generator (Multiple) / Story Frame Generator as reference_images. It won't win any awards for excitement, but it's the piece that makes a folder-based pipeline feel like a pipeline instead of a series of uploads.

    Categoryzfr-nodes

    Inputs (2)

    NameTypeDefaultDescription
    folder_pathSTRING
    max_imagesINT00–100000

    Outputs (3)

    NameTypeDescription
    imagesIMAGE
    folder_pathSTRING
    image_countINT