HRNet/DEKR

ONNX file generation fails

vp211991 opened this issue · 2 comments

I am using the script tools/valid.py to export ONNX file. Here is the error stack.

Total Parameters: 29,561,182
----------------------------------------------------------------------------------------------------------------------------------
Total Multiply Adds (For Convolution and Linear Layers only): 45,385,056,256
----------------------------------------------------------------------------------------------------------------------------------
Number of Layers
Conv2d : 395 layers   BatchNorm2d : 343 layers   ReLU : 306 layers   Bottleneck : 4 layers   BasicBlock : 105 layers   Upsample : 31 layers   HighResolutionModule : 8 layers   DeformConv2d : 34 layers   AdaptBlock : 34 layers   
=> loading model from pose_dekr_hrnetw32_coco.pth
/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/symbolic_helper.py:347: UserWarning: You are trying to export the model with onnx:Upsample for ONNX opset version 9. This operator might cause results to not match the expected results by PyTorch.
ONNX's Upsample/Resize operator did not match Pytorch's Interpolation until opset 11. Attributes to determine how to transform the input were added in onnx:Resize in opset 11 to support Pytorch's behavior (like coordinate_transformation_mode and nearest_mode).
We recommend using opset 11 and above for models using this operator. 
  "" + str(_export_onnx_opset_version) + ". "
Traceback (most recent call last):
  File "tools/valid_hpe.py", line 122, in <module>
    main()
  File "tools/valid_hpe.py", line 119, in main
    torch.onnx.export(model, dump_input, "/home/vinay/Downloads/dekr.onnx", verbose=True)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/__init__.py", line 276, in export
    custom_opsets, enable_onnx_checker, use_external_data_format)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 94, in export
    use_external_data_format=use_external_data_format)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 698, in _export
    dynamic_axes=dynamic_axes)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 465, in _model_to_graph
    module=module)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 206, in _optimize_graph
    graph = torch._C._jit_pass_onnx(graph, operator_export_type)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/__init__.py", line 309, in _run_symbolic_function
    return utils._run_symbolic_function(*args, **kwargs)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/utils.py", line 994, in _run_symbolic_function
    return symbolic_fn(g, *inputs, **attrs)
  File "/home/vinay/.local/lib/python3.6/site-packages/torch/onnx/symbolic_opset9.py", line 1777, in slice
    raise RuntimeError("step!=1 is currently not supported")
RuntimeError: step!=1 is currently not supported

I add the following line valid.py to export the model.

torch.onnx.export(model, dump_input, "/home/dekr.onnx", verbose=True)

The same file with the above line works fine in the other repository such as HRNet Image Classification and Human Pose Estimation.

Using opset11

xddlj commented

Using opset11

RuntimeError: Exporting the operator deform_conv2d to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator