ahangchen / windy-afternoon

Gitbook based Blog, Android, Linux, Deep Learning, Computer Vision
https://blog.cweihang.io
365 stars 67 forks source link

merge_bn.py AttributeError: 'collections.OrderedDict' object has no attribute 'iterkeys' #16

Closed MichaelQWang closed 6 years ago

MichaelQWang commented 6 years ago

Hi ahangchen, I install ncs(https://github.com/movidius/ncsdk),the ssd-caffe path is /opt/movidius/ssd-caffe/. When i run merge_bn.py file,it's output is AttributeError: 'collections.OrderedDict' object has no attribute 'iterkeys'.how to tackle this problem? Thanks in advance.

##################################### I0526 14:59:43.139652 7526 net.cpp:228] conv3 does not need backward computation. I0526 14:59:43.139660 7526 net.cpp:228] conv3/dw/relu does not need backward computation. I0526 14:59:43.139668 7526 net.cpp:228] conv3/dw does not need backward computation. I0526 14:59:43.139673 7526 net.cpp:228] conv2/relu does not need backward computation. I0526 14:59:43.139681 7526 net.cpp:228] conv2 does not need backward computation. I0526 14:59:43.139706 7526 net.cpp:228] conv2/dw/relu does not need backward computation. I0526 14:59:43.139744 7526 net.cpp:228] conv2/dw does not need backward computation. I0526 14:59:43.139750 7526 net.cpp:228] conv1/relu does not need backward computation. I0526 14:59:43.139756 7526 net.cpp:228] conv1 does not need backward computation. I0526 14:59:43.139761 7526 net.cpp:228] conv1/dw/relu does not need backward computation. I0526 14:59:43.139766 7526 net.cpp:228] conv1/dw does not need backward computation. I0526 14:59:43.139771 7526 net.cpp:228] conv0/relu does not need backward computation. I0526 14:59:43.139776 7526 net.cpp:228] conv0 does not need backward computation. I0526 14:59:43.139782 7526 net.cpp:228] data_input_0_split does not need backward computation. I0526 14:59:43.139787 7526 net.cpp:228] input does not need backward computation. I0526 14:59:43.139792 7526 net.cpp:270] This network produces output detection_out I0526 14:59:43.139940 7526 net.cpp:283] Network initialization done. Traceback (most recent call last): File "merge_bn.py", line 62, in merge_bn(net, net_deploy) File "merge_bn.py", line 21, in merge_bn for key in net.params.iterkeys(): AttributeError: 'collections.OrderedDict' object has no attribute 'iterkeys' michael@ubt1604:~/workspace/MobileNet-SSD$

ahangchen commented 6 years ago

I guess you are using python3 which is supported by NCS, but MobileNet-SSD are written in python2. You need to modify MobileNet-SSD code to make it pass training and test in python3.

MichaelQWang commented 6 years ago

Hi ahangchen, Thanks for your reply. how do you run merge_bn.py,use python2 or python3 in your project?and what MobileNet-SSD code i should modify? Thanks in advance.

ahangchen commented 6 years ago

I use python3 to train and merge. Please refer to this.

MichaelQWang commented 6 years ago

Hi ahangchen, I want to know you run merge_bn.py with ncs ssd-caffe or installed another ssd-caffe to merge. I need to install another ssd-caffe to run merge_bn.py,am i right? ########################### michael@ubt1604:~/workspace/MobileNet-SSD$ python merge_bn.py Traceback (most recent call last): File "merge_bn.py", line 5, in import caffe File "/opt/movidius/ssd-caffe/python/caffe/init.py", line 1, in from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver File "/opt/movidius/ssd-caffe/python/caffe/pycaffe.py", line 13, in from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: dynamic module does not define init function (init_caffe) michael@ubt1604:~/workspace/MobileNet-SSD$

################################ import numpy as np
import sys,os
caffe_root = '/opt/movidius/ssd-caffe/' sys.path.insert(0, caffe_root + 'python')
import caffe

train_proto = 'example/MobileNetSSD_train.prototxt'
train_model = 'snapshot/mobilenet_iter_32.caffemodel' #should be your snapshot caffemodel

deploy_proto = 'example/MobileNetSSD_deploy.prototxt'
save_model = 'snapshot/MobileNetSSD_markpoint_deploy.caffemodel'

MichaelQWang commented 6 years ago

Hi ahangchen, Thanks very much.You help me to tackle the problem. Thanks again.