Nodes/comfyui-dsocr-bbox/GLM BBox JSON To Mask
ComfyUI Node

GLM BBox JSON To Mask

GLM's desc/class/bbox JSON becomes an inpaint mask

By maomaozi·Created 2 months ago·Updated 2 months ago· 0
GLM BBox JSON To Mask
  • image
  • mask
bbox_json
horizontal_expand0.0
vertical_expand0.0
coord_base1000
coordinate_order

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 to 1000 for normalized coordinates; set 0 when the JSON uses source-image pixels. This must match what your extractor prompt asked for. The README's example keeps 1000 because the default GLM prompt works in that space.
  • coordinate_order - x1,y1,x2,y2 (default) or y1,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=10 grows 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 to 0 for 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.

Categorydsocr_bbox/GLM Vision BBox

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
bbox_jsonSTRING
horizontal_expandFLOAT0.00–100
vertical_expandFLOAT0.00–100
coord_baseINT10000–100000
coordinate_orderCOMBO2 options: x1,y1,x2,y2, y1,x1,y2,x2

Outputs (1)

NameTypeDescription
maskMASK