zhreshold / mxnet-ssd

MXNet port of SSD: Single Shot MultiBox Object Detector. Reimplementation of https://github.com/weiliu89/caffe/tree/ssd
MIT License
764 stars 337 forks source link

Convert caffemodel mobilenet #214

Open ss481 opened 6 years ago

ss481 commented 6 years ago

I want to convert a caffe model (https://github.com/chuanqi305/MobileNet-SSD) to mxnet model. When i run the command python convert_model.py MobileNetSSD_deploy.prototxt mobilenet_iter_73000.caffemodel ssd_converted or python convert_model.py MobileNetSSD_deploy.prototxt MobileNetSSD_deploy.caffemodel ssd_converted i get the following error: Using mxnet as: <module 'mxnet' from '/home/sstojanoski/.virtualenvs/mxnet/local/lib/python2.7/site-packages/mxnet/init.pyc'> Warning: using pre-installed version of mxnet may cause unexpected error... (export MXNET_EXAMPLE_SSD_DISABLE_PRE_INSTALLED=1) to prevent loading pre-installed mxnet. Traceback (most recent call last): File "convert_model.py", line 135, in main() File "convert_model.py", line 45, in main prob, input_dim = proto2symbol(args.caffe_prototxt) File "/home/sstojanoski/converter/mxnet-ssd-master/tools/caffe_converter/convert_symbol.py", line 306, in proto2symbol sym, output_name, input_dim = proto2script(proto_file) File "/home/sstojanoski/converter/mxnet-ssd-master/tools/caffe_converter/convert_symbol.py", line 227, in proto2script max_size = math.sqrt(param.min_size[0] * param.max_size[0]) / input_dim[2] IndexError: list index (0) out of range

zhreshold commented 6 years ago

the converter is too old and I do not have plan to fix it.

ndcuong91 commented 6 years ago

@stefanstojanoski I had the same trouble with you. Did you find the way to solve it? @zhreshold Do you have any release for mobilenet 300x300?

ndcuong91 commented 6 years ago

@stefanstojanoski @zhreshold I have following error when convert: Traceback (most recent call last): File "/home/prdcv/Downloads/pycharm-community-2018.1.3/helpers/pydev/pydevd.py", line 1664, in main() File "/home/prdcv/Downloads/pycharm-community-2018.1.3/helpers/pydev/pydevd.py", line 1658, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home/prdcv/Downloads/pycharm-community-2018.1.3/helpers/pydev/pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/home/prdcv/PycharmProjects/gvh205/mxnet_ssd/tools/caffe_converter/convert_model.py", line 168, in main() File "/home/prdcv/PycharmProjects/gvh205/mxnet_ssd/tools/caffe_converter/convert_model.py", line 150, in main wmat = wmat.reshape(arg_shape_dic[weight_name]) ValueError: cannot reshape array of size 288 into shape (32,32,3,3)

Do you guys have any suggestion to solve it?

ss481 commented 6 years ago

I am not converting the caffe model. You can train ssd_mobilenet512 with --data-shape 300. The model I trained got good accuracy 76% and is much faster that the model with 512 shape (82% accuracy). You can try this approach.

ndcuong91 commented 6 years ago

@stefanstojanoski i know i could do it but my purpose is to build a network as small as possible. Now im trying to modify mobilenet's network in Mxnet as similar as possible with mobilenet-ssd-300 model in Caffe. Can you give me some suggestion to do it @zhreshold ?

ndcuong91 commented 6 years ago

[Update] The caffe converter tool has issue with depthwise convolution layer in mobilenet. I fixed it manually and i could run mobilenet_ssd_300 model in Mxnet now with mAP=70.9% on VOC 2007

ss481 commented 6 years ago

@titikid Nice work. Can you send me the model, so i can try it? Thank you. My email is stefanstojanoski@hotmail.com

madhavajay commented 6 years ago

@titikid are you able to put your code for a MXNet MobileNet SSD 300 on GitHub so I can see and replicate it?

ndcuong91 commented 6 years ago

@madhavajay you can use mobilenet_ssd_300 models in my repo