## 4 Experimental Testing and Result Analysis
### Optimization of the YOLOv8-Pose Loss Function  
The loss function of the YOLOv8-pose model is at the core of its training [17], ensuring that the model can accurately learn key point information. This loss function integrates object localization loss \((\lambda_{box})\), pose estimation loss \(\left(\lambda_{pose}\right)\), and classification loss \((\lambda_{cls})\) to optimize the model's predictive performance. The overall loss function of the YOLOv8-pose model can be described as:  
\[\mathrm{L}=\frac{\lambda_{box}}{N_{pos}}\sum\mathrm{L}_{\mathrm{IoU}}\left( \mathrm{b}_{i},\hat{\mathrm{b}}_{i}\right)\;+\frac{\lambda_{cls}}{N_{pos}} \sum\mathrm{L}_{\mathrm{cls}}(\mathrm{c}_{i},\hat{\mathrm{c}}_{i})\;+\frac{ \lambda_{pose}}{N_{pos}}\sum\mathrm{L}_{\mathrm{pose}}(\mathrm{p}_{i},\hat{ \mathrm{p}}_{i}) \tag{14}\]  
where:  
* \(L_{\mathrm{IoU}}\) is the complete IoU (Intersection over Union) loss, used to measure the consistency between the predicted bounding box and the actual bounding box. * \(L_{cls}\) is the classification loss, using cross-entropy to measure the difference between the predicted category and the real category. * \(L_{pose}\) is the pose loss, using the Euclidean distance between key point coordinates. * \(N_{pos}\) represents the number of positive samples, and the \(\lambda\) series are the weight coefficients for each loss component. \begin{table}
\begin{tabular}{c c} \hline \hline
**Evaluation Metrics** & **Result** \\ \hline Precision & 92.3\% \\ Recall & 90.7\% \\ Mean Average Precision & 89.5\% \\ Average Inference Time(s) & 0.074 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Detection results of the test set. Figure 7: Recognition result image. * \(b_{i}\), \(p_{i}\), and \(c_{i}\) represent the ground truth values for object localization, pose estimation, and classification for each sample, respectively. * \(\hat{b}_{i}\), \(\hat{p}_{i}\), and \(\hat{c}_{i}\) are the predicted values for object localization, pose estimation, and classification for each sample, respectively. From Figure 7, it can be seen that although the interconnected terminals and cables can be accurately identified, the recognition box does not always fully cover the cable numbers and terminal numbers. Therefore, it is necessary to adjust the training parameters to improve the recognition effect. To enhance the recognition accuracy, parameter optimization was designed in this experiment. In the YOLOv8-pose model, the key points' loss is a key part in locating the connection relationship between terminals and cables. To improve the accuracy of the recognition box for terminal numbers and cable numbers, a series of experiments were designed to adjust the proportion of the key-point loss weight in the loss function. Firstly, while keeping other parameters unchanged, only the key-point loss weight was changed to observe the performance change of the model. In the initial experiment, the key-point loss weight was set to the model's default value. Subsequently, the weight was modified from 5 to 30 with a step size of 1, and the changes in the model's overall and key-point recognition accuracy, recall rate, and mAP in the detection task of terminals and cables were recorded. The experimental results are shown in Figure 8.  
Figures 8 and 9 show the experiments result for key-point recognition and the overall recognition result for the connection between terminals and cables, respectively. To further explore the relationship between the weight of the key-point loss function and the model's recognition performance, all the results shown in Figures 8a-d and 9a-d are normalized, then we calculate the sum of the eight normalized values corresponding to each weight. The  
Figure 8: Experiments result for the key-point recognition. (**a**) Precision (**b**) Recall (**c**) mAP\({}_{50}\) (**d**) mAP\({}_{50}\)-95.  
results are shown in Figure 10. From the figure, it is evident that the model's comprehensive performance is best when the weight is 22.