Deep neural network model developed in colab with @Lemonzino as our Machine Learning course project at Alma Mater Studiorum University. This model is able to recognize the presence of a face in a pic and guess the area of photo in which it is.
The final model is a parallel Convolutional Neural Network composed by two submodules:
- Face presence classifier;
- Face area detector;
This submodel has the duty to classify if there is a face or not in the examined pic.
The classification is a real number in range [0,1]
and the confidence that i chosen for this detector >= 0.5
.
This model is composed by a CNN followed by a layer dense to solve the classification task.
This model is a TF model, that use MobileNetV2 architecture pretrained with image-net.
It was trained using two datasets:
This submodel is a regressor that guess a rectangle in the photo that contains an eventual face.
The guess has the following format:
[x_top_left, y_top_left, width, height]
This model was built using a Fully Convolution approach.
This model is a TF model, that use MobileNetV2 architecture pretrained with image-net.
It was trained using a single dataset:
- Support for tensorflow GPU (this should probably work on tensorflow CPU too, but not tested);
- Python 3.6 or greater;
- All pip packages listed in requirements.
After you got a camera you only need to access the root project directory and launch
python webcam_face_detector.py
.
You only need to access the root project directory and launch:
python image_face_detector.py input_image_path outputdir
.
The classifier submodel hasn't a great accuracy because of the low variation of faces that were feed to it in training phase.
Indeed you can test the model without the classifier by simply commenting and moving a few lines of code in
webcam_face_detector.py
or in input_image_path
and you should see a greater performance in detection.
The future improvement is to repeate the classifier training with an increased dataset that contains a greater variation in faces position and orientation.