您的位置:首页 > 其它

Face Detection with the Faster R-CNN (基于Faster RCNN的人脸检测)

2017-03-26 15:23 525 查看

1. GitHub

https://github.com/playerkk/face-py-faster-rcnn

2. Requirements

Requirements: software

Requirements for caffe and pycaffe (see: Caffe installation instructions)

Python packages you might not have: cython, python-opencv, easydict


Requirements: hardware

For training smaller networks (ZF, VGG_CNN_M_1024) a good GPU (e.g., Titan, K20, K40, ...) with at least 3G of memory suffices
For training Fast R-CNN with VGG16, you'll need a K40 (~11G of memory)
For training the end-to-end version of Faster R-CNN with VGG16, 3G of GPU memory is sufficient (using CUDNN)


3. Installation

Clone the face Faster R-CNN repository

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

Build the Cython modules

cd $FRCN_ROOT/lib

make

Build Caffe and pycaffe

cd $FRCN_ROOT/caffe-fast-rcnn

make -j8 && make pycaffe

下载预先训练好的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

下载测试数据

http://vis-www.cs.umass.edu/fddb/index.html 下载FDDB数据库放入$FRCN_ROOT/data目录:

包括:

FDDB

FDDB/FDDB-folds

FDDB/originalPics

4.Test the trained model

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

运行完成后显示:



十组图片,每检测完11张图片显示完成度 XX%

在run_face_detection_on_fddb.py 添加保存图片的命令

# for j in xrange(dets.shape[0]): 下面添加以下代码
p1 = (int(dets[j, 0]), int(dets[j, 1]))
p2 = (int(dets[j, 0] + dets[j, 2]), int(dets[j, 1] + dets[j, 3]))
cv2.rectangle(im, p1, p2, (0, 0, 255))
cv2.imwrite("/home/dl/faceBox.jpg", im)


效果:







5. 自己训练模型

Download pre-computed Faster R-CNN detectors

cd $FRCN_ROOT

./data/scripts/fetch_faster_rcnn_models.sh

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/

Download the (http://jianghz.me/files/wider_face_train_annot.txt) and put it under the WIDER directory.

Create symlinks for the WIDER dataset

cd FRCNROOT/dataln−sWIDER WIDER

Follow the next sections to download pre-trained ImageNet models

cd $FRCN_ROOT

./data/scripts/fetch_imagenet_models.sh

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

cd FRCN_ROOT

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

eg:

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

Trained Fast R-CNN networks are saved under: (GTX980训练了10多个小时)

output/ experiment directory / dataset name /



6. 遇到的问题

http://blog.csdn.net/zengdong_1991/article/details/51614315
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐