Open schyun9212 opened 4 years ago
I used opset10. To avoid incorrect resize, I should change opset version to 11.
UserWarning: You are trying to export the model with onnx:Resize for ONNX opset version 10. 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).
I removed unnecessary type casting to remove this error
TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
# from
image_list = ImageList(image.unsqueeze(0), [(int(image.size(-2)), int(image.size(-1)))])
# to
image_list = ImageList(image.unsqueeze(0), [(image.size(-2), image.size(-1))])
But this causes wrong result
🐛 Bug
I exported submodules backbone, rpn, roi_heads. backbone is successfully created and executable. But in case of rpn, it has two inputs 'image' and 'features'. Although model was exported, no graphs related to images were created, which led to wrong results.
Considering that the cause of the bug was caused by multiple inputs, we have created a model following the two models(backbone + rpn). But graph of exported model same as backbone.
In case of roi_heads, we can exported model. But failed to load on onnxruntime. And cannot create shape infer model, graph showed bbox as a unique input.
To Reproduce
Environment
PyTorch version: 1.3.1 Is debug build: No CUDA used to build PyTorch: 10.1.243
OS: Ubuntu 18.04.3 LTS GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 CMake version: version 3.10.2
Python version: 3.7 Is CUDA available: Yes CUDA runtime version: 10.1.243 GPU models and configuration: GPU 0: GeForce RTX 2080 Ti Nvidia driver version: 440.44 cuDNN version: Probably one of the following: /usr/local/cuda-10.0/targets/x86_64-linux/lib/libcudnn.so.7 /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7.6.5
Versions of relevant libraries: [pip3] numpy==1.18.1 [pip3] onnx==1.6.0 [pip3] onnxruntime==1.1.0 [pip3] onnxruntime-gpu==1.1.0 [pip3] torch==1.3.1 [pip3] torchvision==0.4.2 [conda] Could not collect