so ugly code
hopef opened this issue · 0 comments
hopef commented
The image got with self.to_rgb = True is actually ugly BGR format!!!
It attempts to perform a BGR2RGB conversion on an RGB image!!!
# img is PIL.Image, the default mode is RGB
# This will make an ugly image if self.to_rgb = True.
img = mmcv.imnormalize(np.array(img), self.img_mean,
self.img_std, self.to_rgb)
def imnormalize(img, mean, std, to_rgb=True):
assert img.dtype != np.uint8
mean = np.float64(mean.reshape(1, -1))
stdinv = 1 / np.float64(std.reshape(1, -1))
if to_rgb:
cv2.cvtColor(img, cv2.COLOR_BGR2RGB, img) # inplace
cv2.subtract(img, mean, img) # inplace
cv2.multiply(img, stdinv, img) # inplace
return img