# MTCNN
`PyTorch` implementation of **inference stage** of face detection algorithm described in
[Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks](https://arxiv.org/abs/1604.02878).

## Why this projects
[mtcnn-pytorch](https://github.com/TropComplique/mtcnn-pytorch) This is the most popular pytorch implementation of mtcnn. There are some disadvantages I found when using it for real-time detection task.
* Mix torch operation and numpy operation together, which resulting in slow inference speed (Cannot run on GPU).
* Based on the old version of pytorch (0.2).
So I create this project and make some improvments:
* Transfer all numpy operation to torch operation, so that it can benefit from GPU acceleration.
* Automatic run on 'CPU' or 'GPU'.
* Based on the latest version of pytorch (1.3)
* Real-time face tracking
## Installation
1. Create virtual environment
```
# conda create -n face_detection
```
2. Activate virtual environment
```
# source activate face_detection
```
3. [Install PyTorch](https://pytorch.org/)
```
(face_detection)# conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
```
4. Install Jupyter Notebook
```
(face_detection)# conda install jupyter notebook
```
5. Install `opencv`
```
(face_detection)# pip install opencv-python
```
## How to use it
Just download the repository and then do this
```
import sys
import os
sys.path.append(os.pardir)
from importlib import import_module
import cv2
from src.detect import FaceDetector
# import camera driver
if os.environ.get('CAMERA'):
Camera = import_module('camera_' + os.environ['CAMERA']).Camera
else:
from camera import Camera
if __name__ == "__main__":
detector = FaceDetector()
while True:
frame = Camera().get_frame()
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
bounding_boxes = detector.detect(image)
for i in range(len(bounding_boxes)):
cv2.rectangle(frame, (int(bounding_boxes[i][0]), int(bounding_boxes[i][1])),
(int(bounding_boxes[i][2]), int(bounding_boxes[i][3])), (255, 0, 0), 2)
cv2.imshow('capture', frame)
key = cv2.waitKey(1)
if key & 0xFF == ord('q'):
break
```
or just run:
```
(face_detection)# cd MTCNN_face_detection_alignment_pytorch/src/
(face_detection)# CAMERA=opencv python test.py
```
## Tutorial
[Detect step by step](./notebooks/try_mtcnn_step_by_step.ipynb)
## Credit
This implementation is heavily inspired by:
* [TropComplique/mtcnn-pytorch](https://github.com/TropComplique/mtcnn-pytorch)
* [faciallab/FaceDetector](https://github.com/faciallab/FaceDetector)
## Citation
```
@article{7553523,
author={K. Zhang and Z. Zhang and Z. Li and Y. Qiao},
journal={IEEE Signal Processing Letters},
title={Joint Face Detection and Alignment Using Multitask Cascaded Convolutional Networks},
year={2016},
volume={23},
number={10},
pages={1499-1503},
keywords={Benchmark testing;Computer architecture;Convolution;Detectors;Face;Face detection;Training;Cascaded convolutional neural network (CNN);face alignment;face detection},
doi={10.1109/LSP.2016.2603342},
ISSN={1070-9908},
month={Oct}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
具体环境安装操作流程可看链接:https://pan.baidu.com/s/1Q7V2Fz_cv4Sjsam_tbRD4g?pwd=bing 提取码:bing 基于python的flask工具构建服务端,进行3D姿态和人脸关键点相关推断计算,然后在unity构建卡通角色的人脸和人体的驱动客户端。博客可见https://blog.csdn.net/zb1165048017/article/details/109834126 注意先运行server文件夹下的run_server.bat,相关python环境请自行安装。然后再在unity中打开firstscene客户端。
资源推荐
资源详情
资源评论











收起资源包目录





































































































共 5617 条
- 1
- 2
- 3
- 4
- 5
- 6
- 57

风翼冰舟
- 粉丝: 2399
- 资源: 56

下载权益

C知道特权

VIP文章

课程特权

开通VIP
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
- 3
- 4
- 5
- 6
前往页