Background - One of the tasks for Computer Vision internship at The Sparks Foundation.
Face Mask Detection project by classification of with_mask
& without_mask
classes is using TensorFlow, Keras and transfer learning with MobileNetV2 DNN architecture having weights of pre-trained on the imagenet
. Training for the model and the dataset of this project is done on free GPU of GoogleColab notebook.
Phase:1 - Train Face Mask Detector
- Load Face Mask Dataset
- Train Face Mask Classifier with Keras/TensorFlow and using Transfer Learning with MobileNetV2 as baseModel
- Serialize trained face mask classification model to disk
Phase:2 - Apply Face Mask Detector
- Load face mask classification model from disk
- Detect faces in image/videostream
- Extract each face ROI
- Apply face mask classifier to each face ROI to determine "mask" or "no mask"
- Save/Show the result
Check the package manager, conda which will be required to install required libraries & packages under specific virtual environment. Install anaconda on your machine, and run the following cell on terminal/command prompt after installed.
conda create -n FaceMaskDetector jupyter tensorflow keras python opencv imutils scipy numpy pandas matplotlib
MobileNetV2 BaseModel
-> Average Pooling
-> Flatten
-> Dense
-> Dropout
-> Dense
- Transfer Learning with
MobileNetV2
with weights of pretrained onimagenet
- Average Pooling with
pool_size=(7, 7)
flatten
into vector- Dense layer with
units=128
andactivation='relu'
- Dropout 50%/
0.5
of neurons - Final Dense layer with
units=2
andactivation='softmax'
learning_rate
with1e-4
& usingadam
optimizer &loss
withbinary_crossentropy
&metric
with["accuracy"]
- Train with
DataAugmentation
for better accuracy &batch_size
with32
&epochs
with20