Skip to content

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

fix: update vertical count condition for text orientation and adjust default batch size for inference

myhloli433b37589cb5
diff --git a/mineru/backend/pipeline/pipeline_analyze.py b/mineru/backend/pipeline/pipeline_analyze.py
index 4ddf408b..9a6c663b 100644
--- a/mineru/backend/pipeline/pipeline_analyze.py
+++ b/mineru/backend/pipeline/pipeline_analyze.py
@@ -78,7 +78,7 @@ def doc_analyze(
适当调大MIN_BATCH_INFERENCE_SIZE可以提高性能,更大的 MIN_BATCH_INFERENCE_SIZE会消耗更多内存,
可通过环境变量MINERU_MIN_BATCH_INFERENCE_SIZE设置,默认值为384。
"""
- min_batch_inference_size = int(os.environ.get('MINERU_MIN_BATCH_INFERENCE_SIZE', 384))
+ min_batch_inference_size = int(os.environ.get('MINERU_MIN_BATCH_INFERENCE_SIZE', 128))
# 收集所有页面信息
all_pages_info = [] # 存储(dataset_index, page_index, img, ocr, lang, width, height)
diff --git a/mineru/model/ori_cls/paddle_ori_cls.py b/mineru/model/ori_cls/paddle_ori_cls.py
index 598fcc1c..49555f99 100644
--- a/mineru/model/ori_cls/paddle_ori_cls.py
+++ b/mineru/model/ori_cls/paddle_ori_cls.py
@@ -90,7 +90,7 @@ class PaddleOrientationClsModel:
# elif aspect_ratio > 1.2: # Wider than tall - horizontal text
# horizontal_count += 1
- if vertical_count >= len(det_res) * 0.3:
+ if vertical_count >= len(det_res) * 0.3 and vertical_count >= 3:
is_rotated = True
# logger.debug(f"Text orientation analysis: vertical={vertical_count}, det_res={len(det_res)}, rotated={is_rotated}")
@@ -104,9 +104,9 @@ class PaddleOrientationClsModel:
if label == "90":
rotation = cv2.ROTATE_90_COUNTERCLOCKWISE
img = cv2.rotate(np.asarray(img), rotation)
- elif label == "180":
- rotation = cv2.ROTATE_180
- img = cv2.rotate(np.asarray(img), rotation)
+ # elif label == "180":
+ # rotation = cv2.ROTATE_180
+ # img = cv2.rotate(np.asarray(img), rotation)
elif label == "270":
rotation = cv2.ROTATE_90_CLOCKWISE
img = cv2.rotate(np.asarray(img), rotation)