# Deep Learning-Based Automatic Safety Helmet Detection System for Construction Safety
## 4 Result and Discussion  
In this paper, for a comparative study of the YOLOv5x model, two other models, YOLOv3 and YOLOv4, were also implemented for safety helmet detection at the construction site. Figure 6 shows the confusion matrix, which proved the descent performance of the proposed computer vision model. Figure 7 shows the average precision (A.P.) of each class and the mAP for each model. YOLOv5x achieved the best mAP of 92.44%, followed by YOLOv4 (90.64%) and YOLOv3 (85.78), respectively. On the other hand, YOLOv3 showed a balanced performance in detecting both classes, \"Helmet\" and \"Head\", while YOLOv4 and YOLOv5x were relatively poor in detecting the \"Head\" class, especially the latter. Table 2 shows the detailed comparison between all three YOLO models trained on the Hard Hat detection dataset, depicting the mean and standard deviation (\(\mu\pm\sigma\)) of accuracy, precision, recall, and F-1 score, respectively. Figure 6: Confusion Matrix for Safety Helmet Detection using YOLOv5x. The YOLOv5x model showed higher accuracy, precision, recall, and F1 score value of almost 92%, 92%, 89%, and 91%, respectively, compared to YOLOv3 and YOLOv4, meaning that YOLOv5x performed best in detecting safety helmets. Furthermore, YOLOv4 and YOLOv5x showed significantly higher accuracy than YOLOv3, potentially due to the backbone feature layer. YOLOv4 and YOLOv5x use CSPDarknet53, and YOLOv3 uses Darknet53, which struggles when objects are small. Furthermore, YOLOv4 and YOLOv5x use mosaic data augmentation strategy internally [44], which also helped in improving their performance. Additionally, Table 3 compares all the above models on different metrics such as model weight, number of parameters, etc. Yolov5x uses CSPDarknet53 for feature extraction, which only extracts essential features from the image, followed by spatial pyramid pooling to avoid repeatedly computing the convolutional features. That is why YOLOv5x is the largest network with 86.7 million (M) parameters, and still has the lowest model weight of all three models. Figure 8 shows the loss vs. epochs curve on the training and validation dataset for YOLOv5x architecture. For the training process, the model runs for 50 epoch cycles with the patience value of 10 (complete 10 continuous epoch cycles without change in the loss by 0.01) to avoid the problem of overfitting. Figure 8a shows the loss curve for bounding box detection, Figure 8b shows the loss curve for class (Helmet and Head) detection, and 8c shows the loss curve for object detection. The loss curve for the training set is shown in Figure 8, which declines significantly at first and progressively converges as the number of \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Measure** & **YOLOv3 (\%)** & **YOLOv4 (\%)** & **YOLOv5x (\%)** \\ \hline
**Accuracy** & 82.12 \(\pm\) 0.12 & 87.77 \(\pm\) 0.14 & 92.00 \(\pm\) 0.21 \\
**Precision** & 85.78 \(\pm\) 0.28 & 90.63 \(\pm\) 0.10 & 92.44 \(\pm\) 0.11 \\
**Recall** & 81.87 \(\pm\) 0.17 & 86.78 \(\pm\) 0.21 & 89.24 \(\pm\) 0.28 \\
**F1 score** & 83.77 \(\pm\) 0.22 & 88.66 \(\pm\) 0.16 & 90.81 \(\pm\) 0.19 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Performance Assessment of YOLO models. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Model Weight (M.B.)** & **Parameters (M)** & **GFLOPs (B)** & **Latency (ms)** \\ \hline
**YOLOv3** & 212 & 63 & 157.3 & 11.78 \\
**YOLOv4** & 189 & 78.5 & 187.6 & 14.3 \\
**YOLOv5x** & 167 & 86.7 & 205.7 & 16.5 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Architectural Comparison between Different YOLO Models. Figure 7: Mean Average Precision for Each Model. epochs grows, which indicates that the model was evolving well in the training process. All the losses were almost less than 0.03, illustrating the decent performance of the YOLOv5x-based safety helmet detection model in low-light or when workers are at a considerably larger distance (resulting in small objects for detection). Figure 9 shows the prediction results with a confidence score for both classes.