GLM-4V Batch Generate
Caption a whole folder of images with GLM-4V Batch Generate
- batch_results
- statistics
Point a single-image captioner at a folder of a few hundred images and you'll be there all day. GLM-4V Batch Generate exists to solve exactly that: you give it a directory, it runs Zhipu's GLM-4V vision model over every image inside, and drops a .txt file with the same base name next to each one. sunset_beach.jpg becomes sunset_beach.txt. That's the headline feature, and for captioning a training set it's the whole game.
It's the batch sibling to Glm4vNode in the same linjian-ufo/ComfyUI_GLM4V_voltspark pack - same model, same mechanism, one extra layer of folder handling. The model is the open MIT-licensed GLM-4V from Zhipu/Z.ai (the Tsinghua spin-off behind CogVideoX), so everything runs locally with no API key and no filter. In the natural-language captioning space, people typically reach for JoyCaption or Florence 2; GLM-4V is the "also great, and it's a full chat model" alternative that holds its own. Because it writes sentences rather than Danbooru tags, it's the right tool when your destination is an LLM-encoder checkpoint like Flux - the exact opposite of the WD14 tagger workflow you'd use for Illustrious or Pony.
How it works
Under the hood it's honest about its laziness: it creates a Glm4vNode internally and calls its generate() per image while forcing unload_policy to Never for the loop, so the ~6.7GB model loads once, not per file. It globs the folder for the extensions you list (case-insensitive), caps the count at max_images, converts each image to a tensor, and records per-file status, description, and processing time. With save_results on, it writes two things into that same folder: the same-name .txt per image, and a combined timestamped results file in your chosen format. Output is greedy, deterministic, up to 8192 tokens.
The inputs that matter
- image_folder_path - the one that's obviously load-bearing. Absolute path to your images; the node fails cleanly if it doesn't exist.
- image_extensions - defaults to
jpg,jpeg,png,bmp,tiff,webp. Comma-separated; it matches both cases. - max_images - a hard cap (1–1000, default 10). Bump it up before you run, or you'll caption ten images and wonder where the rest went. Remember the model loads once, so batches are cheap once warm.
- save_results and output_format -
output_format(TXT/JSON/CSV) controls the combined results file; the same-name.txtfiles are always written regardless. - prompt, model_name, unload_policy - same as the single node, with the batch default on
unload_policybeingAfter 5 minsrather thanAlways, which is the sane choice here.
Outputs are two STRINGs: batch_results (per-file status + description, for wiring into a Save Text node or log) and statistics (totals, success/failure counts, average seconds per image).
Installing it
It's the same pack as Glm4vNode, so the install is identical:
cd ComfyUI/custom_nodes
git clone https://github.com/linjian-ufo/ComfyUI_GLM4V_voltspark
pip install -r ComfyUI_GLM4V_voltspark/requirements.txt
or just search "GLM-4V" in ComfyUI Manager. Dependencies: torch, transformers==4.54.0 (pinned - beware it downgrading a newer env), accelerate, bitsandbytes, Pillow, numpy, sentencepiece, protobuf. And the same gotcha as the single node: the README claims the model auto-downloads from Hugging Face, but the code actually raises FileNotFoundError if ComfyUI/models/glmv4_4bit/ isn't already on disk. Download the weights yourself and drop the folder there before running.
Where people get burned
- It writes into your source folder. Same-name
.txtfiles and the combined results file land right next to the images. Point it at a folder you're fine having written into - don't aim it at your precious originals. - CUDA-only, like its sibling; no Macs or CPU mode. It'll error out clearly if it can't find a GPU.
- VRAM. The 4-bit model is ~6.7GB, and if you're short the code auto-falls back to NF4 quantization with CPU offload. That works, but it's slow - the full-precision
GLM-4.1V-9B-Thinkingoption is roughly double the footprint, so don't pick it on a small card. - Individual failures don't kill the batch - they're logged with
status: errorin the results and the loop keeps going. Checkstatisticsat the end rather than assuming silence means success.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image_folder_path | STRING | C:/path/to/your/images | — |
| prompt | STRING | describe this image,Describe in long sentence form, without using Markdown format. | — |
| model_name | COMBO | glmv4_4bit | 2 options: glmv4_4bit, GLM-4.1V-9B-Thinking |
| image_extensions | STRING | jpg,jpeg,png,bmp,tiff,webp | — |
| max_images | INT | 101–1000 | — |
| save_results | BOOLEAN | true | — |
| output_format | COMBO | TXT | 3 options: TXT, JSON, CSV |
| unload_policy | COMBO | After 5 mins | 6 options: Always, Never, After 1 min, After 2 mins, After 5 mins, After 10 mins |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| batch_results | STRING | — |
| statistics | STRING | — |