VL text → OCR JSON (after Qwen-VL)
Qwen-VL Found The Text. Now Make It Usable By The Mask Node.
- image
- ocr_json
- mask
A vision-language model is genuinely better than classic OCR at one thing: reading a busy ad layout. It knows a price badge is a price badge, it doesn't split a stylised wordmark into three fragments, and it handles a language switch without you reinstalling anything. What it cannot do is give you a mask. It gives you prose, or a JSON array inside a blob of prose, and both of those are useless to a mask or render node.
That's the gap VevorVlTextToOcrJson plugs. Wire the text output of a VL node (the author names the community QwenVisionParser, but anything that returns a JSON array in a string works) plus the source image, and out come the same two things the rest of this pack's OCR side speaks: labelme JSON and a mask batch.
The parsing, honestly described
This is a small node and it does small-node things, which is good - you can predict exactly how it will and won't fail once you know the steps.
It strips a leading/trailing markdown fence (```json), then slices from the first [ in the string to the last ], then json.loads. Anything the model said before or after the array - "Sure, here are the regions:" - gets discarded by that slice. Then per item it wants a text key (or label), and a box from bbox, box or points, taking the first four numbers. Score defaults to 0.9. Everything else produces a labelme rectangle with a label of text:score and one filled rectangle in the mask batch.
No OCR, no model loading, no dependencies beyond numpy and torch. It's a converter with an opinion about what a well-behaved VL model should have returned.
Inputs and outputs
image- the IMAGE the model was looking at. Used for canvas width and height, frame 0 only. It is not used for detection; the geometry comes entirely from the model's numbers.text- STRING, connect-only. The VL node's text output. You can't type into it, which forces you to keep the provenance honest.
Outputs: ocr_json (labelme, single document) and mask ((N, H, W), one rectangle per region). Mask → VevorMaskBatchUnion → grow/feather/composite. JSON → VevorOcrGuard if you want brand protection and noise dropping, otherwise straight to VevorTextRender.
The node's own description is precise about its purpose: it exists "for VevorOcrGuard". It's a front-end adapter so that a VL model can stand in for PaddleOCR or Surya without changing a single wire downstream. That's a good architectural instinct - swap the engine, keep the contract.
Install
Ships with the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/rexqin/comfyui-vevor-mask-union
# restart ComfyUI
Manager → search Vevor Mask Union works too. No model files, no pip installs. The VL model itself is a separate pack's problem, and on a 12 GB card a quantised Qwen-VL is a comfortable fit - but that's your node choice, not this one's.
Where people get burned
Pixel coordinates are assumed, and there is no rescaling. The pack's own VL prompt text asks the model for pixel coordinates on the image, and this parser takes whatever numbers arrive at face value. If your prompt (or your model's habits) produce normalised 0–1 coordinates, every box compiles into a two-pixel speck in the top-left corner and the mask is useless - with no error, because there's nothing illegal about the numbers. Check one debug mask before you build a workflow on top of it, and make sure your VL prompt says pixels.
A refusal and a clean answer look identical. If the model answers in prose with no array, the slice finds no [, json.loads never runs, the region list is empty, and you get a zero-frame mask batch. Nothing raises. The image comes out unchanged and you blame the sampler. This is the exact failure mode the KB's LLM-in-graph doc warns about: models emit chat scaffolding, and a node that doesn't hard-constrain decoding has to be defended against with prompt instructions and a look at the output.
Three box key names, four numbers, no unit validation. points from a model that meant "a polygon of six corners" gets truncated to its first four numbers as x1, y1, x2, y2 and you get a rectangle that's only half the region. Ask for bbox explicitly.
It inherits every VL limitation. Multi-subject attribution is where VLMs reliably fail - the KB's captioning section documents it for captioning and it applies just as hard to region boxes: two similar labels near each other and the model swaps their text. For a spec table with twelve near-identical rows, classic OCR is still more trustworthy. Use the VL path when the layout is messy and the text is stylised, not when it's dense and repetitive.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| text | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| ocr_json | JSON | — |
| mask | MASK | — |