## 3 Results and Discussion
### Implementation, Optimization, Debugging, and Testing of the Algorithm Using the CNN YOLOv5s  
The YOLOv5s loss function consists of three parts (Figure 5):  
- box_loss--loss of regression of the bounding box (root mean square error);  
- obj_loss--confidence in the presence of an object is a loss of objectivity;  
- cls_loss--classification loss (Cross Entropy). Mean Average Precision (mAP) is used to evaluate computer vision models; to calculate it, you must first determine the Precision (P), Recall (R), and Average Precision (AP) indicators. Calculation of P and R values is carried out according to the formulas:  
\[\text{Precision (P)}=\text{TP / (TP+FP)} \tag{1}\]  
\[\text{Recall (R)}=\text{TP / (TP+FN)}, \tag{2}\]  
\"here true positive (TP) is the correct detection made by the model; false positive (FP) is incorrect detection made by the detector; false negative (FN) is a true result missed (not detected) by the detector\" [7]. An auxiliary metric Intersection over Union (IoU) is used to determine AP. IoU shows how much our predicted boundary overlaps with the true (real object boundary). Figure 6 schematically shows the calculation of IoU where the intersection area is divided by the area of the union of the true and predicted frames. Figure 5: Loss functions. The area of intersection of the regions in Figure 6 is divided by the area of the union between the true and predicted frames. The IoU metric, also known as the Jaccard index, is a number from zero to one that shows how much two objects (reference and predicted by the neural network) have the same internal \"volume\". AP@\(\alpha\) is an area under Precision-Recall Curve (AUC-PR) that is estimated at threshold \(\alpha\) IoU. The formula for the calculation is as follows:  
\[\text{AP@}\alpha=\int\limits_{0}^{1}\text{P}(\text{R})\,dr \tag{3}\]  
Mean Average Precision (mAP) is equal to the average of Average Precision over all classes in the model. Table 2 estimates mAP for the test set, averaged over IoU \(\in\) [0.50:0.95] (standard COCO metric) and mAP0.50 (PASCAL VOC metric). It is worth noting that the \"broken corners\" and \"inclusion\" classes are defined less precisely than the \"cracks\" and \"rust\" classes. This is due to the geometric parameters of the defects themselves: cracks and rust spots are most noticeable to the expert at the marking stage and, hence, to the detector. Smaller defects of the \"inclusion\" type can be missed by a specialist when marking, and therefore will not be taken into account in the process of training a neural network, which entails a decrease in accuracy when this class is detected. Careful markup of these objects is required, and was performed. The effect of interference was taken into account in the process of data augmentation by changing the brightness, contrast, and saturation of images. Figure 7 shows the Confusion Matrix, which is a classification performance metric. \begin{table}
\begin{tabular}{c c c c c} \hline
**Num** & **Parameter** & **Instances** & **mAP0.50** & **mAP0.50:0.95** \\ \hline
1 & all & 825 & 0.87 & 0.72 \\ \hline
2 & broken corners & 98 & 0.84 & 0.68 \\ \hline
3 & cracks & 106 & 0.89 & 0.84 \\ \hline
4 & inclusion & 61 & 0.86 & 0.60 \\ \hline
5 & rust & 560 & 0.88 & 0.77 \\ \hline \end{tabular}
\end{table} 
Table 2: Model Quality Estimates. Figure 6: Computing Intersection over Union. Figure 8 shows the results of the developed algorithm. The model shows bounding boxes indicating the predicted feature class and how confident the network is in its prediction. Figure 8: _Cont._  
Figure 7: Confusion Matrix. The results show that the detector detects and classifies defects in photographs subjected to changes during the augmentation process, namely, changing lighting conditions and shooting angles: Figure 8a,c is shifted along the OX axis, Figure 8e is changed brightness. Thus, various survey factors are taken into account in the learning process, and they do not reduce the efficiency of the detection algorithm.