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

In yolov3.onnx converted from yolov3.pt, in layer ID 371, 391, output, which are boxes and which are classes? #2131

Closed
leeyunhome opened this issue Feb 4, 2021 · 4 comments
Labels
question Further information is requested Stale Stale and schedule for closing soon

Comments

@leeyunhome
Copy link

❔Question

Hello,
Thank you for sharing a great project.

The following figure shows the downloaded yolov3.pt converted to onnx using export.py and then confirmed in graph form with netron.
image

python models/export.py --weights ./weights/yolov3.pt --img 640 --batch 1

torch.onnx.export(model, img, f, verbose=False, opset_version=12, input_names=['images'],
output_names=['classes', 'boxes'] if y is None else ['output'])
The above function converts the downloaded yolov3.pt in export.py to onnx. Here, when y is none, output_names are classes and boxes. In the converted onnx, classes and boxes cannot be found. There are only names 371 and 391. Which of 371 and 391 are classes and which are boxes? And what is the output?

Thank you.

Additional context

@leeyunhome leeyunhome added the question Further information is requested label Feb 4, 2021
@zhiqwang
Copy link
Contributor

zhiqwang commented Feb 5, 2021

Hi @leeyunhome

All three of them seem to be feature maps. If you want to get the boxes, scores and labels, there is one procedure left to deal with, namely post-processing, which containing the nms. And now there are different ways to process this. (You could just search it on GitHub, especially in the issues of YOLOv5.)

One option is here in my own repo, maybe you could check it.

@leeyunhome
Copy link
Author

Hi @leeyunhome

All three of them seem to be feature maps. If you want to get the boxes, scores and labels, there is one procedure left to deal with, namely post-processing, which containing the nms. And now there are different ways to process this. (You could just search it on GitHub, especially in the issues of YOLOv5.)

One option is here in my own repo, maybe you could check it.

Hello?

Thank you so much for the answer.

With the help of @glenn-jocher:

ultralytics/yolov3#1679 (comment)

I modified the line and converted it back to onnx.
Here is the result:

ultralytics/yolov3#1679 (comment)

But I don't see the box and class explicitly, how can I check it?

In the next post of another person, the layer ID in numbers appears at first,
After that, it changed to class and box.
I don't know how to do this.
ultralytics/yolov3#1109
image
image

Thank you.

@zhiqwang
Copy link
Contributor

zhiqwang commented Feb 6, 2021

Also here, seems that it's a reorganization of the feature maps, and its meaning is also feature maps, there is one procedure left to deal with, namely post-processing, which containing the nms. (if it make senses, 12348 here should be the number of anchors.)

EDIT: The graph you quoted is a little weird, I'm not sure how they reorder the feature maps to this shape.

And the meaning of 107 in here should be 102 + 4 + 1, 4 is the meaning of box, 1 is score.

With my limited knowledge, there are two options to process the post-process procedure.

BTW, if you want to have an impression of the post-process, you can check this object in Python. I've refactored the post-process to make it more visible.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale and schedule for closing soon
Projects
None yet
Development

No branches or pull requests

2 participants