Recaption
Turn any image back into a prompt
- image
- text
Recaption is Prompt Enhancer's sibling, pointed the other direction: you hand it an image and it hands you back the prompt. No local vision model, no downloads - the image is sent to any OpenAI-compatible endpoint that speaks the vision message format (OpenAI, LM Studio with a VL model, LocalAI, vLLM, and friends). If you've ever looked at a render you love and wanted the prompt that made it, or stared at a batch of training images and dreaded hand-writing fifty captions, this is the node for that.
The timing is right for it, too. Captioning quality matters more than dataset size when you're training, and the community's hard-won advice is that a good captioner beats a fast one every time - BLIP is widely considered unusable for training work, while dedicated taggers and vision LLMs carry the load. Recaption is a middle path: instead of a fixed auto-tagger, you get a vision LLM with a system prompt you control, and the seeded styles are genuinely well-written. The "Stable Diffusion" style outputs Danbooru-convention tags for anime and plain descriptive tags for photos, 25–50 of them, densest information first, and refuses to invent quality boosters it can't verify in the image. The "Flux" style switches to 60–180 words of natural-language prose, which is exactly what Flux-class models want. For a LoRA training set, that's a far better baseline than raw WD14 output, and for a single image you can also just use the result as your next generation prompt.
The inputs that matter
- image - an IMAGE tensor. Only the first frame of a batch gets captioned, so a single-image source is the clean case; if you feed it a batch expecting per-frame captions, you'll get one caption for the first frame and silently nothing for the rest.
- style - the captioner's system prompt, from YAML files under
user/default/coras_textgen/prompts/recaption/. Edit the seeded files or add your own; they're never overwritten. - model - a vision-capable model from your endpoint's
/modelslist.
Output is a single text string, <think>-stripped. Wire it into a text encoder, save it, or feed it back into Prompt Enhancer for another pass.
How it works
On run, the node grabs the first frame of your image, encodes it as a base64 PNG, and sends it as an OpenAI-compatible vision message (image_url content part) to <api_base>/chat/completions alongside the style's system prompt. The model dropdown is filtered by a name heuristic - it looks for vision, vl, llava, gpt-4o, gemma, pixtral, molmo, claude, minicpm, florence, moondream, multimodal, that family. If the filter would empty the list entirely, it falls back to showing every model so the dropdown never sits on "Loading..." - and if your model's id doesn't advertise its eyes, that fallback is why you can still pick it.
Install and configure
Same pack as the others. ComfyUI Manager, search "Text Gen Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/cora-clanker/comfyui-textgen-nodes
Restart, then set the endpoint and API key in Settings → Cora's Textgen. The key has no default and only gets written to disk once you change the setting, so actually enter it (or set CORAS_TEXTGEN_API_KEY) or every call fails. Only dependency is requests, which ComfyUI already ships.
Where people get burned
- Vision model missing from the dropdown. The heuristic is a substring guess, so a model whose id is just
my-awesome-vlmwith no telltale keyword gets filtered out. The fallback usually saves you, but if the dropdown still looks wrong, flip Filter Vision-Capable Models off in Settings to see everything and pick manually. If you pick a genuinely non-vision model, you'll get a clear server error at run time - there's no silent garbage. - Timeouts on big images. The whole PNG goes up as base64, and a slow local VL model plus a large image can blow past the 60-second default timeout. Raise it in Settings if captioning keeps dying mid-call.
- Batches. Remember the first-frame-only behavior. For a training dump of hundreds of images, you're better off batching at the file level outside ComfyUI anyway; this node shines for one-off re-captions and for controlling exactly how the caption is phrased.
The honest caveat: if you're captioning a thousand-image dataset, a dedicated local tagger or JoyCaption-class tool will do it faster and free. Recaption's edge is precision and control - the caption comes out written your way, in your style YAML, one thoughtful image at a time.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| style | COMBO | Prompt style. Edit or add YAML files under <user>/default/coras_textgen/prompts/recaption/. | |
| model | COMBO | Vision-capable models advertised by the configured endpoint. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |