Sfoglia il codice sorgente

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

myhloli 3 mesi fa
parent
commit
433b37589c

+ 1 - 1
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)

+ 4 - 4
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)