moondream2 Caption
A caption from a 2B vision model that runs entirely on your machine
- model
- md2_image
- caption
moondream2 Caption looks at an image and writes a sentence about it, entirely on your machine. No API, no key, no cloud round-trip - despite the product-sounding name, this is a tiny vision-language model living inside your ComfyUI install.
Reach for it when you want to caption a stack of images without a monster GPU. In the local-captioner pecking order, moondream2 sits a rung below JoyCaption and Florence-2 on quality, and comfortably above BLIP - which, as anyone who's trained a LoRA recently will tell you, has been "pure trash" for years. What moondream2 gives back for that quality gap is size: a couple of billion parameters, small enough to run on a laptop CPU if you don't mind waiting. For sorting a folder, finding a few good frames, or seeding a prompt, it's exactly the right tool. For building a serious training dataset, caption by hand or reach for JoyCaption instead.
How it works
The pack splits a VLM into two halves. You first run the image through moondream2 Encode, which runs the vision encoder and hands back a pre-encoded md2_image. This node takes that encoded result and runs the language half: it nudges the small LLM with a "describe this image" style prompt and streams out text. That two-stage design is why you can run the pricey vision step once and then caption or query the same image as many times as you like - worth remembering if you're asking more than one thing per render.
Inputs and output
The knobs you'll actually touch:
- model - the moondream2 you loaded with the DownLoad node.
- md2_image - the output of moondream2 Encode. There's no way around encoding first; this node won't accept a raw IMAGE.
- length -
shortgives you a one-liner,longa fuller description. - max_tokens - the ceiling on generated text, 512 by default. Generous; you'll rarely touch it.
The caption output is a plain STRING. That's what makes the node flexible: wire it into a CLIPTextEncode text input to feed an image its own caption as the prompt for an img2img pass, or drop it into a Save Text node to build a .txt per image for dataset prep - the classic "load a folder, caption each image, save" loop.
Install
ComfyUI Manager → Custom Nodes Manager → search ComfyUI-moondream2, or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/zhilemann/ComfyUI-moondream2
Restart ComfyUI. The pack needs a reasonably recent transformers (more below) and pulls the model weights from HuggingFace on first use.
Common issues
The first-run trap: the DownLoad node is fetching a couple of gigabytes from HuggingFace the first time you run the graph. It looks hung. It isn't - let it finish once and it's cached forever after.
If you hit a load error that mentions transformers, that's the classic moondream failure mode: the model needs a newer transformers than ComfyUI's bundled environment ships. pip install -U transformers and restart usually clears it.
And manage expectations. At 2B this model writes fluent, mostly-accurate captions, but small models hallucinate small details, and the 0.5b variant is noticeably dumber. Great for batching and prompt reuse; verify anything you're about to train on.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model | moondream2 | — | |
| md2_image | MD2_IMAGE | — | |
| length | COMBO | short | 2 options: short, long |
| max_tokens | INT | 512 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| caption | STRING | — |