代码:https://github.com/rbgirshick/py-faster-rcnn.git
Installation (sufficient for the demo)
0.可能需要Python安装包:cython,python-opencv,easydict
先装一个python包管理器pip:
sudo apt-get install python-pip
再安装那三个包
sudo pip install cython
sudo apt-get install python-opencv (进入python,import cv2可看到是否安装成功)
sudo pip install easydict
1.从git clone faster r-cnn
git clone –recursive https://github.com/rbgirshick/py-faster-rcnn.git
2.cd 到py-faster-rcnn/lib (rbg的第二步不用管,本文中,依然使用py-faster-rcnn而没用FRCN_ROOT)
make
3.Download pre-computed Faster R-CNN detectors(rbg的那个步骤4,在已经安装了caffe的情况下,不用再做)
cd $FRCN_ROOT
./data/scripts/fetch_faster_rcnn_models.sh
Demo
#After successfully completing basic installation, you’ll be ready to run the demo.
cd $FRCN_ROOT
./tools/demo.py
出现错误:
import error no module named _caffe。(在caffe-master下的py-faster-rcnn下执行./tools/demo.py,而不是和caffe-master并列的那个)
解决方法:
#回到caffe-master
make distribute
#make dir for custom python modules, install caffe
mkdir ~/python
mv distribute/python/caffe ~/python
#set PYTHONPATH (this should go in your .bashrc or whatever
#回到用户主目录,
export PYTHONPATH = $PYTHONPATH:~/caffe-master/python/caffe
source ~/.bashrc
出现错误:
importERROR no module named skimage.io
解决方法:
#直接使用终端安装:
#回到用户主目录
pip install -U scikit-image (过程漫长)
出现错误:
imortERROR:no module named google.protobuf.internal
解决方法:
sudo apt-get install python-protobuf
出现错误:
ImportERROR: no module named gpu_nms
解决方法:
在py-faster-rcnn的lib中make
出现错误:
ImportERROR:no module named _tkinter,please install the python-tk package
解决方法:
sudo apt-get install python-tk
出现错误:
Check failed:ReadProtorFromTextFile(param_file,param) failed to parse NetParameter file: / home/meng/caffe-master/py-faster-rcn/models/pascal_voc/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt
***Check failure stack trace***
1.编译/py-faster-rcnn/caffe-fast-rcnn
cd py-faster-rcnn/caffe-fast-rcnn
cp Makefile.config.example Makefile.config
更改Makefile.config文件:
#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
#配置一些引用文件(增加部分主要是解决新版本下,HDF5的路径问题)
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
#启用Intel Parallel Studio XE 2016
BLAS := mkl
#配置路径,实现caffe对Python接口的支持
PYTHON_LIB := /usr/local/lib
#启用OpenCV 3.0, 去掉”#”
OPENCV_VERSION =3
进行编译:
make -j8 && make pycaffe
因为这个版本所用的cudnn为旧版本的,可能与新环境的cudnn不兼容,导致出现如下错误:
make: * [.build_release/src/caffe/util/db.o] Error 1 (可能是这个,类似吧,有点乱。)
解决办法:
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里的相应的同名文件。
再次make -j8 && make pycaffe
会遇到错误:
make: * [.build_release/src/caffe/layers/cudnn_relu_layer.o] 错误 1
解决方法:
将/py-faster-rcnn/caffe-fast-rcnn/include/caffe/layers的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp,cudnn_lcn_laye.hpp
遇到错误:
ImportError:no module named yaml
解决方法:
sudo apt-get install python-yaml
遇到错误:
“/home/meng/.local/lib/python2.7/site-packages/matplot
file “/usr/lib/python2.7/lib-tk/Tkinter.py”
self.tk = _tkinter.create(screenName,baseName,className,interative,wantobjexts.useTk,sync,use)
_tkinter.TclError: no display name and no $DISPALY environment variable
解决方法:
这错误是因为用putty远程登陆导致的,那个窗口弹不出来。给windows装个Xming吧。
2.运行faster-rcnn里的demo
cd py-faster-rcnn/tools
./tools/demo.py