# A Fitting Recognition Approach Combining Depth-Attention YOLOv5 and Prior Synthetic Dataset
## 5 Experiments and Results
### Test Field Experiment
#### 5.1.3 Comparison between YOLOv5s and Our Proposed Method  
The mAP is used as a metric for recognition accuracy, which is the average of average precisions (APs) with IoU thresholds greater than a setting threshold. COCO's mAP recognition standard is mAP5095 (average mAP on step size 0.05 for thresholds from 0.5 to 0.95). The \(AP\) is calculated by precision (\(P\)) and recall (\(R\)) as:  
\[AP=\int_{0}^{1}P(R)\mathrm{d}R \tag{8}\]  
Figure 14: Loss and mAP during training of YOLOv5 model in the test field experiments.  
Figure 13: Example of the dataset.  
The \(P\) and \(R\) are:  
\[P=\frac{TP}{FP+TP} \tag{9}\]  
\[R=\frac{TP}{FN+TP} \tag{10}\]  
True positive \(TP\) means the content in the bounding box predicted by the model is the insulators, and the result is correct. False positive \(FP\) means the content in the bounding box predicted by the model is the insulators, and the result is false. True negative \(TN\) means the content in the bounding box predicted by the model is not the insulators, and the result is correct. False negative \(FN\) means the insulator is not recognized.  
Table 3 compares the results of the standard YOLOv5 model and the depth-attention YOLOv5 model with \(D_{\alpha}=3\) and \(D_{\beta}=-6\) on the test dataset. It can be seen that depth-attention improves the mAP5095 of the YOLOv5 model by 5.2%, and inference speed is only 3.1 s slower, verifying the feasibility of the depth-attention.  
To further elaborate the process of depth-attention to improve accuracy, we analyzed the last layer's feature maps. Figure 15a is the input image of the test dataset. Figure 15b-d visualize the depth-attention matrix, \(g(x)\), with the same size as the feature maps of the last layer, and the brightness is the value of \(g(x)\). Figure 15e,f show the feature heat map of the last layer at the standard YOLOv5 inference, including both correct and false inferences. Figure 15g,h are the feature heat map at the depth-attentionYOLOv5 inference. Comparing Figure 15f,g, the weight of the misdetection is reduced by depth-attention. Figure 16 shows more understandable inference results: YOLOv5 falsely recognized the class NLD, and depth-attention reduced the confidence of false recognition and improved the confidence of correct recognition of XG. The results indicate that the depth-attention mechanism could improve the accuracy of recognizing fittings and reduce the probability of misdetection.  
Figure 15: Visualization of feature maps and depth-attention matrices. (**a**) Input image of the test dataset. Depth-attention matrix, \(g(x)\), on the feature map of the last layer: (**b**) \(g(x)\) of large target recognition, (**c**) \(g(x)\) of medium target recognition, (**d**) \(g(x)\) of small target recognition. Feature heat map of the last layer at the standard YOLOv5 inference: (**e**) correct inference, (**f**) false inference. Feature heat map of the last layer at the depth-attention YOLOv5 inference: (**g**) correct inference, (**h**) false inference.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **Fitting** & **mAP 50(\%)** & **mAP 5095(\%)** & **P** & **R** & **Inference Speed (ms)** \\ \hline YOLOv5 & XG & 96\% & 62.9\% & 0.942 & 0.935 & 7.9 \\ Depth-attention & XG & 99\% & 68.1\% & 0.983 & 0.983 & 11 \\ YOLOv5 & & & & & \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of the YOLOv5 and depth-attention YOLOv5.