Load Dataset From Folder
Turn a folder of images and captions into a batch ComfyUI can chew on
- images
- filenames
- captions
Most ComfyUI users never need a dataset loader. They're generating, not training. But the moment you want to evaluate something over a batch - test a LoRA across a folder of subjects, preview what an upscale or a style transfer does to a set of images, or prep data for a training run - you discover that loading images one at a time and captions by hand is misery. Load Dataset From Folder is the node that turns a folder of images plus their .txt caption files into three batch outputs, in one shot.
It's the "training" category node in Sage Utils, but don't let that scare you off. Its real usefulness is any workflow that wants a whole dataset in the graph at once.
How it works
Point dataset_path at a folder. The node scans for .png, .jpg, .jpeg, and .webp images, and for each one looks for a same-named .txt caption file (your photo.png pairs with photo.txt). It then:
- batches the images into one
imagesoutput, - gives you the matching
filenames, - and collects the captions into a
captionsoutput.
The optional prefix and suffix inputs let you modify every caption as it loads - the classic use is prefixing your LoRA trigger word, so prefix = "mychar" turns every caption into "mychar a woman walking…" without you editing a hundred files. A separator (default a space) controls the glue between prefix/suffix and the caption text.
It also validates before running: if the path isn't a directory, or the folder has no supported images, it tells you instead of silently failing. That's a thoughtful touch for a node you'll point at filesystems.
The inputs that matter
dataset_path- the folder. The only required input.prefix/suffix- added to every caption (default empty).separator- the join string, default" ".
Outputs: images (IMAGE batch), filenames (STRING), captions (STRING).
Wiring it up
The natural pattern: images goes to a batch-processing branch (an upscaler, a sampler for img2img previews), while captions feeds a text display or a caption-relevant node so you can see what the graph "knows" about each image. For training-adjacent work, this is the same folder layout the major trainers expect - images plus matching caption files - so what you load here is directly comparable to a dataset you'd hand to ai-toolkit or kohya.
Installing
It ships in Sage Utils (training nodes are enabled by default in this pack):
cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils.git
cd ComfyUI_SageUtils && pip install -r requirements.txt
Restart ComfyUI, or use ComfyUI Manager and search "Sage Utils."
Where people trip
Caption pairing is the classic gotcha: the node looks for a .txt file with the same base name as the image. photo.png → photo.txt. If your captions are named captions.txt (one giant file) or stored in a subfolder, they won't match - this expects one caption file per image. Also, keep the folder to supported image extensions; stray .gif or .heic files just get skipped, which is usually what you want. And a reminder from the training world: caption quality is the whole game, so the prefix/suffix inputs are worth using deliberately rather than as an afterthought.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset_path | STRING | Path to the folder containing image files and optional caption text files. | |
| prefixopt | STRING | Optional text prefix to prepend to each caption. | |
| suffixopt | STRING | Optional text suffix to append to each caption. | |
| separatoropt | STRING | Separator used when concatenating prefix/suffix with caption text. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | Output value for images. |
| filenames | STRING | Output value for filenames. |
| captions | STRING | Output value for captions. |