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

Did anyone got onnx yolov7 working with opencv? #486

Open
holger-prause opened this issue Aug 11, 2022 · 3 comments
Open

Did anyone got onnx yolov7 working with opencv? #486

holger-prause opened this issue Aug 11, 2022 · 3 comments

Comments

@holger-prause
Copy link

holger-prause commented Aug 11, 2022

Hello, i am wondering if anyone of you could succesfully read in yolov7 model with the opencv dnn module and got predictions with it?

The problems i am facing:

  • opencv complains about missing layers after exporting to onxxx with --grid and --end2end
  • when exporting without those flags i got an array back with 3 entries with the following shapes:
    <class 'tuple'>: (1, 3, 40, 40, 85)
    <class 'tuple'>: (1, 3, 20, 20, 85)
    <class 'tuple'>: (1, 3, 80, 80, 85)

I honestly dont know what to do with this result, 80 seems to correspond to the amount of classes, but in which array are the confidences / bounding boxes? 85- 80 is 5 - maybe the first 80 entries are the confidences for each class while the last 5 entries are classId, x, y, w, h?

Looking at the numbers in the array i am a bit skeptical, some are negative - shouldnt be a confidence be between 0 and 1?
Any further insight or even an opencv example using opencvs net.forward would be highly welcome.

@microboym
Copy link

#49 (comment)

seems that someone has already come up with a solution.

@holger-prause
Copy link
Author

holger-prause commented Aug 15, 2022

Thank you very much - i came across this posting - but i disregarded it as i have to switch to a special branch for this and i wanted to stick to the latest master version. Still i could port this solution to master or just use the solution supplied here - https://colab.research.google.com/github/WongKinYiu/yolov7/blob/main/tools/YOLOv7onnx.ipynb#scrollTo=07vh3pUa1ccC which just uses the onnx runtime to do the predictions (no opencv dnn module)

I am still a bit unhappy and unsure which way to got - ideally usinng opencvs dnn module on master branch - but i am a bit lost there.

@microboym
Copy link

AlexeyAB/darknet#8595 (comment)

It seems possible to convert yolov7 model into darknet format(.cfg and .weights), and maybe you can simply load the darknet model with opencv using cv2.dnn.readNetFromDarknet("yolov7.cfg", "yolov7.weights").

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

2 participants