MinusZone - Captioner(Florence-2)
Caption an entire folder with Florence-2, .caption files and all
- debug
Captioner(Florence-2) is the batch-mode sibling of CLIPTextEncode(Florence-2). It takes a directory instead of an image, walks every .jpg/.jpeg/.png in it, captions each with Florence-2, and writes the captions as sidecar files (image.png.caption by default) right next to the images. It's a purpose-built dataset-captioning tool, and it's the node in this pack you'd actually run overnight.
The KB's lora-training guidance is the whole rationale: Florence 2 is a community-recommended captioner for natural-language training captions, and captioning quality matters more than dataset size. This node turns that recommendation into a one-shot batch job with a progress bar in the ComfyUI UI.
The inputs that matter
model_name-Florence-2-large-ft(default) orFlorence-2-large. Use the-ftfor better instruction following.directory- the folder to scan, recursively. This is the one that actually does the work.resolution- default 512, resize target before captioning.batch_size- default 1. How many images to caption per model forward pass. You can raise it if VRAM allows; 1 is the safe setting.caption_suffix- default.caption. Change to.txtif your trainer expects that.force_update- defaultFalse. Skip images that already have a caption file; flip on to re-caption everything (useful after changing the model or prompt).prompt_fixed_beginning- string prepended to every caption, e.g. a trigger word.
Output is a single debug STRING - the batch runner isn't built to return captions as tensors, so the real output is the files on disk.
How it works
Internally it wraps the Florence-2 encode path in the pack's shared batch captioner: walk the directory, skip already-captioned images unless force_update, convert each image to a tensor, run the model (kept resident across the batch), write <image><suffix>, and show progress. If a generation comes back empty, it retries with a bumped seed up to 5 times - a sane guard against the occasional empty output.
Installing
Part of ComfyUI-Prompt-MZ:
cd ComfyUI/custom_nodes
git clone https://github.com/MinusZoneAI/ComfyUI-Prompt-MZ
Restart. Needs transformers + torch; the Florence-2 model downloads into ComfyUI/models/minus_zone_models on first run (multi-GB). llama-cpp-python from the pack's requirements isn't exercised by this node but installs with the pack anyway.
Troubleshooting
The realistic complaints: (1) It's slow - Florence-2-large on CPU can take several seconds per image, so a few hundred images is an all-afternoon job. Set batch_size up if your GPU has room, and consider the smaller Florence-2-large-ft's sibling models from elsewhere if speed is the blocker. (2) The captions are natural-language sentences, which is what you want for Flux-style bases and wrong for Danbooru-tag bases like Illustrious - pick your trainer before trusting the output. (3) OOM mid-batch: keep batch_size at 1 and note this node's batch mode keeps the model loaded, so VRAM stays busy the whole run - close the sampler's windows or run captioning as a separate step from generation. (4) If a run "completes" with no files, check directory - a typo path silently scans nothing.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 2 options: Florence-2-large-ft, Florence-2-large | |
| directory | STRING | — | |
| resolution | INT | 512128–18446744073709550000 | — |
| batch_size | INT | 11–18446744073709550000 | — |
| caption_suffix | STRING | .caption | — |
| force_update | COMBO | false | 2 options: false, true |
| prompt_fixed_beginning | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| debug | STRING | — |