Convert pre-trained model to .onnx format
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
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: https://github.com/pytorch/pytorch/pull/30972
@kosmastsk
@muzi2045 thanks a lot, I'll try it!
@kosmastsk hi,bro. do you convert successfully?