Faster R-CNN检测模型的环境搭建(Ubuntu,caffe)

1 首先要保证安装了cython, python-opencv, easydict,如果没有请执行以下命令:

pip install cython 

pip install easydict

apt-get install python-opencv

或:

sudo apt-get install cython
sudo apt-get install python-opencv
sudo pip install easydict
 

2 下载Faster R-CNN源码:

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

加--recursive参数,能保证项目工程中的caffe-fast-rcnn子模块的下载

3 修改Makefile.config

cp Makeile.config.example Makefile.config

修改:

(1)WITH_PYTHON_LAYER:=1  (打开python接口)

(2)修改以下两行成下列模样:

INCLUDE_DIRS := $(PYTHON_INCLUDE)    /usr/local/include   /usr/include/hdf5/serial/

LIBRARY_DIRS := $(PYTHON_LIB)   /usr/local/lib     /usr/lib      /usr/lib/x86_64-linux-gnu/hdf5/serial/

4 编译Cython模块:

cd py-faster-rcnn/lib

make

5 编译caffe和pycaffe

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

make all  (make -j32   (或者改为-j8、-j16,或者干脆不加))

make pycaffe 

可能会出现当前版本的caffe的cudnn实现与系统安装的cudnn的版本不一致的问题

可能会出现gpu不支持computer20,修改Makefile文件删掉computer20

可能出现找不到-lopenblas错误,运行:apt install liblapack-dev liblapack3 libopenblas-base libopenblas-dev

6 下载预训练模型

cd py-faster-rcnn

./data/scripts/fetch_faster_rcnn_models.sh

7 运行测试demo

cd py-faster-rcnn

./tools/demo.py

原文地址:https://www.cnblogs.com/dindin1995/p/13059195.html