π· TA Directory Captioning
Caption a whole folder of images with a local vision LLM
- status
Building a training dataset means captioning hundreds of images, and doing that by hand is a slow, sad afternoon. TA Directory Captioning turns that into a batch job: point it at a folder, and it writes a .txt caption next to every image using a vision-capable LLM served by LM Studio or Ollama - all local, no API key, no uploads.
Here's the flow. You give it a directory_path and pick a model from the dropdown, which is populated by pinging both backends at node-load time - LM Studio on 127.0.0.1:1234 and Ollama on 127.0.0.1:11434. That's what server_url is for; the default points at LM Studio, so flip it to the Ollama port if that's your backend. Vision-capable models are auto-tagged with [Vision] in the list, and it preselects the first one it finds - you do need a vision model here, a text-only model can't see the images.
For each image in the folder it normalizes the file (fixes EXIF orientation, converts to RGB, strips metadata), downscales it to max_image_size on the longest side, base64-encodes it, and fires it at the backend with your prompt and system_prompt. The defaults are sensible captioning instructions - describe subject, style, colors, lighting, composition, no bullet points - and temperature defaults low (0.2) because you want factual captions, not creativity. The response is written to a same-name .txt file. max_tokens caps how long each caption can be, and overwrite_existing controls whether files that already have a caption get redone (default: skip them).
Two implementation details matter. max_image_size isn't a quality knob - it's a compatibility knob. Oversized images get rejected by the backend with an HTTP 400, which is exactly the error the tooltip warns about; downscaling to 1024 avoids it. And the node forces re-execution on every queue run via a timestamp, so if you drop new images into the folder and run again, it picks them up. Output is a single status string you can show in a text display to see how many images were processed.
This is the pack's least-glamorous node and arguably one of its most useful - it's a real pre-training chore done properly. It leans on the same backend discovery as TA Smart LLM, so if that node's dropdown shows "No Backend", this one will too, and the fix is the same: make sure LM Studio or Ollama is actually running before you queue.
Install. No extra Python packages - the pack itself is dependency-free:
cd ComfyUI/custom_nodes
git clone https://github.com/tmode-1960/TA-ComfyUI-Nodes-Pack
or via ComfyUI Manager. Restart, find it under TA-Nodes/LMStudio. The only external requirement is a running LM Studio or Ollama with a vision model loaded.
Gotchas. The usual suspects: wrong port (HTTP 400s or empty model lists), a non-vision model selected (you'll get gibberish or "I can't see images"), and the v2.x pack rewrite breaking old workflows. Also note captions land in the same folder as the images - make sure that's where you want them before you run a big batch.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| directory_path | STRING | C:/Images/to_caption | β |
| model | COMBO | No Backend | 1 options: No Backend |
| server_url | STRING | http://127.0.0.1:1234 | LMStudio: http://127.0.0.1:1234 | Ollama: http://127.0.0.1:11434 |
| prompt | STRING | Describe this image in one continuous sentence or short paragraph. No labels, no bullet points, no line breaks. Focus on: subject, style, colors, lighting, composition, background. No filler phrases, no interpretation. Respond in English. | β |
| system_prompt | STRING | You are a precise image captioning assistant for AI training datasets. Describe only what is visible. Be factual, concise, and always respond in English. | β |
| temperature | FLOAT | 0.20β2 | β |
| max_tokens | INT | 1501β131072 | β |
| max_image_size | INT | 1024256β4096 | Longest side in pixels. Larger images are downscaled (prevents HTTP 400). |
| overwrite_existing | BOOLEAN | false | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| status | STRING | β |