Nodes/ComfyUI-moondream/MoondreamQuery
ComfyUI Node

MoondreamQuery

The Node That Answers 'What Is This?' — MoondreamQuery

By kijai·Created 3 years ago·Updated 2 years ago· 109
MoondreamQuery
  • images
  • text
questionWhat is this?
keep_model_loadedtrue
modelmoondream2
max_new_tokens256

You just rendered an image and you want to know what's actually in it, or you want a workflow to write its own subject prompt. MoondreamQuery is how you ask. It runs a genuinely tiny vision-language model entirely on your machine - no API, no key, no cloud call. Feed it an image, type a question in plain English, and out comes a string with the model's answer.

The model is vikhyatk's moondream, a 1.6–2B parameter VLM built on SigLIP and a small Phi-1.5 language model. Kijai - the same prolific node author behind ComfyUI-LTXVideo, ComfyUI-GGUF and ComfyUI-SUPIR - wrapped it for ComfyUI back in early 2024. This is the era of "auto-interrogator" workflows: SUPIR upscaling famously uses a moondream interrogator to auto-generate the subject prompt its upscaler conditions on, instead of making you type one. MoondreamQuery is exactly that trick as a standalone node: you can wire its output into your positive prompt, a text file, or just a ShowText node to read what the model thinks it sees.

How it works

On the first run the node downloads the weights from Hugging Face (vikhyatk/moondream1 or vikhyatk/moondream2) into the pack's own checkpoints folder - a couple of GB, done once. After that, each run is a two-step pipeline: the SigLIP vision encoder turns your image into embeddings, then the text model generates the answer autoregressively, stopping at max_new_tokens. It lands on whatever torch device ComfyUI is using and drops to fp16 when it can.

The inputs that matter

There are five, and honestly you'll only touch three:

  • images - an IMAGE tensor from any Load Image / batch.
  • question - the prompt, multiline. The default is literally "What is this?", which is the single most useful question you can ask it.
  • model - moondream1 or moondream2. The default is moondream2 and you should leave it there; it's better and tolerates modern transformers far more gracefully (see below).
  • keep_model_loaded - defaults true, which means the model stays resident in VRAM after the first run so the next question is instant.
  • max_new_tokens - how long an answer it's allowed to write. 256 is plenty.

The output is one text STRING. Here's the gotcha: feed it more than one image and it answers each one separately, then hands you a JSON-ish dictionary string - {"0": "a red train", "1": "a dog"} - instead of a plain sentence. For a single image you just get the answer. If you want a clean one-per-image list instead, that's what the sibling MoondreamQueryCaptions node is for.

Installing it

ComfyUI Manager: search ComfyUI-moondream. Or the old-fashioned way:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-moondream

Restart ComfyUI. The node's own requirements.txt pulls accelerate, huggingface-hub, Pillow, timm and einops - note there's no pinned transformers version, which matters below.

Where people get burned

  • First run looks frozen. The ~3GB model download runs silently with no progress bar. Watch ComfyUI/custom_nodes/ComfyUI-moondream/checkpoints/moondream2/ instead of the console. If the download fails you get a bare "No model found." error.
  • moondream1 + a modern transformers = crash. The classic symptom is a tensor-size mismatch ("The size of tensor a (760) must match the size of tensor b (761)"). Kijai's repo issue #3 carries a one-line fix for moondream1 on newer transformers, but the pragmatic answer is: use moondream2.
  • It's an old pack. Last touched March 2024, and moondream was always a "good enough, runs anywhere" model, not a frontier one. The model can produce inaccurate or oddly confident answers, and its English is fairly literal.

One honest caveat before you build a whole pipeline around this: as a captioning workhorse it's slow, and kijai's own Florence-2 node was reported as dramatically faster per image within months. For asking a render a question, or generating a subject prompt automatically, MoondreamQuery is still the easiest thing that works. For mass captioning, look elsewhere.

CategoryMoondream

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
questionSTRINGWhat is this?
keep_model_loadedBOOLEANtrue
modelCOMBOmoondream22 options: moondream1, moondream2
max_new_tokensoptINT256

Outputs (1)

NameTypeDescription
textSTRING