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

Bug of demo.py #100

Open
leftthomas opened this issue Dec 4, 2022 · 3 comments
Open

Bug of demo.py #100

leftthomas opened this issue Dec 4, 2022 · 3 comments

Comments

@leftthomas
Copy link

According to your code, the input image is in RGB format:


and the given mean and std is also in RGB format:
PIXEL_MEAN: [123.675, 116.280, 103.530]
PIXEL_STD: [58.395, 57.120, 57.375]

In demo.py, the image is read as RGB format:
img = read_image(path, format="RGB")

and then passed to DefaultPredictor:
self.predictor = DefaultPredictor(cfg)
def run_on_image(self, image, confidence_threshold):
"""
Args:
image (np.ndarray): an image of shape (H, W, C) (in BGR order).
This is the format used by OpenCV.
Returns:
predictions (dict): the output of the model.
vis_output (VisImage): the visualized image output.
"""
vis_output = None
predictions = self.predictor(image)

In DefaultPredictor, the image is firstly converted into BGR format:
https://github.com/facebookresearch/detectron2/blob/96c752ce821a3340e27edd51c28a00665dd32a30/detectron2/engine/defaults.py#L309
and finally be normalized according to the given mean and std:
image = (image - self.pixel_mean) / self.pixel_std

As the given mean and std is in RGB format and the image is in BGR format, so there remains a mismatch.

@wondervictor
Copy link
Member

Hi @leftthomas, I'm so sorry for the late reply.
Thank you for reminding me of this problem and I'll check and fix it soon~

@leftthomas leftthomas reopened this Jan 3, 2023
@leftthomas
Copy link
Author

@wondervictor it still haven't been fixed now.

@nai-kon
Copy link

nai-kon commented Jan 23, 2024

@wondervictor
Thank you for the wonderful project. I also encountered the same problem, when will it be fixed?

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

3 participants