From e319f376492dd77670427b1bd23a75b669b36b7a Mon Sep 17 00:00:00 2001 From: Moein Date: Tue, 30 Jul 2019 10:56:55 +0430 Subject: [PATCH 1/5] Update data_aug.py --- data_aug/data_aug.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data_aug/data_aug.py b/data_aug/data_aug.py index 94892b0..74b78e7 100644 --- a/data_aug/data_aug.py +++ b/data_aug/data_aug.py @@ -40,7 +40,10 @@ def __call__(self, img, bboxes): img_center = np.hstack((img_center, img_center)) if random.random() < self.p: img = img[:, ::-1, :] - bboxes[:, [0, 2]] += 2*(img_center[[0, 2]] - bboxes[:, [0, 2]]) + # this line chenged from bboxes[:, [0, 2]]+=2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') + # to the following: + + bboxes[:, [0, 2]] =np.add(bboxes[:, [0, 2]],2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') box_w = abs(bboxes[:, 0] - bboxes[:, 2]) From bd799c7e06121f8abd3daac5b14a9161d9104168 Mon Sep 17 00:00:00 2001 From: Moein Date: Tue, 30 Jul 2019 10:58:31 +0430 Subject: [PATCH 2/5] same_kind restriction removed --- data_aug/data_aug.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_aug/data_aug.py b/data_aug/data_aug.py index 74b78e7..96128f2 100644 --- a/data_aug/data_aug.py +++ b/data_aug/data_aug.py @@ -41,7 +41,7 @@ def __call__(self, img, bboxes): if random.random() < self.p: img = img[:, ::-1, :] # this line chenged from bboxes[:, [0, 2]]+=2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') - # to the following: + # to the following line: bboxes[:, [0, 2]] =np.add(bboxes[:, [0, 2]],2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') From 80eeff78cbf4c073fdbc806b237c001c049ed32a Mon Sep 17 00:00:00 2001 From: Moein Date: Tue, 30 Jul 2019 16:35:58 +0430 Subject: [PATCH 3/5] Update data_aug.py --- data_aug/data_aug.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_aug/data_aug.py b/data_aug/data_aug.py index 96128f2..32ab591 100644 --- a/data_aug/data_aug.py +++ b/data_aug/data_aug.py @@ -40,7 +40,7 @@ def __call__(self, img, bboxes): img_center = np.hstack((img_center, img_center)) if random.random() < self.p: img = img[:, ::-1, :] - # this line chenged from bboxes[:, [0, 2]]+=2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') + # this line chenged from bboxes[:, [0, 2]]+=2*(img_center[[0, 2]] - bboxes[:, [0, 2]]) # to the following line: bboxes[:, [0, 2]] =np.add(bboxes[:, [0, 2]],2*(img_center[[0, 2]] - bboxes[:, [0, 2]]),casting='unsafe') From f6ea1596c3a68f32896290eb3bc153217e98c1c7 Mon Sep 17 00:00:00 2001 From: Moein Date: Tue, 30 Jul 2019 16:51:39 +0430 Subject: [PATCH 4/5] same_kind restriction line new_bbox[:,:4] /= [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y] changed to the np.divide format with unsafe casting due to : ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind'' --- data_aug/data_aug.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data_aug/data_aug.py b/data_aug/data_aug.py index 32ab591..5533b7e 100644 --- a/data_aug/data_aug.py +++ b/data_aug/data_aug.py @@ -469,7 +469,10 @@ def __call__(self, img, bboxes): img = cv2.resize(img, (w,h)) - new_bbox[:,:4] /= [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y] + # line new_bbox[:,:4] /= [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y] changed to the following: + new_bbox[:,:4]=np.divide(new_bbox[:,:4], + [scale_factor_x, scale_factor_y, scale_factor_x, scale_factor_y] ,casting='unsafe') + bboxes = new_bbox From 6ec4b25678e6da1a60e93f609c4e3f84a2e1a340 Mon Sep 17 00:00:00 2001 From: Moein Date: Tue, 30 Jul 2019 17:02:27 +0430 Subject: [PATCH 5/5] np.multiply replaced *= --- data_aug/data_aug.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data_aug/data_aug.py b/data_aug/data_aug.py index 5533b7e..b759758 100644 --- a/data_aug/data_aug.py +++ b/data_aug/data_aug.py @@ -712,7 +712,9 @@ def __call__(self, img, bboxes): scale = min(self.inp_dim/h, self.inp_dim/w) - bboxes[:,:4] *= (scale) + + # line changed from bboxes[:,:4]*=(scale) + bboxes[:,:4]=np.multiply(bboxes[:,:4] , (scale)) new_w = scale*w new_h = scale*h