PaddlePaddle/PaddleOCR · error · ValueError
box_type can only be one of ['quad', 'poly']
Error message
box_type can only be one of ['quad', 'poly']
What it means
ValueError from DBPostProcess.__call__ during inference/postprocess when self.box_type is neither 'quad' nor 'poly'. The constructor did not validate box_type, so an invalid value survives until the first image is decoded and each result row is converted, then the else-branch raises.
Source
Thrown at ppocr/postprocess/db_postprocess.py:253
for batch_index in range(pred.shape[0]):
src_h, src_w, ratio_h, ratio_w = shape_list[batch_index]
if self.dilation_kernel is not None:
mask = cv2.dilate(
np.array(segmentation[batch_index]).astype(np.uint8),
self.dilation_kernel,
)
else:
mask = segmentation[batch_index]
if self.box_type == "poly":
boxes, scores = self.polygons_from_bitmap(
pred[batch_index], mask, src_w, src_h
)
elif self.box_type == "quad":
boxes, scores = self.boxes_from_bitmap(
pred[batch_index], mask, src_w, src_h
)
else:
raise ValueError("box_type can only be one of ['quad', 'poly']")
boxes_batch.append({"points": boxes})
return boxes_batch
class DistillationDBPostProcess(object):
def __init__(
self,
model_name=["student"],
key=None,
thresh=0.3,
box_thresh=0.6,
max_candidates=1000,
unclip_ratio=1.5,
use_dilation=False,
score_mode="fast",
box_type="quad",
**kwargs,View on GitHub (pinned to 2661c7c0ef)
Solutions
- Set PostProcess.box_type to 'quad' or 'poly' in the detection config.
- If you need quadrilateral output for legacy label format, use 'quad'; for full polygon/NMS-free output use 'poly'.
- Validate the config before launching a long evaluation run, since the error only surfaces at the first postprocessed batch.
Example fix
# before PostProcess: name: DBPostProcess box_type: polygon # after PostProcess: name: DBPostProcess box_type: poly
Defensive patterns
Strategy: validation
Validate before calling
BOX_TYPES = {"quad", "poly"}
box_type = cfg['PostProcess']['box_type'] if 'PostProcess' in cfg else 'quad'
assert box_type in BOX_TYPES, f"PostProcess.box_type must be one of {BOX_TYPES}, got {box_type!r}" Type guard
def is_valid_box_type(v) -> bool:
return v in ("quad", "poly") Prevention
- Validate the postprocess block of detection configs before launching long runs — the error only appears at the first batch.
- Use 'poly', not 'polygon', when you want polygon output.
When it happens
Trigger: Running DB/DB++ text detection inference or evaluation with PostProcess.box_type set to anything other than 'quad' or 'poly' in the detection config (e.g. 'polygon', 'box', 'rect').
Common situations: Hand-edited det configs (det_mv3_db.yml etc.) where users write the long form 'polygon' instead of 'poly'; configs copied from other repos (e.g. MMOCR vocabulary) with different box-type names.
Related errors
- not support limit type, image
- Detection model session is not initialized.
- Unexpected det output dims: [${dims.join(", ")}]
- Unexpected det output dims: [${od.join(", ")}]
- Detection batch output N=${String(nOut)} does not match inpu
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/acf2eb7e1dd73e3e.
Report an issue: GitHub.