ubuntu 上运行 py-faster-rcnn


最近在研究行人检测,看到faster-rcnn的介绍,准确度挺高,试运行作者的代码:https://github.com/rbgirshick/fast-rcnn, 过程中遇到一些问题,特此记录:

1.  按照Caffe installation instructions(http://caffe.berkeleyvision.org/installation.html)配置 caffe 环境。

    另外需要安装Python安装包:cython,python-opencv,easydict:

  sudo apt-get install python-pip    #  python包管理器pip
  sudo pip install cython
  sudo pip install python-opencv
  sudo pip install easydict

2. 下载源代码:

  # Make sure to clone with --recursive
  git clone --recursive https://github.com/rbgirshick/fast-rcnn.git
    注:不要自己去下载, 不然要多做一些工作(见readme中Installation 2)

    下载完成后将文件夹重命名为 FRCN_ROOT

3. 生成Cython模块

   将第1步配置好的 Makefile.config 复制到 FRCN_ROOT/caffe-fast-rcnn中,注意修改:

 # In your Makefile.config, make sure to have these line uncommented
 USE_CUDNN := 1   
 BLAS := mkl
 WITH_PYTHON_LAYER := 1

  修改完成后:

 cd FRCN_ROOT/lib
 make
  但是很不幸的出现以下错误:

 c++: error: unrecgnized command line option '-fstack -protector -strong'
 c++: error: unrecgnized command line option '-fstack -protector -strong'
 error: command 'c++' failed with exit status 1
 Makefile:2: recipe for target 'all' failed
 make: *** [all] Error 1

  原因是gcc版本不符合,faster rcnn编译的gcc版本必须是4.9,而我的版本是4.7,所以需升级gcc

 cd /usr/bin
 sudo rm gcc 
 sudo ln -s gcc-4.9 gcc
 sudo rm g++ 
 sudo ln -s g++-4.9 g++
  之后就不会有问题了。

4.  生成 Caffe 和 pycaffe

  cd FRCN_ROOT/caffe-fast-rcnn 
  make -j8 && make pycaffe

5. 下载 Fast R-CNN 检测器   

  cd FRCN_ROOT
  ./data/scripts/fetch_fast_rcnn_models.sh
 不过下载速度很慢,个人建议自行下载,然后解压放在  FRCN_ROOT/data中。

6. 运行demo

  cd FRCN_ROOT
  ./tools/demo.py
  完成,结果例下图:

 


你可能感兴趣的:(检测)