Nodes/comfyui-dsocr-bbox/DeepSeek OCR Draw BBox
ComfyUI Node

DeepSeek OCR Draw BBox

Draw DeepSeek OCR boxes and crop every region in one go

By maomaozi·Created 2 months ago·Updated 2 months ago· 0
DeepSeek OCR Draw BBox
  • image
  • image
  • crop_images
  • crop_info
ocr_result
coord_base1000
crop_expand0
box_color#ff0000
box_width3
labelnone
label_color#ffffff
label_font_size20
font_path

You've got DeepSeek OCR output and you want to see what it found - and, while you're at it, grab each detected region as its own image. That's the whole job of this node. It draws the bounding boxes (or polygon outlines) onto your image, crops each bbox region into an image batch, and writes a JSON file that remembers exactly where every crop came from. It's the inspection-and-harvest step of the pack.

Like everything in the DeepSeek half of this pack, it doesn't call any API and needs no key. The ocr_result input is a STRING socket you wire to whatever produced the OCR text - another node, an HTTP call, a pasted file. The node just parses <|ref|>...<|/ref|><|det|>...<|/det|> tags and does geometry.

The three outputs are the point

  • image - your source image with the boxes drawn on. Feed it to a Preview or Save node and you get instant QA: did OCR catch the watermark in the corner, or skip it?
  • crop_images - every bbox region cut out and stacked into one IMAGE batch. This is what you'd route into a per-region upscale or a fresh inpaint pass.
  • crop_info - JSON with pixel coordinates for every crop: box, original_box, ref, text, and source size. Don't lose this string if you plan to put the crops back later - that's what the pack's paste node reads.

That last output is what makes this a workflow component rather than a preview toy. Crop → re-render each region → paste back is the classic detailing loop (same shape as the SEGS pipeline in Impact Pack, just with OCR coordinates instead of a detector). You can even process the crops with other tools entirely, as long as you keep crop_info alongside.

Inputs you'll actually touch

Mostly three:

  • coord_base - default 1000 for DeepSeek's normalized coordinates; set 0 if your OCR is already in pixels.
  • crop_expand - expands each crop outward by this many pixels (clipped to image bounds). A little padding, like 4–8, keeps the crop from cutting glyphs at the edge. Note that when you use it, box in crop_info becomes the expanded area while original_box keeps the unexpanded bbox.
  • label - none, ref, ref + text, or text; draws the OCR text (or its ref label) next to each box. Great for debugging, off for clean exports.

box_color, box_width, label_color, and label_font_size are cosmetic. If your text is Chinese and the labels render as tofu boxes, set font_path to a CJK font (the code knows the usual Windows/noto locations but only when you point it there).

Installing

It's part of comfyui-dsocr-bbox. Via ComfyUI Manager, search "dsocr", or:

cd ComfyUI/custom_nodes
git clone https://github.com/maomaozi/comfyui-dsocr-bbox

restart ComfyUI, and install the one dependency the pack needs for its OCR side:

pip install -r custom_nodes/comfyui-dsocr-bbox/requirements.txt

Common issues

The recurring trap is again coord_base: set 1000 on DeepSeek-normalized output and 0 on pixels, and if you're feeding this from another node that already converted to pixels, remember to flip it. Crop images come back as a batch, so ComfyUI pads them to a common size - keep that in mind if you stare at a crop and wonder why there's a black strip; the pack's paste node strips that padding automatically. Polygon detections are cropped by their enclosing rectangle while the drawn box keeps the polygon outline, which trips people up exactly once.

CategoryDeepSeek OCR

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
ocr_resultSTRING
coord_baseINT10000–100000
crop_expandINT00–10000
box_colorSTRING#ff0000
box_widthINT31–100
labelCOMBOnone4 options: none, ref, text, ref + text
label_colorSTRING#ffffff
label_font_sizeINT206–200
font_pathSTRING

Outputs (3)

NameTypeDescription
imageIMAGE
crop_imagesIMAGE
crop_infoSTRING