Просмотр исходного кода

fix: disable progress bar in predictions for cleaner output

myhloli 2 месяцев назад
Родитель
Сommit
90047f9bd5

+ 2 - 2
mineru/model/ori_cls/paddle_ori_cls.py

@@ -195,7 +195,7 @@ class PaddleOrientationClsModel:
 
         # 对每个分辨率组进行批处理
         rotated_imgs = []
-        for group_key, group_imgs in tqdm(resolution_groups.items(), desc="Table-ori cls stage1 predict"):
+        for group_key, group_imgs in tqdm(resolution_groups.items(), desc="Table-ori cls stage1 predict", disable=True):
             # 计算目标尺寸(组内最大尺寸,向上取整到RESOLUTION_GROUP_STRIDE的倍数)
             max_h = max(img["table_img_bgr"].shape[0] for img in group_imgs)
             max_w = max(img["table_img_bgr"].shape[1] for img in group_imgs)
@@ -243,7 +243,7 @@ class PaddleOrientationClsModel:
         # 对旋转的图片进行旋转角度预测
         if len(rotated_imgs) > 0:
             imgs = self.list_2_batch(rotated_imgs, batch_size=batch_size)
-            with tqdm(total=len(rotated_imgs), desc="Table-ori cls stage2 predict") as pbar:
+            with tqdm(total=len(rotated_imgs), desc="Table-ori cls stage2 predict", disable=True) as pbar:
                 for img_batch in imgs:
                     x = self.batch_preprocess(img_batch)
                     results = self.sess.run(None, {"x": x})

+ 1 - 1
mineru/model/table/cls/paddle_table_cls.py

@@ -138,7 +138,7 @@ class PaddleTableClsModel:
         imgs = [item["table_img"] for item in img_info_list]
         imgs = self.list_2_batch(imgs, batch_size=batch_size)
         label_res = []
-        with tqdm(total=len(img_info_list), desc="Table-wired/wireless cls predict") as pbar:
+        with tqdm(total=len(img_info_list), desc="Table-wired/wireless cls predict", disable=True) as pbar:
             for img_batch in imgs:
                 x = self.batch_preprocess(img_batch)
                 result = self.sess.run(None, {"x": x})

+ 1 - 1
mineru/model/table/rec/unet_table/main.py

@@ -64,7 +64,7 @@ class WiredTableRecognition:
         img = self.load_img(img)
         polygons, rotated_polygons = self.table_structure(img, **kwargs)
         if polygons is None:
-            logging.warning("polygons is None.")
+            # logging.warning("polygons is None.")
             return WiredTableOutput("", None, None, 0.0)
 
         try:

+ 1 - 1
mineru/model/table/rec/unet_table/utils_table_line_rec.py

@@ -152,7 +152,7 @@ def calculate_center_rotate_angle(box):
     ) / 2
     # x = cx-w/2
     # y = cy-h/2
-    sinA = (h * (x1 - cx) - w * (y1 - cy)) * 1.0 / (h * h + w * w) * 2
+    sinA = (h * (x1 - cx) - w * (y1 - cy)) * 1.0 / (h * h + w * w + 1e-10) * 2
     angle = np.arcsin(sinA)
     return angle, w, h, cx, cy