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

Unexpected output shape of onnx model #37

Closed
Fschoeller opened this issue Jul 2, 2021 · 3 comments
Closed

Unexpected output shape of onnx model #37

Fschoeller opened this issue Jul 2, 2021 · 3 comments

Comments

@Fschoeller
Copy link

Hi! i'm on the paper branch and have exported a yolor-p6 model to onnx using models/export.py.
The onnx model has the output shape output: batch, 3, 96, 160, nc though I expected the shape output: batch, 3, max_boxes, nc
Am I doing anything wrong?
Thanks!

@Fschoeller
Copy link
Author

Fschoeller commented Jul 6, 2021

Solved by commenting out line 44 in export model.model[-1].export = True # set Detect() layer export=True
and using inplace operation during export:

if self.inplace:
    y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i]  # xy
    y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh

@jnskplr
Copy link

jnskplr commented Mar 30, 2022

Hi,

I'm using paper branch too and exported my model to onnx. Having the same issue with output shape and tried to follow your steps.

I don't really get what you're meaning with the inplace operation. Where did you insert it into your code, I guess in forward() function of IDetect() class in yolo.py? And what else did you adjust there? Maybe you can provide your yolo.py file.

Thanks and best regards.

@jnskplr
Copy link

jnskplr commented Apr 1, 2022

Solved it for me, the way is almost the same just a little bit different. #207

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