DeepSeek OCR BBox To Mask
Turn DeepSeek OCR text into an inpaint mask without touching a brush
- image
- mask
If your workflow is "find every scrap of text on this image and inpaint it away," the manual path is miserable: eyeball the image, paint a mask over each word, try not to miss the watermark in the corner. This node kills that step. Feed it DeepSeek OCR output and it hands you a proper ComfyUI MASK with every text region already filled in white, ready to drop into an inpainting setup.
The name is the key thing to understand, because it's a little misleading: this node doesn't call DeepSeek's API. DeepSeek OCR is a separate cloud service you run yourself (via an HTTP request node, a Python script, or any tool that hits that API). What this pack does is consume the output of that service - the text-blob format DeepSeek OCR returns - and turn it into something a diffusion graph can actually use. You get the OCR elsewhere; this node makes it useful.
How it works
DeepSeek OCR returns boxes in a quirky tagged format that looks like this:
<|ref|>已售6万+健腹轮<|/ref|><|det|>[[59, 72, 485, 124]]<|/det|>
The parser here is forgiving. It accepts full DeepSeek OCR output, bare <|det|> blocks, plain lists like [[x1, y1, x2, y2], ...], dicts like {"bbox": [...]}, and even polygon points. It fills each bbox interior to 1 (white / the inpaint area) and leaves everything else 0, then returns a float32 mask in ComfyUI's native [batch, height, width] shape - the same shape the built-in Load Image node emits, so it plugs straight into VAE Encode (for Inpainting) or Set Latent Noise Mask.
DeepSeek OCR normalizes coordinates to a 0–1000 range, which is why coord_base defaults to 1000. Leave that alone unless your OCR output is already in raw pixels - then set it to 0.
The inputs that matter
Only three of them, honestly:
bbox_info- the OCR text, from a STRING socket. This is the one required input that's easy to get wrong: it's a socket, so wire the output of whatever produces your DeepSeek OCR result into it.coord_base-1000for DeepSeek's normalized output,0for pixel coordinates. Get this wrong and your mask is a 10×10 white dot in a corner.invert_mask- flips the selection. Handy when you want to inpaint everything except the text, though for normal logo removal you'll leave it off.
image_width and image_height can both stay at 0 if you connect the optional image input - it reads dimensions (and batch size) from the source image automatically. The image itself is only used for size; its pixels are untouched and not returned.
Installing it
This node ships in the comfyui-dsocr-bbox pack. Easiest route is ComfyUI Manager - search "dsocr" or the full title - or clone it manually:
cd ComfyUI/custom_nodes
git clone https://github.com/maomaozi/comfyui-dsocr-bbox
then restart ComfyUI. The only real dependency is rapidocr-onnxruntime (for the pack's local-OCR nodes), installed with:
pip install -r custom_nodes/comfyui-dsocr-bbox/requirements.txt
You don't strictly need that for this node - mask generation is pure geometry - but install the file anyway since the pack shares one environment.
Where people get burned
The classic failure is a mask that's all black or a tiny smudge: that's a coord_base mismatch, because DeepSeek's normalized coordinates get interpreted as pixels. The second classic: pasting raw DeepSeek OCR prose into a node that expects the socket format - this node accepts full text fine, but if your OCR result came out of an LLM wrapper that reformatted it, the parser may skip items it can't make sense of. Keep the original <|ref|>/<|det|> structure.
From there it's the standard inpainting loop - mask into VAE Encode (for Inpainting), run a denoise in the 0.5–0.8 range for text removal, and keep an eye on seams (generous mask padding helps). If you're cleaning a whole product-image batch, this is the node that turns it from a hobby into a pipeline.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| bbox_info | STRING | — | |
| image_width | INT | 00–100000 | — |
| image_height | INT | 00–100000 | — |
| coord_base | INT | 10000–100000 | — |
| invert_mask | BOOLEAN | false | — |
| imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |