Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

so ugly code #186

Open
hopef opened this issue Nov 17, 2023 · 0 comments
Open

so ugly code #186

hopef opened this issue Nov 17, 2023 · 0 comments

Comments

@hopef
Copy link

hopef commented Nov 17, 2023

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

img = mmcv.imnormalize(np.array(img), self.img_mean,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant