CVMI-Lab / PAConv

(CVPR 2021) PAConv: Position Adaptive Convolution with Dynamic Kernel Assembling on Point Clouds
Apache License 2.0
287 stars 40 forks source link

.t7 to .onnx problem #39

Open Printeger opened 2 years ago

Printeger commented 2 years ago

Hi, nice work.

im trying to convert .t7 to .onnx model, but i got something wrong. Currently using: torch.onnx.export()

    path = "/home/t72onnx/best_model.t7"
    model = PAConv(args).to(device)
    dummy_input = torch.randn(16, 3, 1024).to(device)
    model.load_state_dict({k.replace('module.', ''):v for k, v in torch.load(path, map_location=device).items()})
    model.eval()

    torch.onnx.export(model.to(device),               # model being run
                  dummy_input.to(device),                         # model input (or a tuple for multiple inputs)
                  "my_mobileface.onnx",   # where to save the model (can be a file or file-like object)
                  export_params=True,        # store the trained parameter weights inside the model file
                  opset_version=12,
                  verbose=False, 
                  do_constant_folding=True,  # whether to execute constant folding for optimization
                  input_names = ['input'],   # the model's input names
                  output_names = ['output'], # the model's output names
                #   Operator_export_types = torch.onnx.OperatorExportTypes.onnx_aten_fallack,
                 )

but i got RuntimeError with AssignScoreWithK

Traceback (most recent call last):
  File "main.py", line 307, in <module>
    torch.onnx.export(model.to(device),               # model being run
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/__init__.py", line 271, in export
    return utils.export(model, args, f, export_params, verbose, training,
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 88, in export
    _export(model, args, f, export_params, verbose, training, input_names, output_names,
  File "/opt/conda/lib/python3.8/site-packages/torch/onnx/utils.py", line 709, in _export
    proto, export_map = graph._export_onnx(
RuntimeError: ONNX export failed: Couldn't export Python operator AssignScoreWithK

is that because torch.onnx.export does not surport PAConv model? Many thanks!