MinusZone - ImageCaptionerConfig
Batch-caption a folder for LoRA training without leaving the graph
- captioner_config
MZ_ImageCaptionerConfig is the dataset-prep friend of this pack. On its own it does nothing; plugged into the captioner_config input of any image-interrogation node, it flips that node from "describe one image" into "caption every image in a folder and write the text files next to them." It was added (per the changelog) specifically to support batch prompt generation for LoRA datasets.
That matters more than it sounds. If you're building a training set, the pack's KB has a strong opinion: captioning quality matters more than dataset size, and for natural-language captions Florence 2 or JoyCaption beat BLIP outright. This node is how you point a Florence-2 or PaliGemma captioner at a whole directory and walk away. One run, and every image.png gets a sibling image.png.caption (or whatever suffix you pick).
The inputs that matter
directory- the folder to scan. It walks subdirectories too, and only processes.jpg,.jpeg, and.pngfiles.caption_suffix- default.caption. Files are written as<image path> + suffix. Change it to.txtif your trainer expects that.force_update- defaultFalse. With it off, images that already have a caption file are skipped - so re-running the batch only fills in the missing ones. Flip it on to re-caption everything.retry_keyword- defaultnot,",error. If the generated caption contains any of these comma-separated substrings (or comes back empty), the node treats it as a failed generation and retries with a bumped seed, up to 5 times. This is a genuinely useful guard - vision LLMs do occasionally emit "I'm sorry, I can't..." boilerplate, and the keyword list is how this pack catches it.prompt_fixed_beginning- a string prepended to every caption file, e.g. your trigger word. Handy for consistent dataset prefixes.
Output is a captioner_config object for the captioner_config input on CLIPTextEncode(ImageInterrogator), ImageInterrogator(LLava), the Florence-2 and PaliGemma captioners, etc.
How the batch run behaves
When the config is connected, the interrogator node switches modes: it walks the directory, converts each image to a tensor, runs the interrogation, and writes the caption file - showing a progress bar in the ComfyUI UI as it goes. It keeps the model resident in memory across images in a batch (keep_device is forced on internally between items) to avoid reloading the LLM per image. Skipped images report nothing, failed-after-retries images are skipped with a log line. It's a proper little batch runner, not a hack.
Installing and gotchas
Same pack, same install - ComfyUI Manager, search "ComfyUI-Prompt-MZ", or:
cd ComfyUI/custom_nodes
git clone https://github.com/MinusZoneAI/ComfyUI-Prompt-MZ
Real-world traps: (1) if directory is empty or wrong, the walk finds zero images and the run completes doing nothing - check the path. (2) The retry loop is per-image and each retry costs a full LLM forward pass; on a CPU-only machine a folder of hundreds of images can take a very long time, so start with a small subfolder. (3) When the batch finishes, the node returns an empty string as its text output - don't wire the batch mode expecting a summary.
One honest caveat: this node automates captioning, and the KB's lora-training advice is that hand-captioning is still the gold standard for small sets. Use it to get 90% of the way, then review the captions - especially if you're training a character LoRA where what you don't describe becomes the fixed concept.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| caption_suffix | STRING | .caption | — |
| force_update | COMBO | false | 2 options: false, true |
| retry_keyword | STRING | not,",error | — |
| prompt_fixed_beginning | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| captioner_config | ImageCaptionerConfig | — |