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版本源码
[plain] view plain copy git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
3. 进入/py-faster-rcnn/lib 进行编译
[plain] view plain copy cd py-faster-rcnn/lib make
4.编译/py-faster-rcnn/caffe-fast-rcnn
[plain] view plain copy cd py-faster-rcnn/caffe-fast-rcnn
[plain] view plain copy cp Makefile.config.example Makefile.config
更改Makefile.config文件:
[plain] view plain copy # 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
进行编译:
[plain] view plain copy make -j8 && make pycaffe
因为这个版本所用的cudnn为旧版本的,可能与新环境的cudnn不兼容,导致出现如下错误:
[plain] view plain copy 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里的相应的同名文件。
src/caffe/layers/cudnn_relu_layer.cpp: In member function ‘virtual void caffe::CuDNNReLULayer<Dtype>::LayerSetUp(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&)’: src/caffe/layers/cudnn_relu_layer.cpp:16:45: error: ‘activ_desc_’ was not declared in this scope cudnn::createActivationDescriptor<Dtype>(&activ_desc_, CUDNN_ACTIVATION_RELU); ^ make: *** [.build_release/src/caffe/layers/cudnn_relu_layer.o] 错误 1
将./include/caffe/layers的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp,cudnn_lcn_laye.hpp</p> 都替换成最新版的caffe里的相应的同名文件
5.运行faster-rcnn里的demo
[plain] view plain copy cd py-faster-rcnn/tools ./tools/demo.py