BEVDepth icon indicating copy to clipboard operation
BEVDepth copied to clipboard

so ugly code

Open hopef opened this issue 1 year ago • 0 comments

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

https://github.com/Megvii-BaseDetection/BEVDepth/blob/d78c7b58b10b9ada940462ba83ab24d99cae5833/bevdepth/datasets/nusc_det_dataset.py#L498

hopef avatar Nov 17 '23 03:11 hopef