Caffe MobileSSD 使用过程记录

github地址:https://github.com/chuanqi305/MobileNet-SSD

1.下载SSD并编译运行

SSD caffe地址:https://github.com/weiliu89/caffe/tree/ssd

要点一:下载的VOC数据要放在HOME/username/data/目录下 而不是caffe-ssd的data目录下

要点二:数据转换,执行命令直接 sudo ./data/VOC0712/create_list.sh  或 sudo  bash ./data/VOC0712/create_list.sh

而不是 sudo sh ./data/VOC0712/create_list.sh 否则会抱如下错误:

./data/VOC0712/create_list.sh: 5: ./data/VOC0712/create_list.sh: Bad substitution
./data/VOC0712/create_list.sh: 15: ./data/VOC0712/create_list.sh: [[: not found
Create list for VOC2007 trainval...
./data/VOC0712/create_list.sh: 15: ./data/VOC0712/create_list.sh: [[: not found
Create list for VOC2012 trainval...
./data/VOC0712/create_list.sh: 39: [: trainval: unexpected operator
./data/VOC0712/create_list.sh: 45: [: trainval: unexpected operator
./data/VOC0712/create_list.sh: 15: ./data/VOC0712/create_list.sh: [[: not found
Create list for VOC2007 test...
./data/VOC0712/create_list.sh: 15: ./data/VOC0712/create_list.sh: [[: not found
Create list for VOC2012 test...
./data/VOC0712/create_list.sh: 39: [: test: unexpected operator
./data/VOC0712/create_list.sh: 45: [: test: unexpected operator

执行 sudo ./data/VOC0712/create_data.sh 命令  报错如下:

./data/VOC0712/create_data.sh: 1: ./data/VOC0712/create_data.sh: Bad substitution
python: can't open file '/home/yang/../../scripts/create_annoset.py': [Errno 2] No such file or directory
python: can't open file '/home/yang/../../scripts/create_annoset.py': [Errno 2] No such file or directory

使用命令sudo bash ./data/VOC0712/create_data.sh 或直接   ./data/VOC0712/create_data.sh命令时解决以上问题,但又抱其它错误如下:

Traceback (most recent call last):
  File "/home/yang/Documents/model/MyProject/caffe-ssd/data/VOC0712/../../scripts/create_annoset.py", line 7, in 
    from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto
Traceback (most recent call last):
  File "/home/yang/Documents/model/MyProject/caffe-ssd/data/VOC0712/../../scripts/create_annoset.py", line 7, in 
    from caffe.proto import caffe_pb2
ImportError: No module named caffe.proto

解决方法: 
1.打开 ~/caffe-ssd/scripts/create_annoset.py 文件。 
2.在import sys和from caffe.proto import caffe_pb2这两段代码中间插入sys.path.insert(0,’/home/xxx/caffe_ssd/ python’)这句代码,xxx为你们自己的用户名。

然后报错:

from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: dynamic module does not define init function (init_caffe)

解决方法:

修改create_data.sh文件中 python xxx命令为python3 xxx,完美解决。

 

针对caffe-ssd文件中存在python2语法,使用如下命令进行更改:

2to3 -f all -f idioms  directorypath -w

执行命令  python3 examples/ssd/ssd_pascal.py 时,报错如下:

Traceback (most recent call last):
  File "examples/ssd/ssd_pascal.py", line 440, in 
    AddExtraLayers(net, use_batchnorm, lr_mult=lr_mult)
  File "examples/ssd/ssd_pascal.py", line 27, in AddExtraLayers
    lr_mult=lr_mult)
  File "/home/yang/Documents/model/MyProject/caffe-ssd/python/caffe/model_libs.py", line 93, in ConvBNLayer
    [kernel_h, kernel_w] = UnpackVariable(kernel_size, 2)
  File "/home/yang/Documents/model/MyProject/caffe-ssd/python/caffe/model_libs.py", line 16, in UnpackVariable
    assert len > 0
TypeError: unorderable types: builtin_function_or_method() > int()

2.编译好的SSD要放在caffe-ssd/examples路径下,训练也是在该路径下打开文件

 

python3 merge_bn.py --model example/MobileNetSSD_deploy.prototxt --weights snapshot5/mobilenet_iter_6000.caffemodel

在caffe-ssd/build/tools文件夹下
./upgrade_net_proto_binary  no_bn.caffemodel   my.caffemodel

最后修改ptototxt中的input层

你可能感兴趣的:(深度学习,ubuntu)