You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.3 kB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <div align=center>
  2. <img src="http://affluent.oss-cn-hangzhou.aliyuncs.com/html/images/dface_logo.png" width="350">
  3. </div>
  4. -----------------
  5. # DFace • [![License](http://pic.dface.io/apache2.svg)](https://opensource.org/licenses/Apache-2.0)
  6. | **`Linux CPU`** | **`Linux GPU`** | **`Mac OS CPU`** | **`Windows CPU`** |
  7. |-----------------|---------------------|------------------|-------------------|
  8. | [![Build Status](http://pic.dface.io/pass.svg)](http://pic.dface.io/pass.svg) | [![Build Status](http://pic.dface.io/pass.svg)](http://pic.dface.io/pass.svg) | [![Build Status](http://pic.dface.io/pass.svg)](http://pic.dface.io/pass.svg) | [![Build Status](http://pic.dface.io/pass.svg)](http://pic.dface.io/pass.svg) |
  9. **基于多任务卷积网络(MTCNN)和Center-Loss的多人实时人脸检测和人脸识别系统。**
  10. [Github项目地址](https://github.com/kuaikuaikim/DFace)
  11. [Slack 聊天组](https://dfaceio.slack.com/)
  12. **DFace** 是个开源的深度学习人脸检测和人脸识别系统。所有功能都采用 **[pytorch](https://github.com/pytorch/pytorch)** 框架开发。pytorch是一个由facebook开发的深度学习框架,它包含了一些比较有趣的高级特性,例如自动求导,动态构图等。DFace天然的继承了这些优点,使得它的训练过程可以更加简单方便,并且实现的代码可以更加清晰易懂。
  13. DFace可以利用CUDA来支持GPU加速模式。我们建议尝试linux GPU这种模式,它几乎可以实现实时的效果。
  14. 所有的灵感都来源于学术界最近的一些研究成果,例如 [Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks](https://arxiv.org/abs/1604.02878) 和 [FaceNet: A Unified Embedding for Face Recognition and Clustering](https://arxiv.org/abs/1503.03832)
  15. **MTCNN 结构**  
  16. ![mtcnn](http://affluent.oss-cn-hangzhou.aliyuncs.com/html/images/mtcnn_st.png)
  17. ** 如果你对DFace感兴趣并且想参与到这个项目中, 以下TODO是一些需要实现的功能,我定期会更新,它会实时展示一些需要开发的清单。提交你的fork request,我会用issues来跟踪和反馈所有的问题。也可以加DFace的官方Q群 681403076 也可以加本人微信 jinkuaikuai005 **
  18. ### TODO(需要开发的功能)
  19. - 基于center loss 或者triplet loss原理开发人脸对比功能,模型采用ResNet inception v2. 该功能能够比较两张人脸图片的相似性。具体可以参考 [Paper](https://arxiv.org/abs/1503.03832)和[FaceNet](https://github.com/davidsandberg/facenet)
  20. - 反欺诈功能,根据光线,质地等人脸特性来防止照片攻击,视频攻击,回放攻击等。具体可参考LBP算法和SVM训练模型。
  21. - 3D人脸反欺诈。
  22. - mobile移植,根据ONNX标准把pytorch训练好的模型迁移到caffe2,一些numpy算法改用c++实现。
  23. - Tensor RT移植,高并发。
  24. - Docker支持,gpu版
  25. ## 安装
  26. DFace主要有两大模块,人脸检测和人脸识别。我会提供所有模型训练和运行的详细步骤。你首先需要构建一个pytorch和cv2的python环境,我推荐使用Anaconda来设置一个独立的虚拟环境。
  27. ### 依赖
  28. * cuda 8.0
  29. * anaconda
  30. * pytorch
  31. * torchvision
  32. * cv2
  33. * matplotlib
  34. ```shell
  35. git clone https://gitee.com/kuaikuaikim/dface.git
  36. ```
  37. 在这里我提供了一个anaconda的环境依赖文件environment.yml,它能方便你构建自己的虚拟环境。
  38. ```shell
  39. cd dface
  40. conda env create -f environment.yml
  41. ```
  42. 添加python搜索模块路径
  43. ```shell
  44. export PYTHONPATH=$PYTHONPATH:{your local DFace root path}
  45. ```
  46. ### 人脸识别和检测
  47. 如果你对mtcnn模型感兴趣,以下过程可能会帮助到你。
  48. #### 训练mtcnn模型
  49. MTCNN主要有三个网络,叫做**PNet**, **RNet** 和 **ONet**。因此我们的训练过程也需要分三步先后进行。为了更好的实现效果,当前被训练的网络都将依赖于上一个训练好的网络来生成数据。所有的人脸数据集都来自 **[WIDER FACE](http://mmlab.ie.cuhk.edu.hk/projects/WIDERFace/)** 和 **[CelebA](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html)**。WIDER FACE仅提供了大量的人脸边框定位数据,而CelebA包含了人脸关键点定位数据。以下训练除了 生成ONet的人脸关键点训练数据和标注文件 该步骤使用CelebA数据集,其他一律使用WIDER FACE。
  50. * 生成PNet训练数据和标注文件
  51. ```shell
  52. python src/prepare_data/gen_Pnet_train_data.py --dataset_path {your dataset path} --anno_file {your dataset original annotation path}
  53. ```
  54. * 乱序合并标注文件
  55. ```shell
  56. python src/prepare_data/assemble_pnet_imglist.py
  57. ```
  58. * 训练PNet模型
  59. ```shell
  60. python src/train_net/train_p_net.py
  61. ```
  62. * 生成RNet训练数据和标注文件
  63. ```shell
  64. python src/prepare_data/gen_Rnet_train_data.py --dataset_path {your dataset path} --anno_file {your dataset original annotation path} --pmodel_file {yout PNet model file trained before}
  65. ```
  66. * 乱序合并标注文件
  67. ```shell
  68. python src/prepare_data/assemble_rnet_imglist.py
  69. ```
  70. * 训练RNet模型
  71. ```shell
  72. python src/train_net/train_r_net.py
  73. ```
  74. * 生成ONet训练数据和标注文件
  75. ```shell
  76. python src/prepare_data/gen_Onet_train_data.py --dataset_path {your dataset path} --anno_file {your dataset original annotation path} --pmodel_file {yout PNet model file trained before} --rmodel_file {yout RNet model file trained before}
  77. ```
  78. * 生成ONet的人脸关键点训练数据和标注文件
  79. ```shell
  80. python src/prepare_data/gen_landmark_48.py
  81. ```
  82. * 乱序合并标注文件(包括人脸关键点)
  83. ```shell
  84. python src/prepare_data/assemble_onet_imglist.py
  85. ```
  86. * 训练ONet模型
  87. ```shell
  88. python src/train_net/train_o_net.py
  89. ```
  90. #### 测试人脸检测
  91. ```shell
  92. python test_image.py
  93. ```
  94. ### 人脸对比
  95. @TODO 根据center loss实现人脸识别
  96. ## 测试效果
  97. ![mtcnn](http://affluent.oss-cn-hangzhou.aliyuncs.com/html/images/dface_demoall.PNG)
  98. ### QQ交流群(模型获取请加群)
  99. #### 681403076
  100. ![](http://affluent.oss-cn-hangzhou.aliyuncs.com/html/images/dfaceqqsm.png)
  101. #### 本人微信
  102. ##### jinkuaikuai005
  103. ![](http://affluent.oss-cn-hangzhou.aliyuncs.com/html/images/perqr.jpg)
  104. ## License
  105. [Apache License 2.0](LICENSE)

开源的深度学习人脸检测和人脸识别系统。所有功能都采用 pytorch 框架开发。pytorch是一个由facebook开发的深度学习框架,它包含了一些比较有趣的高级特性,例如自动求导,动态构图等。DFace天然的继承了这些优点,使得它的训练过程可以更加简单方便,并且实现的代码可以更加清晰易懂