Skip to content

mss grab color conversion problem using TorchHub #1735

Description

@gpierard

🐛 Bug

Images grabbed with mss need to be converted to RGB before being fed as input to torch's models

However the proposed solution to do this conversion to RGB does not work img2 = cv2.imread('bus.jpg')[:, :, ::-1]

Instead, this has to be used:

result = model(cv2.cvtColor(scr, cv2.COLOR_BGR2RGB), size=400)

To Reproduce (REQUIRED)

Input:

See full code and resolution on SO

Output:
result.show() outputting a non-normal color channel image, with dramatically reduced model accuracy of course (since it was trained on normal color channels).

Expected behavior

Converting the image to RGB using result = model(cv2.cvtColor(scr, cv2.COLOR_BGR2RGB), size=400) fixed the problem.

  • TorchHub shows a normal image with result.show()
  • Accuracy of the model back to normal

Environment

If applicable, add screenshots to help explain your problem.

  • OS: [Windows 10]
  • GPU [e.g. RTX 2080 SUPER]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleStale and schedule for closing soonbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions