diff --git a/ppocr/data/imaug/fce_aug.py b/ppocr/data/imaug/fce_aug.py index 7ef00de33b..66bafef13c 100644 --- a/ppocr/data/imaug/fce_aug.py +++ b/ppocr/data/imaug/fce_aug.py @@ -133,7 +133,7 @@ class RandomCropFlip: fail_flag = False for polygon, ignore_tag in zip(polygons, ignore_tags): ppi = Polygon(polygon.reshape(-1, 2)) - ppiou, _ = poly_intersection(ppi, pp) + ppiou, _ = poly_intersection(ppi, pp, buffer=0) if np.abs(ppiou - float(ppi.area)) > self.epsilon and \ np.abs(ppiou) > self.epsilon: fail_flag = True diff --git a/ppocr/utils/poly_nms.py b/ppocr/utils/poly_nms.py index 31eb6642ac..9dcb3d2c2f 100644 --- a/ppocr/utils/poly_nms.py +++ b/ppocr/utils/poly_nms.py @@ -36,7 +36,7 @@ def points2polygon(points): return Polygon(point_mat) -def poly_intersection(poly_det, poly_gt): +def poly_intersection(poly_det, poly_gt, buffer=0.0001): """Calculate the intersection area between two polygon. Args: @@ -49,7 +49,10 @@ def poly_intersection(poly_det, poly_gt): assert isinstance(poly_det, Polygon) assert isinstance(poly_gt, Polygon) - poly_inter = poly_det.buffer(0.001) & poly_gt.buffer(0.001) + if buffer == 0: + poly_inter = poly_det & poly_gt + else: + poly_inter = poly_det.buffer(buffer) & poly_gt.buffer(buffer) return poly_inter.area, poly_inter