πΌοΈ+π Load Text-Image Pair (Single)
Load One Image-and-Caption Pair at a Time, Straight From Your Training Folder
- image_input
- image_single
- string_single
- image_path_single
- image_filename_single
- total_count
LoRA datasets are not clever. A folder of 0001.png + 0001.txt pairs is the whole convention, and every trainer - kohya, ai-toolkit, OneTrainer - just walks it looking for a text file with the same basename as the image. πΌοΈ+π Load Text-Image Pair (Single) reads that same folder inside ComfyUI, one pair per run, so you can feed a real caption from your dataset into a test generation instead of retyping it.
Why you'd want that: the fastest way to sanity-check a dataset is to generate with the captions themselves. If 0007.txt is "a woman in a red coat, overcast street, 35mm" and the model can't do anything with that, the training run is going to be a waste of six hours. This node hands you image and caption as separate outputs so you can look at both in one pass.
How it works
Point folder_path at the dataset directory and the node scans it: images are .png, .jpg, .jpeg, .bmp and .webp; captions are whatever text_format_extension says (default txt, but .caption works too). It pairs by basename, sorts alphabetically, and skips any image without a matching caption file - silently, which is worth knowing. Then seed is a modulo index, not a seed: seed % total_count picks the pair, so seed 0 is the first pair, seed 12 the thirteenth, and it wraps politely.
total_count comes out as its own output, so you can see how many usable pairs the folder actually has. If that number is smaller than you expected, you have unpaired files.
Both image_input and text_input are optional and take priority over the folder entirely. Connect both and the node just passes them through (the image, the text as a string, total_count = batch size) - which makes it a handy "flatten a batch to one item" node as well as a dataset reader.
Inputs and outputs
You set seed (with control_after_generate on increment to walk the folder run by run) and folder_path, plus optionally text_format_extension. Outputs are image_single, string_single, image_path_single, image_filename_single, and total_count. The path and filename outputs are the ones people forget - wire image_filename_single into a Save Image prefix and every output image names the pair it came from.
Install
ComfyUI Manager, search "ComfyUI-mnemic-nodes", restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
No model downloads. The pack's dependencies (transformers, opencv-python, tiktoken, piexif, imageio) get installed with it; none of them are needed by this particular node.
Common issues
It returns nothing. Either the folder has no matched pairs, or folder_path is wrong. Absolute paths are the safe choice - a relative path isn't resolved against ComfyUI/input here the way you might hope.
Zero-byte or black images. The node .convert("RGB")s every image, so a paletted PNG or a 16-bit TIFF is fine, but a corrupt file just prints to the console and the run continues.
Captions are being ignored. Check the extension. text_format_extension defaults to txt without a dot; pass caption not .caption.
You wanted the whole dataset at once. That's the sibling node, πΌοΈ+π Load Text-Image Pairs (List). This one is deliberately built to be fast and stateless - it opens and decodes one pair per execution rather than caching the set.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00β18446744073709550000 | Index of the pair to load, starting at 0. Increments every run by default to step through the folder. |
| folder_path | STRING | Path to a folder containing image and text files with matching basenames. This is used only if image_input and text_input are not connected. | |
| image_inputopt | IMAGE | A single image or a list/batch of images. This input has priority over the folder_path. | |
| text_inputopt | STRING | A single text string or a list of strings. This input has priority over the folder_path. | |
| text_format_extensionopt | STRING | txt | The file extension for the text files to look for (without the dot). |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image_single | IMAGE | The single image selected by the seed. |
| string_single | STRING | The text string that is paired with the selected image. |
| image_path_single | STRING | The full absolute path of the selected image. |
| image_filename_single | STRING | The filename (without extension) of the selected image. |
| total_count | INT | The total number of pairs found in the dataset. |