您的位置:首页 > 编程语言 > Python开发

Faster-R-CNN(Python).1:从配置到demo

2017-05-04 21:56 471 查看
本文主要讲解Faster-R-CNN(Python)配置过程中遇到的问题。

1. 下载源码

Python版本: https://github.com/rbgirshick/py-faster-rcnn

网传需要用–recursive命令复制源码,否则无法clone到caffe,但是我用的自己的caffe,所以不受影响。

git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git[/code] 

2. 安装必要的Python模块

cython, python-opencv, easydict

pip install cython
pip install easydict
conda install opencv (我安装了anaconda)


3. Build the Cython modules

cd $FRCN_ROOT/lib
make


4. 重新编译caffe

我没有用源码中自带的caffe,而是用的自己之前配置的。

版本:

Ubuntu14.04 LTS

cuda8.0

cudnn5.1

OpenCV3.0

Python2.7

但是Faster-R-CNN中有两个新层需要添加

roi_pooling_layer

smooth_L1_loss_layer

将相关文件放入相应文件夹中:

(1)test_roi_pooling_layer.cpp

(2)test_smooth_L1_loss_layer.cpp

(3)roi_pooling_layer.cpp

(4)roi_pooling_layer.cu

(5)smooth_L1_loss_layer.cpp

(6)smooth_L1_loss_layer.cu

(7)fast_rcnn_layers.hpp

添加方法参照下面链接:

https://yunmingzhang.wordpress.com/2015/01/19/how-to-create-your-own-layer-in-deep-learning-framework-caffe/

然后按照官网方法重新编译:

http://caffe.berkeleyvision.org/installation.html

mkdir build
cd build
cmake ..
make all
make install
make runtest
make pycaffe


done!

遇到的问题:

(1)src/caffe/test/test_smooth_L1_loss_layer.cpp:11:35: fatal error: caffe/vision_layers.hpp

解决方法:

找到文件$CAFFE_ROOT/src/caffe/test/test_smooth_L1_loss_layer.cpp

删除第十一行

11 #include "caffe/vision_layers.hpp"


(2) libhdf5_hl.so.10: cannot open shared object file: No such file or directory

解决方法:

添加环境变量并重启计算机

vi ~/.bachrc


添加:

export LD_LIBRARY_PATH="/path/to/anaconda2/lib":$LD_LIBRARY_PATH


vi文件命令:

i’ – Insert,编辑

ESC’键 +‘:wq’ –强制保存并退出

5. Download pre-computed Faster R-CNN detectors

cd $FRCN_ROOT
./data/scripts/fetch_faster_rcnn_models.sh


6. demo

cd $FRCN_ROOT
./tools/demo.py


遇到的问题:

(1) AttributeError: ‘ProposalLayer’ object has no attribute ‘param_str_’

解决方法:

找到对应文件,修改param_str_为param_str

(2) proposal_layer.py出现 keyerror:’1’错误

解决方法:

暴力地将第64行改为cfg_key = ‘TEST’#str(self.phase), demo可以正常运行

7.The demo performs detection using a VGG16 network trained for detection on PASCAL VOC 2007.

Bonne chance pour le Faster-R-CNN! ^-^
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息