Skip to content

Commit

Permalink
trying PR MhLiao#263 from branch jiangxiluning:master
Browse files Browse the repository at this point in the history
  • Loading branch information
priyank9320 committed Jun 13, 2021
1 parent 4f1672d commit 600938e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions data/processes/augment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,20 @@ 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]
line_polys.append({
Expand All @@ -79,4 +86,3 @@ def may_augment_annotation(self, aug: imgaug.augmenters.Augmenter, data, shape):
})

data['polys'] = line_polys

0 comments on commit 600938e

Please sign in to comment.