From 3c95acc3eb4f0aa64c820ea19d533d12d56f3e93 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Wed, 4 Nov 2020 20:48:22 +0800 Subject: [PATCH] Remove cv2 dependence of normalize (#28361) * rm cv2 dependence of normalize --- python/paddle/vision/transforms/functional_cv2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/paddle/vision/transforms/functional_cv2.py b/python/paddle/vision/transforms/functional_cv2.py index 5c2e8d61bc5..4cc04c39d0b 100644 --- a/python/paddle/vision/transforms/functional_cv2.py +++ b/python/paddle/vision/transforms/functional_cv2.py @@ -495,9 +495,8 @@ def normalize(img, mean, std, data_format='CHW', to_rgb=False): mean = np.float32(np.array(mean).reshape(1, 1, -1)) std = np.float32(np.array(std).reshape(1, 1, -1)) if to_rgb: - cv2 = try_import('cv2') # inplace - cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) + img = img[..., ::-1] img = (img - mean) / std return img -- GitLab