Nodes/ComfyUI-VisualQueryTemplate/Visual Query Template
ComfyUI Node

Visual Query Template

Ask your image questions, get a prompt back — the node that turns one portrait into a character sheet

By celoron·Created 2 years ago·Updated about a year ago· 14
Visual Query Template
  • images
  • STRING
model
question{eye color} eyes, {hair style} {hair color} hair, {ethnicity} {gender}, {age number} years old, {facialhair}

Visual Query Template is a visual question answering (VQA) node: you feed it an image, hand it a question template, and it answers each question and stitches the answers back into one string. The name is a mouthful, but the pitch is genuinely handy for one specific job - turning a single reference image into a structured character description you can drop into a prompt, a LoRA dataset caption, or a character-sheet workflow.

The default question field tells you exactly who this is for: {eye color} eyes, {hair style} {hair color} hair, {ethnicity} {gender}, {age number} years old, {facialhair}. That's not a captioning tool's vocabulary, that's a character-consistency checklist. If you've ever had one good portrait of an OC and needed a text description to seed generations or caption training images, this is the niche it fills. If you instead want free-form "describe this scene" captions, grab a proper captioner or WD14 tagger - this node answers questions, not "what's going on here".

How it works

The source is a single ~70-line file, which is a good sign for something this small. Under the hood it calls Hugging Face's transformers pipeline for VQA. Each run, it loads the chosen model (device = 0 if CUDA else -1, so GPU when you have one), then for every image in your batch it does the same dance:

  1. Converts the image tensor to PIL.
  2. Finds every {placeholder} in your question.
  3. Asks the model each placeholder as its own question - {eye color} literally sends "eye color" as a question - and takes the top answer.
  4. Replaces the placeholder in the template, and returns one finished string per image.

That's the mechanism to remember: one placeholder = one forward pass per image. Six slots in your template means six VQA calls per image. Fine on a GPU, slow as treacle on CPU. It also rebuilds the pipeline from scratch every execution - the weights are cached after the first run so there's no re-download, but don't put this node inside a per-frame loop and expect speed.

The inputs that matter

  • images (IMAGE) - a batch of tensors, so wire in a Load Image or anything that outputs an image.
  • model - pick from four real Hugging Face VQA models: Salesforce/blip-vqa-base (the sensible default), blip-vqa-capfilt-large, dandelin/vilt-b32-finetuned-vqa, or microsoft/git-large-vqav2. GIT-large is the most accurate and the heaviest; VILT sits in the middle; BLIP base is small and fast.
  • question (STRING, multiline) - your template with {placeholders}. The craft is in phrasing them as fill-in-the-blank questions (hair style, age number), because VQA models answer short, single-token-ish answers. A placeholder like describe this person will return noise.

It outputs a STRING list - one completed template per input image - which wires straight into any text input: a Show Text node, a prompt concatenator, or a CLIP text encode if you're auto-building prompts.

Installing it

ComfyUI Manager (search "VisualQueryTemplate"), or the usual manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/celoron/ComfyUI-VisualQueryTemplate
# restart ComfyUI

The requirements.txt pins torch, numpy, transformers - you already have torch and numpy; transformers is the one real dependency Manager will install for you. The hidden cost is the model: the first run downloads your pick from Hugging Face, and GIT-large is over a gigabyte, so give it internet and a minute.

Honest notes

This is an obscure pack - effectively zero impressions on comfy.icu, and the author's own r/comfyui announcement post got no replies. That's not a red flag by itself: the code is short and readable, it makes no API calls and needs no key, and it runs entirely locally after the one-time model download. But you're not getting an active maintenance track either. Treat it as a small utility you can verify yourself, which is easy since the whole thing is one file. If you want stronger structured description and don't mind a bigger footprint, modern vision-LLM nodes will run circles around 2021-era VQA models - but for cheap, offline, slot-filling description this still does the job with zero setup drama.

Categoryimage

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
modelCOMBO4 options: Salesforce/blip-vqa-base, Salesforce/blip-vqa-capfilt-large, dandelin/vilt-b32-finetuned-vqa, microsoft/git-large-vqav2
questionSTRING{eye color} eyes, {hair style} {hair color} hair, {ethnicity} {gender}, {age number} years old, {facialhair}

Outputs (1)

NameTypeDescription
STRINGSTRING