moondream2 Encode Image
Pay the vision cost once, then ask all day
- model
- image
- md2_image
moondream2 Encode Image is the gatekeeper of this whole pack: it takes a regular ComfyUI image and runs the moondream2 vision encoder over it, turning the pixels into a md2_image that the Caption and Query nodes can actually read. You can't skip it, and once you get why it exists you'll appreciate it.
The design is deliberate. For a vision-language model, encoding the image is the expensive part - far pricier than generating a bit of text about it. This pack splits those two jobs on purpose: Encode does the heavy lifting once, and then Caption and Query can run against the same encoded result as many times as you like without re-encoding. If you're asking five questions about one render, or captioning a batch and then spot-checking a few with queries, that's the difference between "fine" and "my whole graph slowed to a crawl."
Inputs and output
- model - the moondream2 from the DownLoad node. No model, no encode.
- image - any standard ComfyUI IMAGE. A Load Image, a sampler's output, a frame from a video workflow - if ComfyUI calls it an image, this takes it.
The md2_image output is a custom type that only the Caption and Query nodes accept, so that's where it wires. That's also the trap: try to plug a raw IMAGE straight into Caption or Query and you'll get a type mismatch, because the pack insists on the encode step. There's no way around it.
Install
ComfyUI Manager → search ComfyUI-moondream2, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zhilemann/ComfyUI-moondream2
Restart and you're in business. Like the rest of the pack it needs the model weights downloaded on first use (the DownLoad node does that) and a reasonably current transformers.
Common issues
The usual pack-level stuff applies: the first-run model download looks like a hang, and a transformers-flavored load error means your transformers is too old - pip install -U transformers and restart.
The encode-step-specific gotcha is expectation management about batches. If you feed a big batch through, the encode is your bottleneck - that's exactly where the int4 quant on the DownLoad node earns its keep. And remember that an encode is a snapshot: if you change the image, the graph re-runs and re-encodes, which is correct behavior but worth knowing when you're iterating on one image and wondering why a single Encode keeps eating time.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | moondream2 | — | |
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| md2_image | MD2_IMAGE | — |