# A Lightweight TA-YOLOv8 Method for the Spot Weld Surface Anomaly Detection of Body in White
## 4 Experiment
### Results and Comparison  
Our proposed TA-YOLOv8 model (hereinafter referred to as Weld Spot Defect Detection Model, WSDDM) was trained, validated and tested on a spot weld image dataset alongside several well-known object detection algorithms such as SSD [34], Faster R-CNN [35] and RetinaNet [36]. Figure 6 shows the performance of each trained model on the test set. When the IoU threshold is set to 0.5, the WSDDM shows a significant improvement in accuracy and speed over YOLOv8. This improvement is due to the improved feature fusion structure, backbone network adjustments, and refined loss functions of the model. While Faster R-CNN achieves the highest detection accuracy, it incurs significant time costs. The lightweight DarkNet53 network used in the WSDDM significantly increases the detection speed without sacrificing accuracy. As can be seen in Figure 6, the WSDDM consistently identifies high- and low-quality spot welds and achieves an mAP of over 90%. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Class** & **Normal** & **Edge Weld** & **Overlap** & **Cold Weld** & **Burr** & **Distortion** \\ \hline training dataset & 2250 & 1170 & 2400 & 510 & 780 & 1650 \\ validation dataset & 225 & 117 & 240 & 51 & 78 & 165 \\ testing dataset & 234 & 153 & 256 & 45 & 59 & 152 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Dataset of welding spots. Figure 6: Performance comparison with typical object detection algorithms on test set. The texting results of the WSDDM are shown in Figure 7. A comparison of YOLOv8 and the WSDDM with images from the test set is also shown in Figure 7. The three columns show the results of YOLOv8, the WSDDM and manual annotations, with green boxes indicating acceptable spot welds and red boxes indicating defective spot welds. The numbers in each box indicate the level of confidence in the presence of spot welds. Despite different lighting conditions and irregular spot weld shapes, both DL models effectively detect spot welds, albeit with slight differences in the confidence level, and they can accurately distinguish similar round spot welds. For tasks involving the detection of dense, small spot welds, the WSDDM outperforms YOLOv8 in terms of detection performance and robustness across different spot weld sizes, with fewer missed or false detections. The model's dual, cross-scale feature fusion strategy increases sensitivity to detailed features, which is helpful in detecting small spot welds. Figure 7: Some results of WSDDM and comparison between small welding spot detection models. We use green to represent the detected weld spots are normal, and red to represent the detected weld spots have defects or abnormalities. Using the WSDDM method described in the previous chapter, each weld spot in the image was located and then cropped and saved, as shown in Figure 8. It provides an organized dataset of spot welds captured under real production conditions, categorized by various defect types as well as normal spots. Meanwhile, each defect type and normal class are represented by multiple images, which helps in creating a balanced dataset. For training object detection models, especially in tasks like small object detection, a balanced dataset with representative defect variations is crucial to achieve high accuracy and reduce model bias. Each image is annotated with labels indicating both class type and an ID number, which may refer to specific samples. This detailed annotation can aid in supervised learning, as the model can be trained to detect both the location and type of defect. 1. Multi-Class Detection: The dataset structure supports multi-class defect detection, which is ideal for models like YOLO and Faster R-CNN that are capable of handling multiple classes. 2. Class Imbalance Consideration: If any defect type is underrepresented, it may lead to class imbalance, affecting the model's ability to generalize across all defect types. Techniques like data augmentation, synthetic image generation, or class-weighted loss functions could mitigate this. 3.