microsoft / MMdnn

MMdnn is a set of tools to help users inter-operate among different deep learning frameworks. E.g. model conversion and visualization. Convert models between Caffe, Keras, MXNet, Tensorflow, CNTK, PyTorch Onnx and CoreML.
MIT License
5.8k stars 965 forks source link

Keras Retinanet to Caffe #505

Open lawrencekiba opened 6 years ago

lawrencekiba commented 6 years ago

Platform (like ubuntu 16.04/win10): Ubuntu 16.04

Python version: 3.5

Source framework with version (like Tensorflow 1.4.1 with GPU): Tensorflow 1.12 GPU

Destination framework with version (like CNTK 2.3 with GPU): Caffe

Pre-trained model path (webpath or webdisk path): Trained my own dataset, but the pre-trained model can be found in this link https://github.com/fizyr/keras-retinanet/releases

Running scripts: mmconvert -sf keras -iw datasets/snapshots/resnet50_csv_25.h5 -df caffe -om resnet50_csv_025.prototxt --inputShape 224,224,3 When the above does not work, I tried mmtoir -f keras -w /datasets/snapshots/resnet50_csv_25.h5 --inputShape 3,244,244 -d resnet50_csv_25

Obtained the following error message for both commands even though I've already included the input shape at mmconvert

File "/home/macman/PycharmProjects/moovitmoovit/venv/bin/mmtoir", line 11, in sys.exit(_main()) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/_script/convertToIR.py", line 192, in _main ret = _convert(args) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/_script/convertToIR.py", line 115, in _convert parser.run(args.dstPath) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/common/DataStructure/parser.py", line 22, in run self.gen_IR() File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 150, in gen_IR func(current_node) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 480, in rename_MaxPooling2D self._convert_pooling(source_node, 2, "MAX", False) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 335, in _convert_pooling self._convert_padding(source_node, IR_node) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/keras/keras2_parser.py", line 212, in _convert_padding list(source_node.layer.strides)) File "/home/macman/PycharmProjects/moovitmoovit/venv/lib/python3.5/site-packages/mmdnn/conversion/common/utils.py", line 114, in compute_tf_same_padding output_shape = (input_shape[idx] + strides[idx] - 1) // strides[idx] TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Would appreciate help on this one. Thank you.

nfnpmc commented 5 years ago

So would I. Same error (at line 116) converting Keras to Caffe.