ソースを参照

fix: update batch analysis to use PIL images for layout prediction and adjust rotation condition

myhloli 2 ヶ月 前
コミット
396cf8b81d
2 ファイル変更5 行追加2 行削除
  1. 3 1
      mineru/backend/pipeline/batch_analyze.py
  2. 2 1
      mineru/utils/ocr_utils.py

+ 3 - 1
mineru/backend/pipeline/batch_analyze.py

@@ -42,12 +42,14 @@ class BatchAnalyze:
         )
         atom_model_manager = AtomModelSingleton()
 
+        pil_images = [image for image, _, _ in images_with_extra_info]
+
         np_images = [np.asarray(image) for image, _, _ in images_with_extra_info]
 
         # doclayout_yolo
 
         images_layout_res += self.model.layout_model.batch_predict(
-            np_images, YOLO_LAYOUT_BASE_BATCH_SIZE
+            pil_images, YOLO_LAYOUT_BASE_BATCH_SIZE
         )
 
         if self.formula_enable:

+ 2 - 1
mineru/utils/ocr_utils.py

@@ -437,6 +437,7 @@ def get_rotate_crop_image(img, points):
         borderMode=cv2.BORDER_REPLICATE,
         flags=cv2.INTER_CUBIC)
     dst_img_height, dst_img_width = dst_img.shape[0:2]
-    if dst_img_height * 1.0 / dst_img_width >= 1.5:
+    rotate_radio = 2
+    if dst_img_height * 1.0 / dst_img_width >= rotate_radio:
         dst_img = np.rot90(dst_img)
     return dst_img