3D-MiniNet icon indicating copy to clipboard operation
3D-MiniNet copied to clipboard

Convert pre-trained model to .onnx format

Open kosmastsk opened this issue 5 years ago • 3 comments

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

kosmastsk avatar Nov 25 '20 13:11 kosmastsk

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 avatar Mar 02 '21 12:03 muzi2045

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

kosmastsk avatar Mar 02 '21 13:03 kosmastsk

@kosmastsk hi,bro. do you convert successfully?

xdtzzz avatar Aug 10 '21 09:08 xdtzzz