热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

FaceDetectionwiththeFasterR-CNN(基于FasterRCNN的人脸检测)

1.GitHubhttps:github.complayerkkface-py-faster-rcnn2.RequirementsRequirements:sof

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

  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. 下载测试数据
    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. 自己训练模型
  1. Download pre-computed Faster R-CNN detectors
    cd $FRCN_ROOT
    ./data/scripts/fetch_faster_rcnn_models.sh

  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 FRCNROOT/datalns WIDER WIDER

  5. Follow the next sections to download pre-trained ImageNet models
    cd $FRCN_ROOT
    ./data/scripts/fetch_imagenet_models.sh

  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
    cd FRCN_ROOT
    ./experiments/scripts/faster_rcnn_end2end.sh [GPU_ID] [NET] wider [–set …]

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

  7. 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


推荐阅读
author-avatar
球之音_970
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有