Advertisement

学习Faster-RCNN (一)跑Faster-RCNN的python版demo

阅读量:

跑Faster-RCNN的python版demo

一、准备材料

在官网“https://github.com/rbgirshick/py-faster-rcnn#installation-sufficient-for-the-demo”,下载demo,阅读“README.md”,按照网址:“https://github.com/rbgirshick/py-faster-rcnn#installation-sufficient-for-the-demo”的步骤,把Requirements: software和Requirements: hardware要求的条件做好,然后Installation (sufficient for the demo)。

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

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

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

  1. cd py-faster-rcnn/lib
  2. make

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

  1. cd py-faster-rcnn/caffe-fast-rcnn
  2. cp Makefile.config.example Makefile.config

二、最关键的地方是修改“Makefile.config”;

1)如果用CPU跑,一定要把“# CPU_ONLY := 1”前面的“#”号去掉;一定要检查您的caffe-master是否安装编译通过,并且Makefile.config是CPU_ONLY := 1的。
2)如果安装了MKL数学计算库就把“BLAS := atlas”改为“BLAS := mkl”。

3)最关键的一步:一定要把“# WITH_PYTHON_LAYER := 1”前面的“#”号去掉。否则python代码写的layrs无法解析。

  1. 进行编译
  1. make -j8 && make pycaffe

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

In file included from ./include/caffe/util/cudnn.hpp:5:0,
2. from ./include/caffe/util/device_alternate.hpp:40,
3. from ./include/caffe/common.hpp:19,
4. from ./include/caffe/util/db.hpp:6,
5. from src/caffe/util/db.cpp:1:
6. /usr/local/cuda/include/cudnn.h:803:27: note: declared here
7. cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
8. ^
9. make: *** [.build_release/src/caffe/util/db.o] Error 1
10. 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里的相应的同名文件。

如果报opencv的imread()错误,则需要在Makefile.config添加:

LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system boost_filesystem hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

三、以上都做好后,输入:cd $FRCN_ROOT;python ./tools/demo.py -CPU;如果用GPU跑一定要记得输入:"python ./tools/demo.py --gpu 0";0代表显卡的设备号。

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

结果如下:

第一次运行:

未完待续。。。

全部评论 (0)

还没有任何评论哟~