ComfyUI Node

GLM-4V Generate

A real 9B vision model on your own GPU — GLM-4V Generate

By linjian-ufo·Created about a year ago·Updated about a year ago· 5
GLM-4V Generate
  • image
  • description
promptdescribe this image,Describe in long sentence form, without using Markdown format.
model_nameglmv4_4bit
unload_policyAlways

The name is a bit of a tease: GLM-4V Generate looks like another "describe this image" utility, but what it's actually doing is running Zhipu's GLM-4V vision-language model - a genuine 9B-parameter multimodal LLM, not a tagger - entirely on your own machine. No API key, no cloud round-trip, no filter deciding what you're allowed to caption. You feed it an image, it writes you a sentence. Sometimes a whole paragraph.

It's one of two nodes in the linjian-ufo/ComfyUI_GLM4V_voltspark pack (the sibling, Glm4vBatchNode, does whole folders). GLM is the MIT-licensed open line from Zhipu/Z.ai, the Tsinghua spin-off that also gave us CogVideoX - so unlike a lot of closed captioning services, the weights are yours to run. The community that compares local captioners against JoyCaption and WD14 consistently puts GLM-4V in the "surprisingly strong, one node does everything" camp. Where the WD14 taggers emit comma-separated Danbooru tags for the anime lineup, GLM-4V writes natural language - which is exactly what you want when you're captioning a dataset for an LLM-encoder model like Flux, where sentence captions beat tags.

How it works

The node looks for the model folder at ComfyUI/models/glmv4_4bit/ (or ComfyUI/models/GLM-4.1V-9B-Thinking/ if you pick that in the dropdown), then loads it via AutoProcessor + Glm4vForConditionalGeneration with trust_remote_code=True in bfloat16. It checks your free VRAM against an estimated model size - about 6.7GB for the 4-bit build - and if you're short, it falls back to bitsandbytes NF4 quantization with device_map="auto" and CPU offload. Plenty of VRAM and it loads the whole thing on the GPU. Generation is greedy (do_sample=False) with a generous 8192-token cap, so outputs are deterministic and can run long. If the model returns an <answer> block, the node strips it out and hands you just that text.

The inputs that matter

  • image - your IMAGE tensor, straight from any Load Image or your sampler's output.
  • prompt - a multiline text box, defaulting to the author's own preset: describe this image,Describe in long sentence form, without using Markdown format. It works, but you'll quickly want your own - the README's "photographer's perspective" example (composition, lighting, mood) gets you much richer captions.
  • model_name - glmv4_4bit (default) or GLM-4.1V-9B-Thinking. The full-precision model gives nicer prose at the cost of VRAM.
  • unload_policy - the one that bites. Default is Always, meaning the model is unloaded after every single image. For back-to-back runs, switch to Never or After 5 mins or you'll sit through a multi-GB reload each time.

The output is a single description STRING, which you can wire into a Save Text node, a prompt text box, or a captioning pipeline.

Installing it

Use ComfyUI Manager (search "GLM-4V"), or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/linjian-ufo/ComfyUI_GLM4V_voltspark
# restart ComfyUI, then install deps:
pip install -r ComfyUI_GLM4V_voltspark/requirements.txt

Dependencies include torch>=2.0, transformers==4.54.0 (pinned - see below), accelerate, bitsandbytes, Pillow, numpy, sentencepiece, and protobuf. The README's "auto-download from Hugging Face" line is a lie - the code does not download anything. It raises FileNotFoundError if ComfyUI/models/glmv4_4bit/ doesn't exist, so get the weights yourself (Baidu links in the README for mainland users; otherwise pull the model from Hugging Face and drop it in that folder).

Where people get burned

  • CUDA-only. The node hard-fails without a CUDA GPU - no Apple Silicon, no CPU mode.
  • The transformers pin. requirements.txt pins transformers==4.54.0 while the README tells you to upgrade to the latest. If your ComfyUI env has a newer transformers, pip install -r will downgrade it and possibly break other nodes. Install it in an isolated env, or accept the pin.
  • Slow first run. Loading a 6.7GB model takes a while. Set unload_policy to Never if you're doing more than one caption, and remember it'll hog VRAM until you restart or run a Never-adjacent policy.

If the node returns "加载模型时出错" (model load error), the folder path is your first suspect. If it says no CUDA, well - it told you so.

CategoryGLM4V

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
promptSTRINGdescribe this image,Describe in long sentence form, without using Markdown format.
model_nameCOMBOglmv4_4bit2 options: glmv4_4bit, GLM-4.1V-9B-Thinking
unload_policyCOMBOAlways6 options: Always, Never, After 1 min, After 2 mins, After 5 mins, After 10 mins

Outputs (1)

NameTypeDescription
descriptionSTRING