This is a project using Multi-task Cascaded Convolutional Networks (MTCNN) for face counting. The test passed in the Anaconda python 3.10 environment of macos and windows.
PNet, RNet, and ONet are key components of the Multi-task Cascaded Convolutional Networks (MTCNN), playing a crucial role in face detection and alignment.
- PNet (Proposal Network): PNet is the first stage of MTCNN. It is a fully convolutional network used for obtaining candidate windows and bounding box regression vectors. It generates candidate windows by sliding a small window across the input image.
- RNet (Refine Network): RNet is the second stage of MTCNN. It takes the output of PNet (candidate windows) as input and further eliminates false windows while performing a more precise bounding box regression on the remaining windows.
- ONet (Output Network): ONet is the third stage of MTCNN. It not only performs tasks similar to RNet (i.e., further eliminating false windows and performing more precise bounding box regression), but also predicts facial landmarks for the detected faces.
In our project , these networks are used for detecting faces in images. Firstly, PNet generates candidate windows in the image, then RNet further refines these windows, and finally, ONet determines the final face detection results and predicts facial landmarks. This process effectively detects all faces in the image, thereby achieving the goal of face counting.
First, install the Anaconda python 3.10 environment: slightly
Then, you need to clone this repository:
git clone https://github.com/tongzm/face_counter_private.gitFinally, you need to install the project's dependencies:
pip install -r requirements.txtYou can use this program with the following command:
python script.py /path/to/your/image.jpgYou need to replace /path/to/your/image.jpg with the actual path to your image file. You can also pass the path to a folder as an argument, and the program will process all .jpg and .png images in the folder:
python script.py /path/to/your/images/If you want to output evaluation metrics, please add the actual number of faces and "_" as the delimiter at the beginning of the image file name, such as: "7_image.jpg", and then add the --eval parameter.
python script.py /path/to/your/7_image.jpg --evalYou need to replace /path/to/your/7_image.jpg with the actual path to your image file
We use mean absolute percentage error(MAPE), Mean absolute error(MAE), root-mean-square-error-rmse(RMSE), R2 Score as evaluation metrics
You can run unit tests with the following command:
python -m unittest test.py