Florence2 Caption Images Under Directory ๐
Batch-caption a folder fast
- model
- log
Point this at a folder and it captions every image in it with Florence-2, writing each caption to a .txt file next to its image. That image.png / image.txt pairing is the standard LoRA dataset layout every trainer expects - so this is the node you use to prep a training set without hand-writing a hundred captions. And because Florence-2 is tiny and quick, it's the fast option when you've got a big folder to get through.
Why this is the one for big datasets
Captioning is one of the highest-leverage steps in LoRA training, and it's also the most tedious. This node hands the tedium to a small, fast vision model. Florence-2 vs the alternatives: it's much lighter than a 7B captioner like Janus or JoyCaption, so on a large folder it just gets through the work faster. It's also the community's standard answer to "don't use BLIP" - BLIP captions are formulaic junk and have been for years; Florence-2 or JoyCaption, or by hand.
The default task (more_detailed_caption) writes natural-language paragraphs, which is what modern LLM-encoder bases (Flux, Qwen-Image, Z-Image) want to be trained on. If you're training an anime base in the Illustrious/Pony line, that world wants Danbooru comma-tags instead - set task to tags, though a dedicated WD14 tagger is still the sharper tool there.
One training rule to keep in mind before you batch: caption what should stay variable, leave what should be permanent undescribed. An auto-captioner describes everything it sees, so treat the generated .txt files as a strong first draft - skim them and prune the lines describing the features you want your LoRA to lock in.
The inputs that matter
model- fromFlorence2 Model Loader.directory- the folder to caption. The defaultX://path/to/filesis a placeholder; swap in a real path.task- same seven options as the single-image node (caption,detailed_caption,more_detailed_caption,tags,mixed,extra_mixed,analyze).more_detailed_captionfor prose,tagsfor comma tags. This choice applies to every image in the folder.save_to_new_directory(off) andsave_directory(optional) - by default the.txtfiles land next to the source images. Turnsave_to_new_directoryon and setsave_directoryto write them somewhere separate and keep your originals clean.
num_beams (3), do_sample (on), max_new_tokens (1024), seed and keep_model_loaded behave exactly like the single-image node.
The output is log (a STRING) - a progress report, not the captions (those go to the .txt files). Wire it into a ShowText node if you want to watch it work.
How to install it
Part of ComfyUI-CaptionThis:
- ComfyUI Manager (recommended): search CaptionThis, Install, restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/MieMieeeee/ComfyUI-CaptionThis, then restart.
Florence-2 weights download from HuggingFace on first run (or set HF_ENDPOINT=https://hf-mirror.com for the mirror). See the Florence2 Model Loader page for variant and precision details.
Common issues & troubleshooting
Nothing gets captioned. You left the X://path/to/files placeholder in the directory field, or the path is wrong. Point it at a real folder of images.
It errors before processing a single file. That's the loader, not this node - usually flash_attention_2 chosen without the flash-attn package, or a precision mismatch. On the Florence2 Model Loader, set attention to sdpa, and try fp32 if you see NaN/garbage output.
Captions over-describe the subject. Expected - the model describes everything. Review the .txt files and prune the lines covering features you want your LoRA to treat as fixed.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MIE_FLORENCE2_MODEL | โ | |
| directory | STRING | X://path/to/files | โ |
| task | COMBO | more_detailed_caption | 7 options: caption, detailed_caption, more_detailed_caption, tags, mixed, extra_mixed, +1 |
| seed | INT | 421โ18446744073709550000 | โ |
| max_new_tokens | INT | 10241โ4096 | โ |
| num_beams | INT | 31โ64 | โ |
| do_sample | BOOLEAN | true | โ |
| keep_model_loaded | BOOLEAN | true | โ |
| save_to_new_directory | BOOLEAN | false | โ |
| save_directoryopt | STRING | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| log | STRING | โ |