@@ -44,7 +44,7 @@ def imnormalize_(img, mean, std, to_rgb=True):
44
44
mean = np .float64 (mean .reshape (1 , - 1 ))
45
45
stdinv = 1 / np .float64 (std .reshape (1 , - 1 ))
46
46
if to_rgb :
47
- cv2 .cvtColor (img , cv2 .COLOR_BGR2RGB , img ) # inplace
47
+ img = img [..., :: - 1 ] # Faster than cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) # inplace
48
48
cv2 .subtract (img , mean , img ) # inplace
49
49
cv2 .multiply (img , stdinv , img ) # inplace
50
50
return img
@@ -57,7 +57,7 @@ def imdenormalize(img, mean, std, to_bgr=True):
57
57
img = cv2 .multiply (img , std ) # make a copy
58
58
cv2 .add (img , mean , img ) # inplace
59
59
if to_bgr :
60
- cv2 .cvtColor (img , cv2 .COLOR_RGB2BGR , img ) # inplace
60
+ img = img [..., :: - 1 ] # Faster than cv2.cvtColor(img, cv2.COLOR_RGB2BGR, img) # inplace
61
61
return img
62
62
63
63
@@ -427,7 +427,7 @@ def adjust_lighting(img, eigval, eigvec, alphastd=0.1, to_rgb=True):
427
427
428
428
img = img .copy ().astype (np .float32 )
429
429
if to_rgb :
430
- cv2 .cvtColor (img , cv2 .COLOR_BGR2RGB , img ) # inplace
430
+ img = img [..., :: - 1 ] # Faster than cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) # inplace
431
431
432
432
alpha = np .random .normal (0 , alphastd , n_eigval )
433
433
alter = eigvec \
0 commit comments