Nodes/ComfyUI-FairLab/Load Image Batch From Directory
ComfyUI Node

Load Image Batch From Directory

One folder, one tensor

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
Load Image Batch From Directory
    • images
    • directory
    • name
    directory
    recursivefalse
    channelsRGB

    Some jobs want the whole folder as a single unit, not as separate images. Load Image Batch From Directory loads every .jpg, .jpeg, and .png in a folder and stacks them into one batched IMAGE tensor - [N, C, H, W] - so a single wire carries your entire dataset or your entire batch of sources. This is the node you reach for when the downstream wants a batch, not a list.

    Compare it to the sibling Load Image From Directory, which returns each image separately as a list. The difference matters: batch consumers (samplers that run a latent batch, batch-wise processors, image grid makers) want one tensor with the batch dimension; item-wise loops want a list they can index. If a node's input accepts IMAGE but boggles at a list, this is the loader to use.

    Inputs and outputs

    • directory (STRING) in - folder path on the ComfyUI server.
    • recursive (BOOLEAN) - also sweep subfolders; default false.
    • channels (RGB / RGBA) - channel layout to load; default RGB.
    • images (IMAGE) out - one stacked batch tensor.
    • directory (STRING, list) out - the folder per image.
    • name (STRING, list) out - filename per image.

    Note the asymmetry: images comes out as a single batch, while directory and name stay as lists aligned with the original files. You can't zip the name list back onto the batch dimension directly without an indexing node - a small gotcha worth knowing if you want per-image names alongside batch processing.

    How it works

    Same scan-and-load machinery as the single-loader, then a stack: all tensors get combined along a new leading batch dimension. Loading shows a progress bar, so a folder of a few hundred images gives you a live readout instead of a frozen UI. It raises a clear error if the directory is invalid.

    Where it fits

    Batch img2img, style-transfer runs over a reference set, grid assembly, and any workflow where "process this entire folder" is the task. Because the batch is one tensor, it also plays nicely with FairLab's own batch tools (Images Range, Images Index, Images Cat) for slicing and recombining afterward.

    Install

    One pack either way: ComfyUI Manager (search ComfyUI-FairLab) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
    cd ComfyUI-FairLab
    pip install -r requirements.txt
    

    Restart, then look under Fair/image. No extra dependencies beyond ComfyUI's own image stack.

    Gotchas

    • Folder path is server-side. Remote or containerized ComfyUI can't see your local hard drive.
    • If the images in the folder aren't all the same size, stacking into a single [N, C, H, W] tensor can fail or produce a ragged batch depending on how the loader handles it. For mixed-size folders, the per-image list loader is the safer first move.
    • recursive on a deep tree will happily swallow hundreds of nested files - check it's on for the right reasons.
    CategoryFair/image

    Inputs (3)

    NameTypeDefaultDescription
    directorySTRING
    recursiveBOOLEANfalse
    channelsCOMBORGB2 options: RGB, RGBA

    Outputs (3)

    NameTypeDescription
    imagesIMAGE
    directorySTRING
    nameSTRING