## 4 Model Training and Results
### Loss Function  
Three different parts form the Yolov5 loss function: object loss, bounding box loss, and class loss. These components are weighted and paired to create the final loss function and can be seen in Equation (10).  
\[LOSS=a\cdot LOSS_{object}+b\cdot LOSS_{B.box}+c\cdot LOSS_{class} \tag{10}\]  
The weights assigned to the loss function are represented by \(a\), \(b\), and \(c\). Typically, object loss is given the highest weight, followed by bounding box loss and class loss.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **Precision** & **Recall** & **mAP** & **mAP** \\  & & & **@0.5** & **0.50.95** \\ \hline Yolov51\_SGD & 0.890 & 0.885 & 0.912 & 0.863 \\ Yolov51\_ADAM & 0.911 & 0.880 & 0.912 & 0.864 \\ Yolov52\_SGD & 0.896 & 0.889 & 0.917 & 0.874 \\ Yolov52\_ADAM & 0.901 & 0.891 & 0.919 & 0.868 \\ Yolov5\_tr\_SGD & 0.931 & 0.892 & 0.921 & 0.873 \\ Yolov51\_tr\_ADAM & 0.934 & 0.895 & 0.927 & 0.878 \\ Yolov7 & 0.898 & 0.839 & 0.884 & 0.811 \\ Yolov8 & 0.919 & 0.887 & 0.914 & 0.877 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Overall training results for all the models. The proposed model performed better during the training process, whereas Yolov5x slightly improved with the ADAM optimizer. Yolov7 recall dropped the most compared to other models.  
Figure 5: All models’ training results after every epoch. Proposed model precision during training peaked at 0.934 along with a recall of 0.895, where average precision at 0.5 and 0.50.95 thresholds peaked at 0.927 and 0.878, respectively.  
Equation (11) shows the two cross-entropy losses, which are class loss and object loss.  
\[LOSS_{CLASS,OBJECT}=-\frac{1}{n}\sum_{I=1}^{n}Y_{I}\cdot Log(P(Y_{i}))+(1-Y_{i}) \times Log(1-P(Y_{i})) \tag{11}\]  
where the total number of categories is (\(n\)), true value is referred to as \(Y_{i}\), and predicted probability is \(P(Y_{i})\).  
The model's predicted result and the true value are compared using binary cross-entropy. The loss function value will be closer to zero if the predicted value is nearer to 1, meaning that the loss function value decreases as the gap between the expected result and the actual value reduces. On the other hand, if the predicted value moves nearer to 0, the gap between the true value and the predicted result will be greater so that the loss function value will be higher.  
We calculated the losses using Equation (11) during the training, where we have seen all the models' losses (object loss, bounding box loss, and class loss) decreased gradually, apart from the bounding box loss of Yolov5l and Yolov5x with the SGD optimizer, which moderately decreased from 0.04 to 0.02 initially, but between the 40 th epoch and the 110 th epoch, it increased and did not converge relatively as expected. The object loss of our proposed model with the ADAM optimizer as well as the Yolov7 model instantly decreased to 0.005 after 10 epochs, which later ended up at 0.003--far better than the other models' during training--whereas during validation, different models have shown different convergence rates, where the class loss decreased gradually while box loss and object loss decreased until the 100 th epoch and later settled with same rate until the end, which can be seen in Figure 6.