Skip to content

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

fix: adjust OCR confidence threshold and refine category assignment logic

myhloli962a3453ca10
diff --git a/mineru/backend/pipeline/batch_analyze.py b/mineru/backend/pipeline/batch_analyze.py
index 0acf3b6e..eefdf83c 100644
--- a/mineru/backend/pipeline/batch_analyze.py
+++ b/mineru/backend/pipeline/batch_analyze.py
@@ -318,6 +318,13 @@ class BatchAnalyze:
layout_res_item['score'] = float(f"{ocr_score:.3f}")
if ocr_score < OcrConfidence.min_confidence:
layout_res_item['category_id'] = 16
+ else:
+ layout_res_bbox = [layout_res_item['poly'][0], layout_res_item['poly'][1],
+ layout_res_item['poly'][4], layout_res_item['poly'][5]]
+ layout_res_width = layout_res_bbox[2] - layout_res_bbox[0]
+ layout_res_height = layout_res_bbox[3] - layout_res_bbox[1]
+ if ocr_text in ['(204号', '(20', '(2', '(2号'] and ocr_score < 0.8 and layout_res_width < layout_res_height:
+ layout_res_item['category_id'] = 16
total_processed += len(img_crop_list)
diff --git a/mineru/utils/ocr_utils.py b/mineru/utils/ocr_utils.py
index cfeed33b..6da9db00 100644
--- a/mineru/utils/ocr_utils.py
+++ b/mineru/utils/ocr_utils.py
@@ -5,7 +5,7 @@ import numpy as np
class OcrConfidence:
- min_confidence = 0.68
+ min_confidence = 0.6
min_width = 3