From 417cb8432436fe4faac7c449536c738d3a6adaf4 Mon Sep 17 00:00:00 2001 From: luning Date: Wed, 2 Jun 2021 09:39:36 +0800 Subject: [PATCH 1/2] fix eval bugs --- data/processes/augment_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/processes/augment_data.py b/data/processes/augment_data.py index b06f575..177c3da 100644 --- a/data/processes/augment_data.py +++ b/data/processes/augment_data.py @@ -69,7 +69,8 @@ def may_augment_annotation(self, aug: imgaug.augmenters.Augmenter, data, shape): keypoints.append(imgaug.Keypoint(p[0], p[1])) keypoints = aug.augment_keypoints([imgaug.KeypointsOnImage(keypoints=keypoints, shape=shape)])[0].keypoints - new_polys = np.array([p.x, p.y] for p in keypoints).reshape([-1, 4, 2]) + new_polys = np.array([[p.x, p.y] for p in keypoints]).reshape((-1, 4, 2)) + for i in range(len(texts)): poly = new_polys[i] line_polys.append({ From 49c6f3bcd922f0df54ad959acf07f17dd7bca756 Mon Sep 17 00:00:00 2001 From: luning Date: Wed, 2 Jun 2021 11:10:29 +0800 Subject: [PATCH 2/2] fix eval bugs --- data/processes/augment_data.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/data/processes/augment_data.py b/data/processes/augment_data.py index 177c3da..835cc8a 100644 --- a/data/processes/augment_data.py +++ b/data/processes/augment_data.py @@ -63,13 +63,19 @@ def may_augment_annotation(self, aug: imgaug.augmenters.Augmenter, data, shape): line_polys = [] keypoints = [] texts = [] + new_polys = [] + for line in data['lines']: texts.append(line['text']) + new_poly = [] for p in line['poly']: + new_poly.append((p[0], p[1])) keypoints.append(imgaug.Keypoint(p[0], p[1])) + new_polys.append(new_poly) - keypoints = aug.augment_keypoints([imgaug.KeypointsOnImage(keypoints=keypoints, shape=shape)])[0].keypoints - new_polys = np.array([[p.x, p.y] for p in keypoints]).reshape((-1, 4, 2)) + if not self.only_resize: + keypoints = aug.augment_keypoints([imgaug.KeypointsOnImage(keypoints=keypoints, shape=shape)])[0].keypoints + new_polys = np.array([[p.x, p.y] for p in keypoints]).reshape((-1, 4, 2)) for i in range(len(texts)): poly = new_polys[i]