Load Images Pair Batch
A dataset loader that brings its own captions
- image
- text
- image_filename
- image_filepath
Load Images Pair Batch loads an image from a folder and, in the same breath, loads the matching .txt caption file beside it. That's the "pair" - image + caption - and it's the whole point. Most ComfyUI image loaders give you pixels and nothing else. This one hands you pixels, the caption text, the filename, and the file path, all from one node. If you're working with training datasets or caption-auditing, this is the loader you want.
The "pair" format it expects is the standard one: an image named foo.png and a text file named foo.txt in the same directory, containing the caption or tags. It's the same convention WD14 taggers and most dataset tools emit, and the same one Save Images Pair in this pack writes. The pair-of-nodes loop - load, tweak, save - is a clean way to scrub captions before a LoRA run, which the lora-training knowledge base calls out as one of the highest-leverage dataset steps there is.
How it works
The node globs a directory (path) for files matching a pattern (default *), filtered to image extensions, and sorts them. Then mode decides which one you get:
- single_image - picks by
index(0-based). - incremental_image - advances through the folder across runs, remembering its position per
label. - random - picks a random file each run.
The incremental memory is worth understanding: the node stores a counter keyed by your label in was_suite_settings.json (a WAS Suite-style database, written into the pack's own folder by default). Change the folder or pattern for a label and the counter resets to zero. This is how you feed a whole folder through a graph one image at a time and let ComfyUI keep walking through it in the queue.
The text output is the contents of the matching .txt file (or an empty string if there's no sidecar). image_filename gives you the basename, and image_filepath the absolute path - handy if you want to save the image back with Save Images Pair without re-encoding it. Two flags to note: allow_RGBA_output set to false (the default) converts to RGB, and filename_text_extension controls whether the filename output keeps its extension.
Inputs and output
The ones a beginner actually touches: path (the folder), mode, index, and label. Outputs: image (IMAGE tensor, into any sampler's image input), text (into the CLIP text encode or your tag chain), image_filename, image_filepath.
A note on re-execution: in incremental_image and random modes the node always re-runs, so it behaves in the queue. In single_image mode it hashes the current file and only re-runs if the image changes.
Installing it
The pack's README is empty, so here's the ground truth: no requirements.txt, no model downloads, no extra Python deps - just numpy, torch, and PIL, which ComfyUI already provides. (This node is lifted from WAS Node Suite, which is why it shares WAS's config-file behavior - but it doesn't pull in WAS's other dependencies.) Install via ComfyUI Manager, searching ComfyUI-Aimidi-nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/AiMiDi/ComfyUI-Aimidi-nodes
Restart ComfyUI; the blue ComfyUI Aimidi Nodes: Loaded line confirms it loaded.
Common issues
- "No valid image was found" - usually a wrong
path, or apatternthat matches nothing. Remember the path is a directory plus a glob. - Incremental mode jumps around unexpectedly - the counter is keyed by
label. Reusing a label for a different folder keeps the old counter; give each dataset its own label. - Text comes back empty - no
.txtsidecar next to the image. Check the filename matches exactly (foo.pngneedsfoo.txt). - The node writes
was_suite_settings.json/was_history.jsoninto the pack's folder on first use. That's expected, not a bug - it's the batch state.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | 3 options: single_image, incremental_image, random | |
| index | INT | 00–150000 | — |
| label | STRING | Batch 001 | — |
| path | STRING | — | |
| pattern | STRING | * | — |
| allow_RGBA_output | COMBO | 2 options: false, true | |
| filename_text_extensionopt | COMBO | 2 options: true, false |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| text | STRING | — |
| image_filename | STRING | — |
| image_filepath | STRING | — |