Nodes/ComfyUI-Pixaroma/Load Texts from Folder Pixaroma
ComfyUI Node

Load Texts from Folder Pixaroma

One caption per picture, one full run per caption

By pixaroma·Created 7 months ago·Updated a day ago· 463
Load Texts from Folder Pixaroma
    • text
    • filename
    • index
    • total
    ◄folder►
    ◄names—►

    Load Images from Folder was the node that made batch work in ComfyUI bearable: point at a folder, get a run per image. Load Texts from Folder Pixaroma is the same trick for text files - point it at a folder of .txt prompts or captions, and the rest of the graph runs once per text.

    That's it, and that's why it's useful. A folder of 40 prompt files becomes 40 renders in one Run, and because the text arrives as a list, it stays in lockstep with an image list rather than drifting.

    Two ways to use it

    Nothing wired into names. Every .txt file directly inside the folder, in name order, one per run. Classic "folder of prompts" work.

    Load Images from Folder's filename wired into names. Now it hands you the text that belongs to each picture, in the pictures' order - 01_Cat.png gets 01_Cat.txt. Both are list nodes running in the same order, so image and caption travel together. This is the mode that matters for training sets: the basename pairing kohya and friends expect from a sidecar .txt is exactly how the two lists get matched.

    Matching is forgiving in the useful direction. It's case-insensitive, and it also matches on the cleaned name, so a caption saved as MG_1234.txt still pairs with a picture called _MG_1234.png. A picture with no .txt doesn't shift the list - it gets an empty text plus a console line naming what was missing. Good call: a silent off-by-one here would caption every image with the wrong text.

    Inputs and outputs

    folder is a text field: empty means ComfyUI's output, a bare name like Training Set means that folder inside output, and a full path works for any folder you've approved once with Browse. names is the optional wire described above.

    Four outputs, all of them lists, because the whole point is fan-out:

    • text - each text in turn. Wire it into CLIP Text Encode, or into an LLM node that rewrites captions, or into a Save node.
    • filename - the file name without .txt (or the wired picture name). Perfect for a save node's filename so each result keeps its source name.
    • index - which text this is, counting from 1.
    • total - how many texts this Run is sending, the same number on every item.

    index and total look like filler until you use them: wire both into a Text Join and every image can be stamped "12 / 40", which turns a folder run from a mystery into a progress bar you can read later.

    How it behaves between runs

    Editing a caption and pressing Run again actually re-runs the graph. The node stamps a hash of every .txt's modified-time and size, so changing a file changes the node's identity to ComfyUI's cache and the workflow re-executes instead of handing you back the previous result. Small thing, but only if the author remembered to do it - plenty of loader nodes don't, and you spend ten minutes wondering why your edits had no effect.

    Limits, all deliberate: only plain .txt files sitting directly in the folder (no subfolder recursion, no .caption files), in name order, and any single file over 1 MB is skipped with a console note. Files that large are not captions.

    The failure you'll actually hit

    If the folder has no readable .txt at all - wrong path, or you pointed it at the image folder instead of the captions folder - the node stops the Run with a message naming the folder it looked in. That's better than the alternative. The one to watch for is the empty text case: a picture with no caption passes an empty string downstream, and while an empty prompt through CLIP is harmless, feeding empty text into an AI captioner is a great way to generate nonsense. Read the console note and fix the missing captions.

    Installing

    ComfyUI Manager, search Pixaroma, Install, restart - or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pixaroma/ComfyUI-Pixaroma
    

    No models, no extra Python packages for this node; the pack's only declared dependency is imageio-ffmpeg, which the video nodes use. The pack is a solo project from the designer behind Pixaroma (@pixaroma on YouTube, support on the Pixaroma Discord), and it ships inside ComfyUI Easy Install on Windows.

    It's built to pair with Save Text's One file per entry (which writes one .txt per picture) and Caption Review Pixaroma (which lets you read and fix them in one window) - caption, review, re-run. If a node of this pack ever looks broken right after an update, hard-refresh the tab with Ctrl+Shift+R first; that's cached visuals, not a bad install.

    Category👑 Pixaroma/💬 Prompt & Text

    Inputs (2)

    NameTypeDefaultDescription
    folderSTRINGThe folder with the .txt files. Empty = ComfyUI's output folder; a name like Training Set = a folder inside output; or a full path to a folder you approved with Browse.
    namesoptSTRINGOptional. Wire Load Images from Folder's filename here to get the text of EACH picture (01_Cat gets 01_Cat.txt), in the pictures' order.

    Outputs (4)

    NameTypeDescription
    textSTRINGEach text in turn. The rest of the workflow runs once per text.
    filenameSTRINGEach text's file name without .txt (or the wired picture name).
    indexINTWhich text this is, counting from 1.
    totalINTHow many texts this Run sends. The same number on every one.