这里主要介绍下faster_rcnn的安装
1.安装平台和准备事项:
我使用的ubuntu14.04
opencv-2 (sudo apt-get install 安装比较容易,opencv3安装相对比较难)
2.去github下,clone官方源码包
https://github.com/rbgirshick/py-faster-rcnn
3.参照github上官方地址的readme进行安装
Contents
- Requirements: software
- Requirements: hardware
- Basic installation
- Demo
- Beyond the demo: training and testing
- Usage
Requirements: software
NOTE If you are having issues compiling and you are using a recent version of CUDA/cuDNN, please consult this issue for a workaround
- Requirements for
Caffe
andpycaffe
(see: Caffe installation instructions)
Note: Caffe must be built with support for Python layers!
# 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
You can download my Makefile.config for reference.2. Python packages you might not have: cython
, python-opencv
, easydict
3. [Optional] MATLAB is required for official PASCAL VOC evaluation only. The code now includes unofficial Python evaluation code.
Requirements: hardware
- For training smaller networks (ZF, VGG_CNN_M_1024) a good GPU (e.g., Titan, K20, K40, ...) with at least 3G of memory suffices
- For training Fast R-CNN with VGG16, you'll need a K40 (~11G of memory)
- For training the end-to-end version of Faster R-CNN with VGG16, 3G of GPU memory is sufficient (using CUDNN)
Installation (sufficient for the demo)
- Clone the Faster R-CNN repository
# Make sure to clone with --recursive
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
We'll call the directory that you cloned Faster R-CNN into
FRCN_ROOT
Ignore notes 1 and 2 if you followed step 1 above.
Note 1: If you didn't clone Faster R-CNN with the
--recursive
flag, then you'll need to manually clone thecaffe-fast-rcnn
submodule:git submodule update --init --recursive
Note 2: The
caffe-fast-rcnn
submodule needs to be on thefaster-rcnn
branch (or equivalent detached state). This will happen automatically if you followed step 1 instructions.Build the Cython modules
cd $FRCN_ROOT/lib make
Build Caffe and pycaffe
cd $FRCN_ROOT/caffe-fast-rcnn # Now follow the Caffe installation instructions here: # http://caffe.berkeleyvision.org/installation.html # If you're experienced with Caffe and have all of the requirements installed # and your Makefile.config in place, then simply do: make -j8 && make pycaffe
Download pre-computed Faster R-CNN detectors
cd $FRCN_ROOT ./data/scripts/fetch_faster_rcnn_models.sh
This will populate the
$FRCN_ROOT/data
folder withfaster_rcnn_models
. Seedata/README.md
for details.These models were trained on VOC 2007 trainval.
Demo
After successfully completing basic installation, you'll be ready to run the demo.
To run the demo
cd $FRCN_ROOT
./tools/demo.py
上面是官方的教程,但是需要注意的是cudnn经常出问题,这是因为这里的cudnn的版本较老,解决办法是去github上下载最新的caffe,地址如下:
https://github.com/BVLC/caffe
并且把所有cudnn的cpp和.h都替换成最新版本caffe底下的,这一步如果有不明白的,可以参照如下博客:
https://blog.csdn.net/u010733679/article/details/52221404
当然还有一种比较简单的方法,就是编译caffe时直接不使用cudnn(这样会导致训练速度较慢,但是也没有慢到像cpu那样子了啦,如果只是为了跑实验连连手可以直接使用这种方法)
安装完之后,参照官方readme一步步实验就可以了,一般是可以跑出结果的,值得注意的是官方使用的网络vgg16\zf网络等在2018年来看都已经完全过时,现在主流的识别网络已经替换成resnet/densenet等。建议自行使用resnet模型替换掉这部分,可以去caffe-zoo上面找一下,或者自行使用resnet在imagenet进行训练。
resnet论文和resnet-caffe实现 分别在arxiv和github上搜索一下就很容易得到了。