openvinotoolkit / training_extensions

Train, Evaluate, Optimize, Deploy Computer Vision Models via OpenVINO™
https://openvinotoolkit.github.io/training_extensions/
Apache License 2.0
1.14k stars 443 forks source link

Failed to convert pre-trained action recognition model to ONNX format #81

Closed elainewangprc closed 5 years ago

elainewangprc commented 5 years ago

I'd like to convert the pre-trained action recognition model to OpenVINO IR files. So I followed the instructions at https://github.com/opencv/openvino_training_extensions/tree/develop/pytorch_toolkit/action_recognition. In the first step that convert the model to ONNX, I saw below error message:

Traceback (most recent call last): File "main.py", line 385, in main() File "main.py", line 330, in main export_onnx(args, model, args.onnx) File "main.py", line 36, in export_onnx model = model.module File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 539, in getattr type(self).name, name)) AttributeError: 'VideoTransformer' object has no attribute 'module'

Steps to Reproduce (for bugs)

  1. git clone https://github.com/opencv/openvino_training_extensions.git
  2. https://download.01.org/opencv/openvino_training_extensions/models/action_recognition/resnet_34_vtn_rgbd_kinetics.pth
  3. Under directory openvino_training_extensions/pytorch_toolkit/action_recognition, run python3 main.py --model resnet34_vtn_rgbdiff --clip-size 16 --st 2 --pretrain-path ~/resnet_34_vtn_rgbd_kinetics.pth --onnx resnet34_vtn_rgbd.onnx

I want to convert the pre-trained decoder and encoder model to OpenVINO IR files. Like https://github.com/opencv/open_model_zoo/blob/master/intel_models/action-recognition-0001-encoder/description/action-recognition-0001-encoder.md and https://github.com/opencv/open_model_zoo/blob/master/intel_models/action-recognition-0001-decoder/

Your Environment

AlexanderDokuchaev commented 5 years ago

Hi @elainewangprc Fixed some problem. Try use follow command:

python3 main.py --model resnet34_vtn_rgbdiff --clip-size 16 --st 2 --pretrain-path ~/resnet_34_vtn_rgbd_kinetics.pth --onnx resnet34_vtn_rgbd.onnx --no-cuda --no-layer-norm

--no-cuda - to run in environment without cuda --no-layer-norm - to ignore LayerNormalization that can not be converted to ONNX, but this may lead to decrease accuracy of final model.

elainewangprc commented 5 years ago

Hi Alex, Thank you for fixing the issue! Now I'm able to convert the pre-trained model into ONNX format.