Save Image Pair Text
Save an Image and Its Caption Together, as a Ready Dataset Pair
- image
Most of the time you save an image and its prompt separately and re-pair them later by hand. This node removes that chore: it saves the image and a same-named .txt file with whatever caption you give it, in one shot. That image.png + image.txt layout is the standard folder format that LoRA/dataset tools (and a lot of fine-tune scripts) expect, so if you're building a training set out of generated images - say, generating 200 style-consistent images and captioning them as you go - this is the node that makes the folder come out right.
How it works
Feed it an IMAGE tensor, a destination folder, a base filename, optional prefix/suffix, and the text to save. It splits the extension off the filename, writes the image via PIL, and - only if text is non-empty - writes a matching .txt with the same base name. Batches are handled properly: for a multi-frame tensor, each frame gets an eight-digit index appended (image_00000000.png, image_00000001.png, …) so a batch never overwrites itself. The output directory is created on the fly if it doesn't exist. It's an output node (OUTPUT_NODE = True), so it returns nothing and exists purely for its side effect on disk.
Inputs
image- theIMAGEtensor to save.path- output folder. Note the default is Windows-flavored:D:/ComfyUI/output. On Linux/macOS, change it.filename- base name including extension (defaultimage.png).prefix/suffix- inserted before/after the base name (prefixbasesuffix.png).text- the caption; empty text means no.txtis written.
Install
Standard pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/Tlant/ComfyUI-OllamaPromptsGeneratorTlant
restart, or find "Save Image Pair Text" in ComfyUI Manager.
Where people get burned
- The default path is a Windows path. On anything else it'll happily create a
D:/directory structure that makes no sense. Setpathto something real before your first run. - Filename includes the extension. It's
image.png, notimage- the node splits the extension itself, so typing.pngin the filename is correct, and typing it in bothfilenameandsuffixgives youimage.png.png. - Empty text means no caption file. If you want a
.txton every image, you must supply non-emptytext. For training-data generation that's usually fine because you're captioning as you go, but it's a silent behavior worth knowing.
It's a dataset-assembly node, not a fancy one - but it turns "generate then organize" into one step, and for anyone building a custom training folder out of ComfyUI output, that's the whole ballgame.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| path | STRING | D:/ComfyUI/output | — |
| filename | STRING | image.png | — |
| prefix | STRING | — | |
| suffix | STRING | — | |
| text | STRING | — |
Outputs (0)
No outputs