Skip to content

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

feat: enhance table classification logic and add OCR detection flag

myhloli865b44a5171c
diff --git a/mineru/backend/pipeline/pipeline_analyze.py b/mineru/backend/pipeline/pipeline_analyze.py
index 1e58b1d8..ea005721 100644
--- a/mineru/backend/pipeline/pipeline_analyze.py
+++ b/mineru/backend/pipeline/pipeline_analyze.py
@@ -190,7 +190,11 @@ def batch_image_analyze(
batch_ratio = 1
logger.info(f'Could not determine GPU memory, using default batch_ratio: {batch_ratio}')
- batch_model = BatchAnalyze(model_manager, batch_ratio, formula_enable, table_enable)
+ if str(device).startswith('mps'):
+ enable_ocr_det_batch = False
+ else:
+ enable_ocr_det_batch = True
+ batch_model = BatchAnalyze(model_manager, batch_ratio, formula_enable, table_enable, enable_ocr_det_batch)
results = batch_model(images_with_extra_info)
clean_memory(get_device())
diff --git a/mineru/model/table/cls/paddle_table_cls.py b/mineru/model/table/cls/paddle_table_cls.py
index f3181d65..4be971b5 100644
--- a/mineru/model/table/cls/paddle_table_cls.py
+++ b/mineru/model/table/cls/paddle_table_cls.py
@@ -3,6 +3,7 @@ import os
import cv2
import numpy as np
import onnxruntime
+from loguru import logger
from mineru.backend.pipeline.model_list import AtomicModel
from mineru.utils.enum_class import ModelPath
@@ -63,6 +64,10 @@ class PaddleTableClsModel:
def predict(self, img):
x = self.preprocess(img)
- (result,) = self.sess.run(None, {"x": x})
- label = self.labels[np.argmax(result)]
- return label
+ result = self.sess.run(None, {"x": x})
+ idx = np.argmax(result)
+ conf = float(np.max(result))
+ # logger.debug(f"Table classification result: {self.labels[idx]} with confidence {conf:.4f}")
+ if idx == 0 and conf < 0.8:
+ idx = 1
+ return self.labels[idx]