天天看点

Face Faster RCNN安装步骤和遇到的问题 1.安装 2.测试模型在FDDB上 3:训练模型VGG和ZF模型

1.安装

  1. Clone the face Faster R-CNN repository 

    Git clone –recursive https://github.com/playerkk/face-py-faster-rcnn.git

  2. Build the Cython modules 

    cd $FRCN_ROOT/lib 

    make

  3. Build Caffe and pycaffe 

    cd $FRCN_ROOT/caffe-fast-rcnn 

    make -j8 && make pycaffe

  4. 下载预先训练好的VGG模型 

    A pre-trained face detection model trained on the WIDER training set is available here. 

    http://supermoe.cs.umass.edu/%7Ehzjiang/data/vgg16_faster_rcnn_iter_80000.caffemodel 

    放置目录: 

    $FRCN_ROOT/output/faster_rcnn_end2end/train/vgg16_faster_rcnn_iter_80000.caffemodel

  5. 下载测试数据 

    下载FDDB数据库放入$FRCN_ROOT/data目录: 

    包括: 

    FDDB 

    FDDB/FDDB-folds 

    FDDB/originalPics

2.测试模型在FDDB上

python ./tools/run_face_detection_on_fddb.py --gpu=0 

遇到的问题:

1:安装 Cython,python-opencv,easydict;不然会提示安装出错的;

可以直接下载easydict,然后tar -zxvf easydict.1.7.0.tar.gz; cd easydict.1.7.0; python setup.py  install

解决即可正常的运行:

2:caffe设置的问题

1配置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 #可以注释掉的
           

3:训练模型VGG和ZF模型

  1. Download pre-computed Faster R-CNN detectors 

    cd $FRCN_ROOT 

    ./data/scripts/fetch_faster_rcnn_models.sh  //也可官网上下载相应的faster_rcnn_models.tgz;然后自己解压;

  2. Download the WIDER face dataset. Extract all files into one directory named WIDER 

    http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/ 

    WIDER/ 

    WIDER/WIDER_train/ 

    WIDER/WIDER_val/

  3. Download the (http://jianghz.me/files/wider_face_train_annot.txt) and put it under the WIDER directory.
  4. Create symlinks for the WIDER dataset 

    cd $FRCN_ROOT   ln -s $WIDER ~/WIDER                          //WIDER在home目录下

  5. Follow the next sections to download pre-trained ImageNet models 

    cd $FRCN_ROOT 

    ./data/scripts/fetch_imagenet_models.sh //也可官网上下载相应的imagenet_models.tgz;然后自己解压;

  6. To train a Faster R-CNN face detector using the approximate joint training method, use experiments/scripts/faster_rcnn_end2end.sh. Output is written underneath $FRCN_ROOT/output.

    cd FRCN_ROOT 

    ./experiments/scripts/faster_rcnn_end2end.sh [GPU_ID] [NET] wider [–set …]

    eg: 

    ./experiments/scripts/faster_rcnn_end2end.sh 0 VGG16 wider

遇到的问题:

第一个问题:TypeError: slice indices must be integers or None or have an index method

这是由于numpy的版本太高,numpy 1.12.0对这个做了些调整,把numpy降级到1.11.0就行了。

sudo pip install -U numpy==1.11.0

同时也可以下载numpy.1.11.0,自己安装一下;就可以跟新到1.11.0版本;

但是我的服务器中有两个python,2.7和3.4,而系统默认pip是装在python3.4上的,这样可以看见:

输入:pip --version

显示:pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)

所以执行以下代码,装到强制装到python2.7中:

sudo python2.7 /usr/local/bin/pip install -U numpy==1.11.0

至此py-faster-rcnn在我这儿可以顺利训练了:

第二个问题:提示找不到图片的问题

主要是数据集的图片路径最后会多一个\r,这都是英文下载的图片标签windows下和Linux下多一个换行符的问题;

提取钱len-1个字符就可以了,可以在face.py中修改image_name这个字符串;

参考博客:http://blog.csdn.net/zengdong_1991/article/details/66475821

继续阅读