Load Images with Captions from Dir (rholdorf)
Your LoRA training folder, loaded with captions intact
- image
- mask
- caption
- file_path
If you've ever built a LoRA training set, you know the layout: images and matching .txt captions, same base name, same folder. This node batch-loads that folder straight into ComfyUI, captions and all, and hands you a list you can iterate over. It's the ComfyUI-side bookend to the pack's Save Image with Caption - save pairs on the way out, load pairs on the way in.
How it works
Point it at a directory and it scans for .jpg, .jpeg, .png, and .webp. Each image is EXIF-transposed (so phone photos stop coming in sideways), converted to RGB, and turned into a tensor. The alpha channel, when present, becomes a mask using the 1 − alpha convention - same as the built-in Load Image, so opaque areas read as 0. The caption is read from a UTF-8 .txt with the same stem in the same directory, and a missing .txt is not an error: you get an empty string, because real training folders routinely contain unlabelled images. If the whole directory is missing or holds no images, the node raises rather than silently returning nothing - better a loud error than a mysteriously empty batch.
The four outputs - image, mask, caption, file_path - are all lists (OUTPUT_IS_LIST), so a downstream node executes once per image instead of receiving one giant batched tensor. That's the behavior you want for pair-by-pair processing.
The inputs that matter
directory- the only required one.image_load_cap- stop after N images (0 = no limit). Handy when testing on a subset.start_index- skip N files from the start of the sorted list.load_always- re-read the folder every run, defeating ComfyUI's cache. Flip this on when you keep adding images between runs and the node keeps serving you a stale list.sort_method- None, alphabetical, numerical, or datetime, each ASC or DESC. Numerical sorts by the first number found in the filename, which keepsimg2ahead ofimg10the way you'd expect (plain alphabetical would putimg10first).
Where it fits
This deliberately replicates the inputs of Inspire pack's Load Image List From Dir and adds the caption output - same semantics, so it's a near drop-in if you're migrating. Its real home is dataset QA: load a folder, connect caption to a display node, and eyeball your image/caption pairs before a training run, catching the mislabelled entries that silently degrade a model. file_path is also handy - pair it with the pack's Path Splitter to rebuild paths or drive save prefixes. Caption quality is the biggest lever in training, and this is the node that puts your pairs in front of your eyes.
Install
Part of the small comfyui_imgtools pack by rholdorf. Install once, get all 11 nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/rholdorf/comfyui_imgtools
Restart ComfyUI. Or search "rholdorf" in ComfyUI Manager. No build step, no extra dependencies - it runs on the torch/numpy/Pillow ComfyUI already ships, so nothing extra to install. Young, low-star solo pack: MIT, short readable code, no network calls, no model downloads. JS changes under web/ need only a browser refresh; Python changes need a restart.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | Folder to scan for image files. | |
| image_load_capopt | INT | 0 | Stop after this many images (0 = no limit). |
| start_indexopt | INT | 00–18446744073709550000 | Skip this many files at the start of the sorted list. |
| load_alwaysopt | BOOLEAN | false | Re-read the folder every run (defeats ComfyUI caching). |
| sort_methodopt | COMBO | How to order files before slicing. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| caption | STRING | — |
| file_path | STRING | — |