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

Export trained model to model.onnx file #32

Closed
leo94-chen opened this issue Jan 18, 2020 · 10 comments
Closed

Export trained model to model.onnx file #32

leo94-chen opened this issue Jan 18, 2020 · 10 comments

Comments

@leo94-chen
Copy link

Hi, thanks for your kind sharing.

Could you please provide the code for exporting the trained model to model.onnx file? Thanks.

@tano297
Copy link
Member

tano297 commented Jan 20, 2020

@Chen-Xieyuanli can you comment on this?

@Chen-Xieyuanli
Copy link
Member

Chen-Xieyuanli commented Jan 20, 2020

Hi @leo94-chen, here is my hack, which is not well-programmed, but you could take it as an example.

https://gist.github.com/Chen-Xieyuanli/980cc0a2c9b664b9cc279b19d61aa898#file-make_onnx-py

@akouri-dd
Copy link

FWIW I opened a fork that contains code to export to ONNX: https://github.com/andrewkouri/lidar-bonnetal/blob/master/train/tasks/semantic/create_onnx.py

Unfortunately I am still having problems opening the model in TensorRT because it is exported with an "ir_version" that is too new... will update if I figure out how to deal with it.

@balajiravichandiran
Copy link

balajiravichandiran commented Jun 16, 2020

FWIW I opened a fork that contains code to export to ONNX: https://github.com/andrewkouri/lidar-bonnetal/blob/master/train/tasks/semantic/create_onnx.py

Unfortunately I am still having problems opening the model in TensorRT because it is exported with an "ir_version" that is too new... will update if I figure out how to deal with it.

This script works for me. Able to inference tensorRt without problem.

I have tried with cuda 10.1, tensorrt.5.1 and cuda 10.2, tensorrt 6.0

Sorry forget to mention. I modified backbone. https://github.com/PRBonn/lidar-bonnetal/blob/master/train/backbones/darknet.py
commented line 159.
#x = x[:, self.input_idxs]

If i dont comment i got something aten error

@caoyifeng001
Copy link

@akouri-dd @balajiravichandiran
hi,when i create onnx file using this script ,i meet a problem.
RuntimeError: ONNX export failed: Couldn't export operator aten::index

@balajiravichandiran
Copy link

@caoyifeng001 you need to comment the line 159 in below file.

I modified backbone. https://github.com/PRBonn/lidar-bonnetal/blob/master/train/backbones/darknet.py
commented line 159.
#x = x[:, self.input_idxs]

@caoyifeng001
Copy link

@balajiravichandiran
thank you, I solved my problem, but I don't understand why this works.

@tano297
Copy link
Member

tano297 commented Jul 21, 2020

We've experienced this too, it is because of a bug in the indexing operation when exporting to onnx. Since the model uses all channels, this is virtually a no op, so it works anyway

@jbehley
Copy link
Member

jbehley commented Dec 4, 2020

I think it seems resolved. If you still have questions, please reopen the issue or comment on this issue.

@jbehley jbehley closed this as completed Dec 4, 2020
@aprilliuwei
Copy link

I can successfully run this script file, but no. Onnx file is generated. Who can help me?Here are the results of my run,Thanks.
1
112

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

8 participants