(1)安装cython, python-opencv,easydict
pip install cython
pip install easydict
apt-get install python-opencv
(2)下载py-faster-rcnn
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
(3)进入py-faster-rcnn/lib,执行make
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文件:去掉以下的注释
WITH_PYTHON_LAYER := 1
USE_CUDNN := 1
配置好Makefile.config文件后,执行:
make -j8 && make pycaffe
报错:error: argument of type “int” is incompatible with parameter of type “cudnnNanPropagation_t”
解决方案:参考(http://www.voidcn.com/blog/10km/article/p-6514306.html)
(5)下载fetch_fast_rcnn_models
cd ~/py-faster-rcnn
./data/scripts/fetch_faster_rcnn_models.sh
如果网络连接不上外网,可以去网络上找网盘资源下载。
下载后存放在:~/py-faster-rcnn/data/faster_rcnn_models/XXXX.caffemodel
(6)运行演示文件demo.py
cd ~/py-faster-rcnn/tools
./demo.py
报错:Error: No module named cv2
解决方法:参考自(http://stackoverflow.com/questions/23040428/error-no-module-named-cv2)
1.在demo.py
文件前加上:
import sys
sys.path.append('/opt/ros/hydro/lib/python2.7/dist-packages')
2.复制 cv2.so
到 sys.path
中的任何一个文件夹
#查看sys.path
python
>>>import sys
>>>>sys.path
我是把/usr/local/lib/python2.7/dist-packages/cv2.so
复制到/home/just/caffe/python
结果:(一开始没有图片显示,是因为我model下错了,注意一下)