R-CNN detection
matlab路径问题
在运行官方提供的R-CNN实例时,当运行语句
../python/detect.py --crop_mode=selective_search --pretrained_model=../models/bvlc_reference_rcnn_ilsvrc13/bvlc_reference_rcnn_ilsvrc13.caffemodel --model_def=../models/bvlc_reference_rcnn_ilsvrc13/deploy.prototxt --gpu --raw_scale=255 _temp/det_input.txt _temp/det_output.h
时出现如下问题
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
按照步骤
1.运行demo.m (先安装linux版本的matlab)
2.将selective_search_ijcv_with_python加入python系统路径
ps:也可以使用 sys.path.append()
参照https://github.com/BVLC/caffe/issues/1030描述核对,也没发现问题,最后终于在https://groups.google.com/forum/#!topic/caffe-users/9bV9dqXhh0A
找到问题所在
Desmond Elliott
...This error is because it cannot read a file that it expected to be produced by MATLAB.
1) Have you correctly set Matlab path in Makefile.config?
2) Have you built the MATLAB packages for Caffe? `make matcaffe`
原来是matlab路径找不到的原因,遂将matlab添加到系统路径就正常运行了.
ps:添加路径可以在/etc/profile或~/.bashrc中添加
export PATH=$PATH:{path_you_want_to_add}
最后source file_name 立即生效
最好重启Ipyhon notebook不然path在环境下好像还没更新
detector文件的修改
处理完上面的问题接着运行后还可能会出现如下问题
predictions = out[self.outputs[0]].squeeze(axis=(2,3))
87
88 # For oversampling, average predictions across crops.
ValueError: 'axis' entry 2 is out of bounds [-2, 2)
依据https://github.com/BVLC/caffe/issues/2041
将出现问题的文件detector.py
和行数确定后做如下修改
将86行的
out[self.outputs[0]].squeeze(axis=(2,3))
修改为
predictions = out[self.outputs[0]].squeeze()
可以正常使用detector.py了,这样修改是否会有影响dgmp88也不清楚,但我在做detection的时候暂时没发现有什么影响,特此说明。