Error converting Mobilenet v2 from pytorch to tensorflow
Platform (ubuntu 16.04):
Python version: Python 3.6.2
Source framework with version pytorch 1.6 CPU:
Destination framework with version (tensorflow 1.13):
Pre-trained model path (webpath or webdisk path):
Model - download with mmdownload
mmdownload -f pytorch -n mobilenet_v2 -o ./
Running scripts:
mmdownload -f pytorch -n mobilenet_v2 -o ./ mmtoir -f pytorch -d mobilenet_v2 --inputShape 3,224,224 -n imagenet_mobilenet_v2.pth
Error message:
/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/torch/onnx/symbolic_helper.py:438: UserWarning: ONNX export mode is set to inference mode, but operator dropout is set to training mode. The model will be exported in inference, as specified by the export mode.
training_mode + ", as specified by the export mode.")
Traceback (most recent call last):
File "/home/radud/anaconda3/envs/model-converter/bin/mmtoir", line 8, in <module>
sys.exit(_main())
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 197, in _main
ret = _convert(args)
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 97, in _convert
parser = PytorchParser151(model, inputshape[0])
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 523, in __init__
self.build_graph(input_shape)
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 92, in build_graph
self.pytorch_graph.build(self.input_shape)
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/pytorch/pytorch_graph.py", line 143, in build
output_shape = [int(x.replace('!', '')) for x in output_shape_str.split(',')]
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/pytorch/pytorch_graph.py", line 143, in <listcomp>
output_shape = [int(x.replace('!', '')) for x in output_shape_str.split(',')]
ValueError: invalid literal for int() with base 10: '1:401408'
Hello. I have tried converting the mobilenetv2 model downloaded with the mmdownload command and have encountered this error. I have also had similar issues when trying to convert a mobilenetv2 which was first converted from TF to pytorch using mmdnn. By similar issues, I mean it can not parse the output shape. Can you please help me? Thank you
I have also tried converting my model using pytorch 1.5.1 and get a different error now
Traceback (most recent call last):
File "/home/radud/anaconda3/envs/model-converter/bin/mmtoir", line 8, in <module>
sys.exit(_main())
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 197, in _main
ret = _convert(args)
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/_script/convertToIR.py", line 120, in _convert
parser.run(args.dstPath)
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/common/DataStructure/parser.py", line 22, in run
self.gen_IR()
File "/home/radud/anaconda3/envs/model-converter/lib/python3.6/site-packages/mmdnn/conversion/pytorch/pytorch_parser.py", line 100, in gen_IR
node_type = PytorchParser.layer_map[onnx_node_type]
KeyError: 'onnx::Clip'
seems related to issue: https://github.com/microsoft/MMdnn/issues/872