Megvii-BaseDetection / BEVDepth

Official code for BEVDepth.
MIT License
710 stars 98 forks source link

so ugly code #186

Open hopef opened 10 months ago

hopef commented 10 months ago

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