Our Implemention

Data

The dataset [2] we used is from the internet, which includes images (different sizes) of both people wearing masks or not in two different folders(total 2166 images wearing masks, 1931 images not wearing masks). We also added many images with people wearing the mask properly or not in the wearing masks folder. Images that have people show their noses outside of the masks will be improperly wearing mask images. The sample dataset is provided below, which includes these three situations. Figure 11 is the sample image of people properly wearing masks, figure 12 is the sample image of people not wearing masks, and figure 13 is the sample image of people improperly wearing masks.

figure 11[2]

figure 12[2]

figure 13[2]

Methodology

Mask Detection: Neural Network

In our project, we use MobileNetV2 to train the model to recognize people wearing masks or not. We split the dataset by 80% for training and 20% for testing. The input tensor shape is 224x224x3. The first layer is an average Pooling 2D layer which is 7x7 size. Next, is a dense layer with 128 outputs with the Relu activation function. Then, a dropout layer with 0.5 inputs to prevent overfitting in this training process. Last, a final dense layer with 2 outputs with a softmax activation function. In this training, we set 15 epochs, the batch size is 32, and the initial learning rate is 1E-4. As we can see in figure 8, the training loss and accuracy plot, only we use 15 epochs, also has higher training accuracy and validation accuracy.


figure 14: training loss and accuracy

Effectiveness Check: Facial Landmark identification

We use pattern matching with Haar Cascade [5] to detect whether the nose is covered or not to check people wearing their masks properly or not. The nose has a specific shape, and we define its shape for pattern matching. There are still some limitations in this effectiveness check part. Facial landmark detection is not accurate when the head is turned to one side, and not enough dataset of people wearing masks improperly.