{"record":{"id":"fcf392dae207d6b3","repo":"opendatalab/MinerU","slug":"shape-of-table-bounding-boxes-is-not-between-in-4","errorCode":null,"errorMessage":"Shape of table bounding boxes is not between in 4 or 8.","messagePattern":"Shape of table bounding boxes is not between in 4 or 8\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/table/rec/unet_table/utils.py","lineNumber":381,"sourceCode":"    ):\n        if save_html_path:\n            html_with_border = self.insert_border_style(table_results.pred_html)\n            self.save_html(save_html_path, html_with_border)\n\n        table_cell_bboxes = table_results.cell_bboxes\n        table_logic_points = table_results.logic_points\n        if table_cell_bboxes is None:\n            return None\n\n        img = self.load_img(img_path)\n\n        dims_bboxes = table_cell_bboxes.shape[1]\n        if dims_bboxes == 4:\n            drawed_img = self.draw_rectangle(img, table_cell_bboxes)\n        elif dims_bboxes == 8:\n            drawed_img = self.draw_polylines(img, table_cell_bboxes)\n        else:\n            raise ValueError(\"Shape of table bounding boxes is not between in 4 or 8.\")\n\n        if save_drawed_path:\n            self.save_img(save_drawed_path, drawed_img)\n\n        if save_logic_path:\n            polygons = [[box[0], box[1], box[4], box[5]] for box in table_cell_bboxes]\n            self.plot_rec_box_with_logic_info(\n                img, save_logic_path, table_logic_points, polygons\n            )\n        return drawed_img\n\n    def insert_border_style(self, table_html_str: str):\n        style_res = \"\"\"<meta charset=\"UTF-8\"><style>\n        table {\n            border-collapse: collapse;\n            width: 100%;\n        }\n        th, td {","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/table/rec/unet_table/utils.py#L363-L399","documentation":"Raised by the UNet table recognizer's visualization routine when table_cell_bboxes has a second dimension that is neither 4 (axis-aligned boxes: x1,y1,x2,y2) nor 8 (quad polygons: 4 xy points). The drawing code dispatches on bboxes.shape[1] and can only draw rectangles (4) or polylines (8).","triggerScenarios":"Calling the draw/save-visualization API of the table model with predicted cell boxes shaped (N, 5) (e.g. boxes with confidence appended), (N, 6), or feeding raw model output without post-processing to box format; also (0,) shaped arrays from an empty prediction reshaped incorrectly.","commonSituations":"Custom post-processing that appends a score column to each bbox; passing logic_points (4-point logical indices) where pixel bboxes were expected; passing a transposed or flattened array.","solutions":["Ensure the array passed for cell bbox drawing is np.ndarray with shape (N, 4) or (N, 8).","If your detector emits (N, 5) with scores, slice them off: bboxes = arr[:, :4].","Check upstream post-processing (e.g. output bbox decoder) hasn't been replaced or reordered."],"exampleFix":"# before\ndrawed = table_rec.visualize(img_path, raw_pred[:, :5])  # score column kept\n\n# after\nbboxes = raw_pred[:, :4] if raw_pred.shape[1] > 4 else raw_pred\ndrawed = table_rec.visualize(img_path, bboxes)","handlingStrategy":"validation","validationCode":"import numpy as np\nbboxes = np.asarray(table_cell_bboxes)\nif bboxes.ndim != 2 or bboxes.shape[1] not in (4, 8):\n    raise ValueError(f\"expected (N,4) or (N,8) bboxes, got {bboxes.shape}\")","typeGuard":"def is_valid_bboxes(arr) -> bool:\n    arr = np.asarray(arr)\n    return arr.ndim == 2 and arr.shape[1] in (4, 8)","tryCatchPattern":null,"preventionTips":["Slice score columns off detector outputs before visualization","Keep post-processing output contract documented as (N,4)/(N,8)","Add shape asserts in unit tests of post-processing"],"tags":["table-recognition","visualization","shape-validation","valueerror"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}