Nodes/ComfyUI/Load Image-Text (from Folder)
ComfyUI Node Runs on cloud

Load Image-Text (from Folder)

Your caption-paired dataset, back as lists

By Comfy-Org·Created 4 years ago·Updated 4 minutes ago· 129,952
Load Image-Text (from Folder)
    • images
    • texts
    folder

    The saving side of the training-data story has its own built-in node, and this is the loading side: Load Image-Text (from Folder) reads a folder of images and their .txt captions and hands them back as two aligned lists. If you're building a workflow that consumes caption-paired training data - or that processes a folder of reference images with their descriptions - this is the node that turns a pile of files into something the graph can chew on.

    What it is

    One input: folder, a dropdown listing subfolders of your input directory (the ComfyUI/input folder). Two outputs, both lists:

    • images - a list of image tensors, one per file, in [1, H, W, 3] float format.
    • texts - a list of caption strings, one per image.

    Supported image formats: PNG, JPG, JPEG, WEBP. For each image, it looks for a .txt file with the same basename - cat.png pairs with cat.txt - and loads that as the caption. Missing caption file? You get an empty string for that image rather than an error, which is worth knowing before you blame the node for your dataset's blank entries.

    The mechanism has one nice surprise from the source: it understands the kohya/ai-toolkit folder structure. A subfolder named 5_fancy_cats - where the leading number is a repeat count - is unwrapped and its images loaded that many times, captions included. That's the standard "repeat images to rebalance a dataset" convention from the training world, and this loader handles it natively. If you've prepared data the trainer way, this node reads it the trainer way.

    Where it fits

    This is the input end of a two-node dataset story. Save Image-Text (to Folder) writes the PNG+txt pairs; this node reads them back as lists. Between those two, ComfyUI has a complete loop for caption-paired data: save a dataset from one workflow, load it in another to feed a trainer, or process it further in-graph.

    Why would you process training data in the graph instead of outside? Mostly for on-the-fly work - feeding a fixed dataset through a caption-conditioned pipeline (like a caption-to-image consistency check), or for batch operations where you want the captions and images together in one pass. The outputs being lists (rather than one big batched tensor) matters: each image stays its own entry, so you can zip the lists, shuffle them in step with the companion Shuffle Image-Text node, or pair each caption with its image explicitly.

    Getting it and where it goes wrong

    It ships with ComfyUI core, a newer experimental addition in comfy_extras/nodes_dataset.py - no install, no model files. The gotchas:

    1. The folder has to live under ComfyUI/input. The dropdown only lists input subfolders. Drop your dataset somewhere else and it won't appear.
    2. Caption pairing is basename-based and positional by file order. cat.png/cat.txt works; a caption named differently silently yields an empty string. Verify one pair before you queue a long run.
    3. It's experimental. The list outputs are the current API shape, and experimental nodes have been known to reshape as ComfyUI's new node system matures.

    For anyone doing LoRA-style dataset work, the loop it completes - save pairs, shuffle, load pairs - is a real convenience, and it's all core, which means no dependency hell to go with your captioning.

    Categoryimage

    Inputs (1)

    NameTypeDefaultDescription
    folderCOMBOThe folder to load images and text captions from.

    Outputs (2)

    NameTypeDescription
    imagesIMAGEList of loaded images
    textsSTRINGList of text captions