Prompt File Image Loader (Badman)
Step through an image+caption dataset one index at a time
- image
- mask
- prompt
- filename
- total
If you've ever built a LoRA dataset - a folder of images plus a text file of matching captions - you know the annoying part isn't training, it's checking your work. Does image 47 actually pair with caption 47? This node solves exactly that: point it at an image folder and a delimited prompt file, give it an index, and it hands back the image, its mask, and the matching prompt text as separate outputs, all at once.
How it works
It's a paired lookup, not a fancy loader. image_directory gives it a folder of images, and prompt_file points at a plain text file where individual prompts are separated by a delimiter (default ---). The node reads the file, splits it on that delimiter, and picks the chunk at position index - same index it uses to pick the image from the directory. Line the two up correctly on disk and every index gives you a matched pair. This is the same shape of problem the LoRA-training crowd solves with BLIP or JoyCaption caption files sitting next to their images; this node is built to plug straight into that layout, which the pack's own README calls out as the intended use ("targeting a specific String when loading prompts from files or from a multi image BLIP interrogator").
wrap_index (default on) means an index past the end wraps back around to the start instead of throwing an error - handy if you're driving this from an incrementing loop or a queue and don't want to hand-calculate where the dataset ends.
The inputs and outputs that matter
image_directoryandprompt_file- plain string paths, not dropdowns. Type them out in full; there's no folder picker here like the native Load Image node has.index- which pair to fetch. Bump it manually, or drive it from a loop/counter to walk the whole dataset.delimiter(default---) - has to match exactly what separates entries in your prompt file. Get this wrong and your prompt boundaries shift.wrap_index- leave it on unless you specifically want an out-of-range index to fail loudly.
Outputs: image and mask (the loaded image, ready for your sampler or a preview), prompt (the matching caption string - wire it into a CLIP Text Encode), filename (useful for logging or for writing results back out under the same name), and total - the dataset size, which pairs nicely with a loop node so you know when to stop.
How to install it
Search ComfyUI-BadmanNodes in ComfyUI Manager and install, or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/MariusKM/ComfyUI-BadmanNodes
Restart ComfyUI. This is a small personal utility pack - the author's own description is "nothing special and nothing crazy" - so there's no model download and no heavy dependency for this particular node. It doesn't show up in community threads much either; treat it as a solid, low-drama QoL tool rather than something with a reputation to weigh.
Common issues & troubleshooting
Image and prompt counts don't match. The node has no idea your folder has 50 images but your prompt file only has 48 entries after splitting - it just indexes into both and hopes they line up. If your captions look shifted by one, the mismatch is almost always here: a stray delimiter, a trailing blank entry, or a file that wasn't updated after you added images.
The path is wrong and nothing loads. Since image_directory and prompt_file are typed strings, a typo or a relative-path assumption that doesn't match ComfyUI's working directory will fail silently or error depending on your setup. Use absolute paths if you're not sure.
BLIP-captioned files look wrong once loaded. That's not this node - that's BLIP. If your prompt file was generated with BLIP, expect generic, occasionally inaccurate captions; the LoRA-training crowd has mostly moved on to JoyCaption or Florence 2, or captions by hand for small sets. This node will faithfully hand you back whatever's in the file, garbage or not.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_directory | STRING | — | |
| prompt_file | STRING | — | |
| index | INT | 00–18446744073709550000 | — |
| delimiter | STRING | --- | — |
| wrap_index | BOOLEAN | true | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| prompt | STRING | — |
| filename | STRING | — |
| total | INT | — |