Face Mask Dataset Training using YOLOv4
Figure 1 Training of custom detection model using YOLOv4
Figure 2 mAP (Mean Average Precision) chart
Figure 3 Performance checking of best-trained model (yolov4-custom_best.weights)
Figure 4 Predicted image using yolov4-custom_best.weights
Updated from previous training, YOLOv4 is used to train a custom face mask detection model. YOLOv4 is more suitable compared to YOLOv4 for real-time object detection as faster inference time is more important than accuracy.
Before dataset training, 1510 images with and without face masks are prepared and the images are then annotated with bounding boxes labeled with or without face masks on people's faces. After that, the values of batch is set to 64 and subdivisions is set to 64 in yolov4-custom.cfg file for training purpose. Figure 2 shows the mAP (Mean Average Precision) chart for the custom object detection model training. The higher the mAP, the better it is for object detection. The best model produces around 95.1% of mAP which is good for object detection. The next step is to test the best model with some images, videos and webcam. Figure 4 shows that the model is able to detect person with and without face masks.
Social Distancing Detection Model
Figure 1 Flow of social distancing detection model
Figure 1 shows the flow of social distancing detection model. The model is implemented based on the pre-trained YOLOv4 algorithm. The 'Person' class is first filtered out from the detections and the centroid of the bounding box is obtained. The Euclidean distance is then calculated between each bounding box. If the distance is less than the threshold (75.0 pixels), the box will be marked as red ('the person is at risk'). Or else, the box will be marked as green ('the person is safe').