Nodes/Y7Nodes for ComfyUI/Y7 Image Batch Path
ComfyUI Node

Y7 Image Batch Path

The image loader that remembers where every file came from

By yushan777·Created about a year ago·Updated 4 days ago· 8
Y7 Image Batch Path
    • IMAGE
    • IMAGE_PATH
    image_dir
    batch_size0
    start_from1
    sort_methodsequential

    Most image loaders in ComfyUI hand you tensors and then drop the file on the floor. If you're captioning a dataset, you need the file path as much as the pixels - otherwise you can't write cat.txt next to cat.jpg. Y7 Image Batch Path is the loader that doesn't drop it: it loads a whole directory of images and hands you both the image tensors and a matching list of their full file paths.

    It's the front half of a three-node captioning chain in the Y7Nodes pack - Image Batch Path → a VLM captioner (the pack's own Y7 JoyCaption works great) → Y7 Caption Saver. The path list is what tells Caption Saver exactly where to write each .txt file, which is what makes the whole pipeline hands-off.

    How it works

    Point it at a directory with image_dir (a multiline string - paste a folder path) and it walks the contents, loading jpg, jpeg, png, and webp files. Each image is EXIF-transposed (so phone photos with orientation tags come out right side up) and converted to an RGB float32 tensor - the standard shape ComfyUI nodes expect.

    The output is two parallel lists, matched one-to-one:

    • IMAGE - the image tensors, one per file.
    • IMAGE_PATH - the full file path for each image.

    That paired output is the whole point. Wire IMAGE into JoyCaption (or any VLM) for captioning, wire IMAGE_PATH into Caption Saver so the captions land next to their source files. Because both are lists, the batch flows through ComfyUI as a whole, not one-image-at-a-time.

    The settings that matter

    • batch_size - how many images to load. 0 = all of them, which is the default and usually what you want.
    • start_from - 1-based index of the first image to load. This is the resume feature: if you've already captioned the first 50 files and the pipeline died, set start_from to 51 and pick up where you left off without redoing work.
    • sort_method - sequential (alphabetical), reverse, or random. One gotcha: random re-evaluates on every run, so if you use it and re-run, you'll get a different order each time. Fine for sampling, wrong for anything where order must be stable.

    Pairing it with the rest of the pack

    The three-node chain is the intended use:

    1. Image Batch Path loads the folder and emits IMAGE + IMAGE_PATH.
    2. Y7 JoyCaption takes IMAGE and generates a caption for each.
    3. Y7 Caption Saver takes the caption STRING + IMAGE_PATH and writes cat.txt next to cat.jpg.

    If you're building a training dataset, this is the loop that does it in one pass. And given the KB's note that natural-language captions (JoyCaption-style) are the standard for LLM-encoder models while Danbooru taggers suit the anime lineage, this node is agnostic - it feeds whatever captioner you prefer.

    Installing it

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

    Restart ComfyUI, or use ComfyUI Manager → search "Y7Nodes".

    Gotchas

    The two things people hit: forgetting that batch_size 0 means "everything" (if the folder is huge, the first run loads it all into memory at once - check your folder size), and expecting a stable order from random. Otherwise it's a solid, boring utility that does exactly one job and does it right.

    CategoryY7Nodes/CaptionTools

    Inputs (4)

    NameTypeDefaultDescription
    image_dirSTRING
    batch_sizeoptINT0Number of images to load (0 = all)
    start_fromoptINT1Start from Nth image (1 = first)
    sort_methodoptCOMBOsequential3 options: sequential, reverse, random

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    IMAGE_PATHSTRING