Skip to content

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

feat: update OCR model parameters to improve detection accuracy and performance

myhlolibf655c46671e
diff --git a/mineru/backend/pipeline/batch_analyze.py b/mineru/backend/pipeline/batch_analyze.py
index 67b966a1..82d40a77 100644
--- a/mineru/backend/pipeline/batch_analyze.py
+++ b/mineru/backend/pipeline/batch_analyze.py
@@ -684,7 +684,6 @@ class BatchAnalyze:
# 获取OCR模型
ocr_model = atom_model_manager.get_atom_model(
atom_model_name=AtomicModel.OCR,
- det_db_box_thresh=0.3,
lang=lang
)
@@ -761,8 +760,6 @@ class BatchAnalyze:
# Get OCR results for this language's images
ocr_model = atom_model_manager.get_atom_model(
atom_model_name=AtomicModel.OCR,
- ocr_show_log=False,
- det_db_box_thresh=0.3,
lang=_lang
)
for res in ocr_res_list_dict['ocr_res_list']:
@@ -832,7 +829,6 @@ class BatchAnalyze:
ocr_model = atom_model_manager.get_atom_model(
atom_model_name=AtomicModel.OCR,
- det_db_box_thresh=0.3,
lang=lang
)
ocr_res_list = ocr_model.ocr(img_crop_list, det=False, tqdm_enable=True)[0]
diff --git a/mineru/backend/pipeline/model_init.py b/mineru/backend/pipeline/model_init.py
index a1437a72..9ee37bd7 100644
--- a/mineru/backend/pipeline/model_init.py
+++ b/mineru/backend/pipeline/model_init.py
@@ -90,23 +90,24 @@ def pp_doclayout_v2_model_init(weight, device='cpu'):
model = PPDocLayoutV2LayoutModel(weight, device)
return model
-def ocr_model_init(det_db_box_thresh=0.3,
+def ocr_model_init(det_db_box_thresh=0.5,
lang=None,
- det_db_unclip_ratio=1.8,
+ det_db_unclip_ratio=1.5,
enable_merge_det_boxes=True
):
+ use_dilation = False
if lang is not None and lang != '':
model = PytorchPaddleOCR(
det_db_box_thresh=det_db_box_thresh,
lang=lang,
- use_dilation=True,
+ use_dilation=use_dilation,
det_db_unclip_ratio=det_db_unclip_ratio,
enable_merge_det_boxes=enable_merge_det_boxes,
)
else:
model = PytorchPaddleOCR(
det_db_box_thresh=det_db_box_thresh,
- use_dilation=True,
+ use_dilation=use_dilation,
det_db_unclip_ratio=det_db_unclip_ratio,
enable_merge_det_boxes=enable_merge_det_boxes,
)
@@ -136,9 +137,9 @@ class AtomModelSingleton:
elif atom_model_name in [AtomicModel.OCR]:
key = (
atom_model_name,
- kwargs.get('det_db_box_thresh', 0.3),
+ kwargs.get('det_db_box_thresh', 0.5),
lang,
- kwargs.get('det_db_unclip_ratio', 1.8),
+ kwargs.get('det_db_unclip_ratio', 1.5),
kwargs.get('enable_merge_det_boxes', True)
)
elif atom_model_name in [AtomicModel.Layout, AtomicModel.MFR]:
@@ -168,9 +169,9 @@ def atom_model_init(model_name: str, **kwargs):
)
elif model_name == AtomicModel.OCR:
atom_model = ocr_model_init(
- kwargs.get('det_db_box_thresh', 0.3),
+ kwargs.get('det_db_box_thresh', 0.5),
kwargs.get('lang'),
- kwargs.get('det_db_unclip_ratio', 1.8),
+ kwargs.get('det_db_unclip_ratio', 1.5),
kwargs.get('enable_merge_det_boxes', True)
)
elif model_name == AtomicModel.WirelessTable:
@@ -236,7 +237,6 @@ class MineruPipelineModel:
# 初始化ocr
self.ocr_model = atom_model_manager.get_atom_model(
atom_model_name=AtomicModel.OCR,
- det_db_box_thresh=0.3,
lang=self.lang
)
# init table model
@@ -330,7 +330,6 @@ class MineruHybridModel:
# 初始化OCR模型
self.ocr_model = self.atom_model_manager.get_atom_model(
atom_model_name=AtomicModel.OCR,
- det_db_box_thresh=0.3,
lang=self.lang
)