Caffe

SLAMDUCK

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的时候暂时没发现有什么影响,特此说明。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值