Load Images From Dir
Point One Node At Your Dataset Folder And Keep The Filenames
- images
- names
What it is
ComfyUI has always been fine at loading one image and mildly annoying at loading a folder of them. LoadImagesFromDir does the folder: give it a path, get back every image in it plus the file names, in the same order.
That last part is why the node exists. It's built to pair with its siblings in the same pack - SaveImageWithText takes a name input and uses it as the stem for both the .png and the .txt - so an image and its caption survive a trip through a ComfyUI graph with their original names intact instead of becoming 00042_.png. The author's own changelog for this feature spells out the motivation: dataset prep (read folder, filter captions, train) used to happen in three different tools.
So the workflow it unlocks is a dataset pass: read a folder of raw images, run them through a tagger or captioner you already have wired up, save image+caption pairs back with the same names, then train. You're not building a training set with this node - TrainSdxlLora reads images straight off disk from output/train/<name>/<version>/train/. This is the review-and-caption stage before that.
How it works, and the two details that matter
The path is resolved relative to ComfyUI's output directory, not the ComfyUI root - that's the author's own tooltip on the field, and it's the number one thing to internalise. Anything that resolves outside output/ gets rejected outright; the pack puts a realpath check on every file path input, so ../models earns you a ValueError rather than a surprise.
Files are filtered to .jpg, .jpeg, .png and .webp, then sorted ascending. Each image is opened with Pillow, passed through exif_transpose - so phone photos come out the right way up - and converted to RGB. That conversion silently drops alpha, which matters more than you'd think: the long-standing advice for character datasets is to avoid transparent-background images precisely because the alpha channel gets ignored and you get jagged edges. Here it's guaranteed, not incidental.
The node also declares a change signature based on each file's name and modification time, which means it re-executes whenever the folder's contents change. In practice that's what makes it usable downstream of a downloader in the same run: fresh files land, the node notices, and everything after it runs again on the new set.
The one input, and the two outputs
dir_path is the only input, a plain string, default empty. Type train/my_lora/v1.0.0/train (or wherever you keep it) and you're done.
images is a list of IMAGE tensors. names is a list of strings holding the file names, in the same order - feed that into SaveImageWithText's name to keep the pairs matched.
Both outputs are list-typed, which is ComfyUI's "run this once per item" signal. Wire a list into an ordinary node and it executes once for every image; wire it into a list-aware node and it sees the whole set. That's exactly how you get a folder of images paired with a folder of filtered captions: both lists are index-aligned, so image i goes with caption i.
Install
Through ComfyUI Manager: search ComfyUI-Alchemine-Pack, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-alchemine-pack
Restart ComfyUI and look under AlcheminePack/Lora. No dependency install - the pack has no requirements file and imports nothing outside a normal ComfyUI environment.
Where people get burned
The output-directory rule. Everyone tries to point it at input/ or at a folder on their D: drive the first time. Put dataset folders under ComfyUI/output/ and address them relatively.
An empty or missing folder is not an error. The node returns two empty lists, the downstream nodes run zero times, and the graph reports success while nothing happens. If your pipeline runs instantly and produces nothing, check the path before you check the graph.
Order is lexicographic, not numeric. 1.jpg, 10.jpg, 2.jpg is the order you'll get, because it's a plain sort on the path. Zero-pad your filenames (001.jpg) if anything downstream depends on sequence. This also applies to the image/caption pairing: the two lists only line up if they came from the same listing.
No .bmp, no .gif, no .avif. Unsupported extensions aren't flagged, they're skipped. A folder of half-.bmp renders will look like a folder of half the images.
It loads everything, at full resolution, at once. Nothing here is lazy. A few hundred 2K images wired into a batch-consuming node is a memory event rather than a captioning session. For dataset review, point it at the folder in chunks, or downscale before the folder.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dir_path | STRING | Folder relative to the ComfyUI output directory. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| names | STRING | — |