GLM BBox JSON To Mask
GLM's desc/class/bbox JSON becomes an inpaint mask
- image
- mask
The GLM Vision BBox Extractor asks a vision model where the logos and banners are and gets back JSON. This node is what turns that JSON into something ComfyUI can act on: a native MASK where every boxed region is white and ready for inpainting. It's the "JSON in, mask out" bridge for the GLM side of the pack.
How it works
The input is the JSON list of {desc, class, bbox} records the extractor produces (or any compatible JSON with bbox arrays). The node parses it, scales the coordinates to pixels, and rasterizes each rectangle onto a float32 [batch, height, width] mask in ComfyUI's standard format - 1 for the boxed area, 0 elsewhere. It expands each box by image-size percentages (not raw pixels), clips everything to the image boundary, and drops any box that ends up with zero area.
The workflow it's designed for is short:
Load Image -> GLM Vision BBox Extractor -> GLM BBox JSON To Mask
| ^
+--------------------------------------+
Wire the mask into VAE Encode (for Inpainting) or Set Latent Noise Mask and you're removing logos.
The inputs that decide correctness
coord_base- defaults to1000for normalized coordinates; set0when the JSON uses source-image pixels. This must match what your extractor prompt asked for. The README's example keeps1000because the default GLM prompt works in that space.coordinate_order-x1,y1,x2,y2(default) ory1,x1,y2,x2. If your prompt told GLM to emit y-first, flip this or the mask is mirrored garbage.horizontal_expand/vertical_expand- percentage of image width/height added on each side.horizontal_expand=10grows the box by 10% of the image width left and right. Decimal values are supported (step 0.1). This is your "cover the whole banner, not just the logo glyphs" dial; set both to0for no expansion.
image is required and does double duty: it supplies the mask dimensions and batch size. Output is the single mask.
Installing
Part of comfyui-dsocr-bbox. ComfyUI Manager (search "dsocr") or:
cd ComfyUI/custom_nodes
git clone https://github.com/maomaozi/comfyui-dsocr-bbox
restart. No extra dependencies for the GLM path - stdlib only. (The pack's rapidocr-onnxruntime requirement covers its local-OCR nodes.)
Where people get burned
Nearly every failure traces back to one of the three coordinates knobs being mismatched with the prompt that produced the JSON: coord_base normalized-vs-pixel, or coordinate_order x-first-vs-y-first. Get those right and the rest is easy. One pleasant surprise buried in the docs: GLM BBox JSON Protected Expand always emits canonical x-first pixel JSON, so you can feed its output here with coord_base=0 and the default x-first order - no guessing. If your mask comes out as a white corner dot, it's the coordinate base; if it looks mirrored, it's the order.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| bbox_json | STRING | — | |
| horizontal_expand | FLOAT | 0.00–100 | — |
| vertical_expand | FLOAT | 0.00–100 | — |
| coord_base | INT | 10000–100000 | — |
| coordinate_order | COMBO | 2 options: x1,y1,x2,y2, y1,x1,y2,x2 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |