PRBonn / lidar-bonnetal

Semantic and Instance Segmentation of LiDAR point clouds for autonomous driving
http://semantic-kitti.org
MIT License
945 stars 205 forks source link

Export trained model to model.onnx file #32

Closed leo94-chen closed 3 years ago

leo94-chen commented 4 years ago

Hi, thanks for your kind sharing.

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

tano297 commented 4 years ago

@Chen-Xieyuanli can you comment on this?

Chen-Xieyuanli commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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

tano297 commented 4 years ago

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 commented 3 years ago

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

aprilliuwei commented 2 years ago

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