PyTorch implementation of Multi Task CNN paper for face detection.
The algorithm performs 3 stage detection process. Each stage uses different CNN, therefore this detection system is represented as a cascade system of three CNNs.
- First CNN: P-Net (Proposal Network) produces initial guesses (candidates) for bounding boxes of faces, along with probabilities that those boxes contain a face. Some of the proposed candidates are rejected due to probability threshold and NMS. Bounding boxes are calibrated
- Second CNN: R-Net (Refinement Network) refines former candidates in order to get a better estimate. Some of the proposed candidates are rejected due to probability threshold and NMS. Bounding boxes are calibrated
- Third CNN: O-net (Output Network) outputs final estimates of bounding boxes and according facial landmark positions
CNNs are pretrained and used as such. This repo is an implementation of Zhang's work. The weights can be found in the pretrained weights folder.
- Open Anaconda Prompt and navigate to the directory of this repo by using:
cd PATH_TO_THIS_REPO
- Execute
conda env create -f environment.yml
This will set up an environment with all necessary dependencies. - Activate previously created environment by executing:
conda activate mtcnn-pytorch
- Start the main script for face detection:
python src/main.py --img_loc PATH_TO_IMAGE
or just executepython src/main.py
and use default locations for image. Default location is: imgs/girls.jpg
This repo is heavily inspired by these two repositories: