{"record":{"id":"acf2eb7e1dd73e3e","repo":"PaddlePaddle/PaddleOCR","slug":"box-type-can-only-be-one-of-quad-poly","errorCode":null,"errorMessage":"box_type can only be one of ['quad', 'poly']","messagePattern":"box_type can only be one of \\['quad', 'poly'\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ppocr/postprocess/db_postprocess.py","lineNumber":253,"sourceCode":"        for batch_index in range(pred.shape[0]):\n            src_h, src_w, ratio_h, ratio_w = shape_list[batch_index]\n            if self.dilation_kernel is not None:\n                mask = cv2.dilate(\n                    np.array(segmentation[batch_index]).astype(np.uint8),\n                    self.dilation_kernel,\n                )\n            else:\n                mask = segmentation[batch_index]\n            if self.box_type == \"poly\":\n                boxes, scores = self.polygons_from_bitmap(\n                    pred[batch_index], mask, src_w, src_h\n                )\n            elif self.box_type == \"quad\":\n                boxes, scores = self.boxes_from_bitmap(\n                    pred[batch_index], mask, src_w, src_h\n                )\n            else:\n                raise ValueError(\"box_type can only be one of ['quad', 'poly']\")\n\n            boxes_batch.append({\"points\": boxes})\n        return boxes_batch\n\n\nclass DistillationDBPostProcess(object):\n    def __init__(\n        self,\n        model_name=[\"student\"],\n        key=None,\n        thresh=0.3,\n        box_thresh=0.6,\n        max_candidates=1000,\n        unclip_ratio=1.5,\n        use_dilation=False,\n        score_mode=\"fast\",\n        box_type=\"quad\",\n        **kwargs,","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/postprocess/db_postprocess.py#L235-L271","documentation":"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.","triggerScenarios":"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').","commonSituations":"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.","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."],"exampleFix":"# before\nPostProcess:\n  name: DBPostProcess\n  box_type: polygon\n\n# after\nPostProcess:\n  name: DBPostProcess\n  box_type: poly","handlingStrategy":"validation","validationCode":"BOX_TYPES = {\"quad\", \"poly\"}\nbox_type = cfg['PostProcess']['box_type'] if 'PostProcess' in cfg else 'quad'\nassert box_type in BOX_TYPES, f\"PostProcess.box_type must be one of {BOX_TYPES}, got {box_type!r}\"","typeGuard":"def is_valid_box_type(v) -> bool:\n    return v in (\"quad\", \"poly\")","tryCatchPattern":null,"preventionTips":["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."],"tags":["postprocess","detection","config","inference"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}