Nodes/ComfyUI-mnemic-nodes/πŸ–ΌοΈ+πŸ“ Load Text-Image Pairs (List)
ComfyUI Node

πŸ–ΌοΈ+πŸ“ Load Text-Image Pairs (List)

Turn Your Whole Training Folder Into a Cached ComfyUI List

By MNeMoNiCuZΒ·Created 3 years agoΒ·Updated a day agoΒ· 105
πŸ–ΌοΈ+πŸ“ Load Text-Image Pairs (List)
  • image_input
  • image_list
  • string_list
  • image_path_list
  • image_filename_list
  • total_count
β—„seed0β–Ί
β—„folder_pathβ–Ί
β—„force_reloadfalseβ–Ί
β—„text_inputβ€”β–Ί
β—„limit_count0β–Ί
β—„text_format_extensiontxtβ–Ί

The single-pair loader is for reading one caption off disk. This one - πŸ–ΌοΈ+πŸ“ Load Text-Image Pairs (List) - loads the entire dataset into memory once and hands you lists, which is what you want when the whole folder is going somewhere: a grid preview, a caption-cleanup pass, a batch upscale, a face-swap over every training image. Same pack, same sidecar convention (0001.png next to 0001.txt), different shape of output.

How it works

folder_path is scanned once and the pairs are cached in memory. That's the headline feature and also the hazard: the first run decodes every image into a batched tensor, and every run after that is nearly instant until you change the folder. force_reload throws the cache away and re-reads from disk - that's your button for when you edited captions or added files.

seed behaves as a rotation index rather than a seed. The output lists come back rotated so the item at seed % total_count is first: string_list[0] is the caption for the pair you selected, string_list[1] is the next one in the folder, and so on around the loop. That's the design decision to internalise - you're not filtering to one item, you're re-ordering the whole list to start at your chosen pair. People expecting a plain slice get confused by this, and the tooltip says it plainly once you know to look.

limit_count caps how many pairs come back (0 = all), and text_format_extension handles .txt or .caption. image_input and text_input still override the folder if you connect them: a single string, or a list of strings, gets zipped against the image batch and truncated to the shorter of the two.

Inputs and outputs

Set seed, folder_path, optionally force_reload, limit_count, text_format_extension. force_reload is a boolean widget, not a seed - flip it, queue once, flip it back (or leave it on and accept the reload cost).

Outputs: image_list, string_list, image_path_list, image_filename_list, and total_count. Every one of them is a genuine list, so they can drive a batch run or feed a list-aware downstream node. total_count is worth wiring to a text display when you're curating a dataset - it's the count of matched pairs, so any image missing its caption silently drops out of it.

Install

ComfyUI Manager β†’ "ComfyUI-mnemic-nodes" β†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes

No models, no keys. The pack's requirements.txt (transformers, opencv-python, piexif, tiktoken and so on) installs alongside, but this node itself only needs PIL, torch and numpy.

Common issues

ComfyUI gets sluggish on big folders. The author flags this directly: without limit_count, a folder of hundreds or thousands of images is decoded into memory in one go. A 500-image dataset at 1024px is a lot of float32 to hold. Cap it.

New files don't show up. The cache. Set force_reload and run once.

Lists don't line up with the folder order. They do - alphabetically - but remember the rotation. Index 0 is your selected pair, not the first file, unless the seed is 0.

Images look wrong / captions look empty. Only pairs are returned. An unpaired image never appears, and its caption-position neighbour shifts up, which is exactly how a half-captioned folder sneaks past you.

Category⚑ MNeMiC Nodes

Inputs (7)

NameTypeDefaultDescription
seedINT00–18446744073709550000Index of the first pair to load, starting at 0. Increments every run by default to step through the folder.
folder_pathSTRINGPath to a folder containing image and text files with matching basenames. This is used only if image_input and text_input are not connected.
force_reloadBOOLEANfalseIf true, forces a reload of data from disk, bypassing the cache.
image_inputoptIMAGEA single image or a list/batch of images. This input has priority over the folder_path.
text_inputoptSTRINGA single text string or a list of strings. This input has priority over the folder_path.
limit_countoptINT00–10000The maximum number of pairs to return in the output lists. If set to 0, all found pairs will be returned.
text_format_extensionoptSTRINGtxtThe file extension for the text files to look for (without the dot).

Outputs (5)

NameTypeDescription
image_listIMAGEA list of all images from the dataset, rotated so that the selected image is the first item in the list.
string_listSTRINGA list of all text strings from the dataset, rotated so that the selected text is the first item in the list.
image_path_listSTRINGA list of full absolute paths of all images.
image_filename_listSTRINGA list of filenames (without extension) of all images.
total_countINTThe total number of pairs found in the dataset.