From 4642f6b5bd48be4c7cd0a7846aa86ac8b68fa9a0 Mon Sep 17 00:00:00 2001 From: vesor Date: Sat, 27 Jan 2018 11:18:32 +0800 Subject: [PATCH 1/3] use opencv instead of numpy to subtract pixel means --- lib/utils/blob.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils/blob.py b/lib/utils/blob.py index fce46aae4..4599b1d78 100644 --- a/lib/utils/blob.py +++ b/lib/utils/blob.py @@ -76,7 +76,8 @@ def prep_im_for_blob(im, pixel_means, target_sizes, max_size): the scale factors that were used to compute each returned image. """ im = im.astype(np.float32, copy=False) - im -= pixel_means + #im -= pixel_means + im = cv2.subtract(im, pixel_means.reshape((1,) + im.shape[-1:])) im_shape = im.shape im_size_min = np.min(im_shape[0:2]) im_size_max = np.max(im_shape[0:2]) From 066c1d01e7968acb43cebb1f921eb5816c1ee878 Mon Sep 17 00:00:00 2001 From: vesor Date: Sat, 27 Jan 2018 11:18:32 +0800 Subject: [PATCH 2/3] use opencv instead of numpy to subtract pixel means --- lib/utils/blob.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils/blob.py b/lib/utils/blob.py index fce46aae4..4599b1d78 100644 --- a/lib/utils/blob.py +++ b/lib/utils/blob.py @@ -76,7 +76,8 @@ def prep_im_for_blob(im, pixel_means, target_sizes, max_size): the scale factors that were used to compute each returned image. """ im = im.astype(np.float32, copy=False) - im -= pixel_means + #im -= pixel_means + im = cv2.subtract(im, pixel_means.reshape((1,) + im.shape[-1:])) im_shape = im.shape im_size_min = np.min(im_shape[0:2]) im_size_max = np.max(im_shape[0:2]) From 874e885ca7744b6ace0faefee20794de01e57ad2 Mon Sep 17 00:00:00 2001 From: weizhe Date: Wed, 16 May 2018 17:56:14 +0800 Subject: [PATCH 3/3] remove the commented line --- detectron/utils/blob.py | 1 - 1 file changed, 1 deletion(-) diff --git a/detectron/utils/blob.py b/detectron/utils/blob.py index 073efd7bd..59cecc519 100644 --- a/detectron/utils/blob.py +++ b/detectron/utils/blob.py @@ -106,7 +106,6 @@ def prep_im_for_blob(im, pixel_means, target_size, max_size): the scale factors that were used to compute each returned image. """ im = im.astype(np.float32, copy=False) - #im -= pixel_means im = cv2.subtract(im, pixel_means.reshape((1,) + im.shape[-1:])) im_shape = im.shape im_size_min = np.min(im_shape[0:2])