From d576a61a63dc10e31cbc55c28641584a70ca7f2b Mon Sep 17 00:00:00 2001 From: wangxinxin08 Date: Wed, 23 Sep 2020 13:10:49 +0800 Subject: [PATCH] modify @ to be compatible to python2 --- ppdet/data/transform/op_helper.py | 2 +- ppdet/data/transform/operators.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ppdet/data/transform/op_helper.py b/ppdet/data/transform/op_helper.py index 6919ece50..b692d294b 100644 --- a/ppdet/data/transform/op_helper.py +++ b/ppdet/data/transform/op_helper.py @@ -482,7 +482,7 @@ def transform_bbox(bbox, n = len(bbox) xy = np.ones((n * 4, 3), dtype=np.float32) xy[:, :2] = bbox[:, [0, 1, 2, 3, 0, 3, 2, 1]].reshape(n * 4, 2) - xy = xy @ M.T + xy = np.matmul(xy, M.T) if perspective: xy = (xy[:, :2] / xy[:, 2:3]).reshape(n, 8) else: diff --git a/ppdet/data/transform/operators.py b/ppdet/data/transform/operators.py index dcb0aac41..b4c7694fa 100644 --- a/ppdet/data/transform/operators.py +++ b/ppdet/data/transform/operators.py @@ -2919,7 +2919,10 @@ class RandomPerspective(BaseOperator): T[1, 2] = random.uniform(0.5 - self.translate, 0.5 + self.translate) * height # matmul - M = T @ S @ R @ P @ C + # M = T @ S @ R @ P @ C + M = np.eye(3) + for cM in [T, S, R, P, C]: + M = np.matmul(M, cM) if (self.border[0] != 0) or (self.border[1] != 0) or (M != np.eye(3)).any(): if self.perspective: im = cv2.warpPerspective(im, M, dsize=(width, height), borderValue=self.border_value) -- GitLab