搭建faster-rcnn进行目标检测的环境

faster-rcnn提出论文: 《Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks》

faster-rcnn 的算法详解可看这篇博文(清晰易懂,良心博文!): http://blog.csdn.net/shenxiaolu1984/article/details/51152614

faster-rcnn python版本源码地址:https://github.com/rbgirshick/py-faster-rcnn

这篇文章主要介绍搭建用faster-rcnn进行目标检测所需的环境。

1.电脑上已经有可运行caffe所需的环境

2.下载faster-rcnn python版本源码

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


3. 进入/py-faster-rcnn/lib 进行编译

cd py-faster-rcnn/lib
make


4.编译/py-faster-rcnn/caffe-fast-rcnn

cd py-faster-rcnn/caffe-fast-rcnn

cp Makefile.config.example Makefile.config

更改Makefile.config文件:

# In your Makefile.config, make sure to have this line uncommented
WITH_PYTHON_LAYER := 1
# Unrelatedly, it's also recommended that you use CUDNN
USE_CUDNN := 1

进行编译:

make -j8 && make pycaffe

因为这个版本所用的cudnn为旧版本的,可能与新环境的cudnn不兼容,导致出现如下错误:

In file included from ./include/caffe/util/cudnn.hpp:5:0,
                 from ./include/caffe/util/device_alternate.hpp:40,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/util/db.hpp:6,
                 from src/caffe/util/db.cpp:1:
/usr/local/cuda/include/cudnn.h:803:27: note: declared here
 cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
                           ^
make: *** [.build_release/src/caffe/util/db.o] Error 1
make: *** Waiting for unfinished jobs....

    

 解决办法:

         1).将/py-faster-rcnn/caffe-fast-rcnn/include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.

         2).将/py-faster-rcnn/caffe-fast-rcnn/src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。

   都替换成最新版的caffe里的相应的同名文件。

5.运行faster-rcnn里的demo

cd py-faster-rcnn/tools
./tools/demo.py



你可能感兴趣的:(caffe)