-
Overview of Project
-
Data Description
-
Libraries used
-
Structure of the Approach
-
How to implement on your computer
We need to implement a face mask detector which detects whether a person is wearing a mask or not. This will be done for a video and an image
For this project , I will be using the data from a git hub repository by Prajna Bhandary images_dataset.
Total number of images in dataset : 1376
Number of images in train set : 690
Number of images in test set : 686
-
Numpy
-
Matplotlib
-
Tensorflow
-
Keras
-
OpenCV
-
os module of python
-
sklearn
-
imutils
Firstly , we load the data set by accessing directories using the os module. Then after loading the image , we convert to to array using img_to_array. We then perform one hot encoding then split it into train and test sets. Now since our train set is very small, we augment the size of train set by applying transformations like rotation, shifting etc. Then we perform transfer learning by loading a MobileNetV2 network and make changes ensuring the head FC layer sets are left off. We then train the model , save it and see the performace
We load our pre trained model, then we load the image in which we need to detect, then we apply certain transformations to the input image and then load it into the model. On running the cells, we get an image with detection of wearing or not wearing the mask
We define a function that extracts blobs from the face. Then we perform resizing to the frame store 3 values faces,locs ,preds. Then we load our model and using imutils have a video stream wherein our previously defined function extracts every frame and predicts where the face is and then tell whether a person is wearing a mask or not.
Download the zip file of the repo. Then if you want to implement mask detector in image, open the detecting_mask_in_image.ipynb file, change the paths in the 2nd cell according to the path where you have downloaded the files . The path should correspond to the prototxt and resnet model file. Then in the 4th cell, change the "withmask.jpg" to the image file on which you want to perform the operation. Then you are good to go, just run all the cells
For video, just change the path in the 3rd cell corresponding the path where you store the prototext and resnet model file. After that just run the cells