Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: replace shape attribute with len for box count and update return type for ragged arrays

myhloli01ab65648774
diff --git a/mineru/model/utils/tools/infer/predict_det.py b/mineru/model/utils/tools/infer/predict_det.py
index 9d339413..c9611fec 100644
--- a/mineru/model/utils/tools/infer/predict_det.py
+++ b/mineru/model/utils/tools/infer/predict_det.py
@@ -303,7 +303,9 @@ class TextDetector(BaseOCRV20):
box = np.array(box)
box = self.clip_det_res(box, img_height, img_width)
dt_boxes_new.append(box)
- return np.array(dt_boxes_new)
+ # Polygon detectors may emit a variable number of points per box,
+ # so this path must preserve a ragged outer container.
+ return dt_boxes_new
def __call__(self, img):
ori_shape = img.shape
diff --git a/mineru/model/utils/tools/infer/predict_system.py b/mineru/model/utils/tools/infer/predict_system.py
index e35b9a4b..9f001038 100644
--- a/mineru/model/utils/tools/infer/predict_system.py
+++ b/mineru/model/utils/tools/infer/predict_system.py
@@ -91,7 +91,7 @@ def sorted_boxes(dt_boxes):
return:
sorted boxes(array) with shape [4, 2]
"""
- num_boxes = dt_boxes.shape[0]
+ num_boxes = len(dt_boxes)
sorted_boxes = sorted(dt_boxes, key=lambda x: (x[0][1], x[0][0]))
_boxes = list(sorted_boxes)
diff --git a/mineru/utils/ocr_utils.py b/mineru/utils/ocr_utils.py
index 375b59e1..b80081da 100644
--- a/mineru/utils/ocr_utils.py
+++ b/mineru/utils/ocr_utils.py
@@ -106,7 +106,7 @@ def sorted_boxes(dt_boxes):
return:
sorted boxes(array) with shape [4, 2]
"""
- num_boxes = dt_boxes.shape[0]
+ num_boxes = len(dt_boxes)
sorted_boxes = sorted(dt_boxes, key=lambda x: (x[0][1], x[0][0]))
_boxes = list(sorted_boxes)