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

Convert pre-trained model to .onnx format #7

Open
kosmastsk opened this issue Nov 25, 2020 · 3 comments
Open

Convert pre-trained model to .onnx format #7

kosmastsk opened this issue Nov 25, 2020 · 3 comments

Comments

@kosmastsk
Copy link

I tried to convert the pre-trained 3D-MiniNet to .onnx format by using the script provided in a similar issue of lidar-bonnetal here.

Specifically, I changed the part that is related to the dummy input of the model in the following way:
dinput = torch.randn(1, 11, 64, 2048, device='cuda', requires_grad=True)
input_points = torch.randn(1, 11, 16, 8192, device='cuda', requires_grad=True)
dummy_input = [dinput, input_points]
and the rest of the script remains the same.

However, I get the following error related to ONNX

Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible

I tried to apply the fix that was suggested here, but it didn't work.

Is there any other way of converting it to ONNX format?
I am using exactly the same versions of packages as in the requirements.txt file

@muzi2045
Copy link

muzi2045 commented Mar 2, 2021

try this script:

print("Starting export onnx model.")
dinput = torch.randn(1, 11, 64, 2048, device='cuda', requires_grad=True)
input_points = torch.randn(1, 11, 16, 8192, device='cuda', requires_grad=True)
input_names = ["proj_in", "proj_points"]
inputs = [[dinput, input_points]]
inputs = tuple(inputs)
torch.onnx.export(model, inputs, "mininet3d.onnx", verbose=True,
                    input_names=input_names, export_params=True, keep_initializers_as_inputs=True, opset_version=11)

when try to convert F.unflod op to onnx, you will need this PR:
pytorch/pytorch#30972

@kosmastsk

@kosmastsk
Copy link
Author

@muzi2045 thanks a lot, I'll try it!

@xdtzzz
Copy link

xdtzzz commented Aug 10, 2021

@kosmastsk hi,bro. do you convert successfully?

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

3 participants