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

Picodet ONNX Opset 11 #70998

Closed
simoberny opened this issue Jan 30, 2025 · 3 comments
Closed

Picodet ONNX Opset 11 #70998

simoberny opened this issue Jan 30, 2025 · 3 comments
Assignees
Labels

Comments

@simoberny
Copy link

请提出你的问题 Please ask your question

Hi,
I'm training a PicoDet XS network on a custom dataset using PaddleDetection. The training completes successfully, and the model export works fine.
However, when I try to convert it to ONNX using paddle2onnx, I get the following error:

Due to the operator: hard_swish, requires opset_version >= 14.

Checking the PaddleDetection code, I see that HardSwish is used in LCNet and other components. However, I noticed that the pre-converted ONNX model example available in the README does not contain HardSwish.

To resolve this, I tried downgrading PaddleDetection to versions 2.3 and 2.4 (the first versions introducing PicoDet), but the issue persists.

I strictly need an ONNX model with Opset 11 for further conversion.

My questions:
How can I modify the network to avoid HardSwish or any other Opset 14 operators?
Is there a way to obtain the same network as the example ONNX model but compatible with Opset 11?
Any guidance would be greatly appreciated.
Thanks!

@nicklasb
Copy link

nicklasb commented Feb 3, 2025

Hi,

I set the activation function to relu6 in the configuration, then it will not use HardSwish (it is not very important for my case).
LCNet, LCPAN and PicoHeadV2 all take this parameter (act: relu6).

However, LCPAN doesn't follow that setting, that is why I did this PR (you can manually make that small change to LCPAN if you want to): PaddlePaddle/PaddleDetection#9280

(Note that the issue is with PaddleDetection, not Paddle itself, so perhaps this issue should be there instead)

@nicklasb
Copy link

nicklasb commented Feb 4, 2025

@simoberny Also there is a --opset_version parameter. So you would pass paddle2onnx your_commands --opset_version=11.

@huangjiyi huangjiyi removed their assignment Feb 7, 2025
@simoberny
Copy link
Author

@nicklasb Yes, I had already tried all those steps before opening the issue, but there always seemed to be a hard_swish inside the network that forced ONNX export to jump to level 14. What resolved the issue were exactly your PR changes, as you mentioned, LCPAN does not follow the activation rule specified in the config.

Also act: relu6 need to be placed in the conv_feat of PicoHeadV2

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants