# A Lightweight TA-YOLOv8 Method for the Spot Weld Surface Anomaly Detection of Body in White
## 4 Experiment
### Data Augmentation and Labeling  
Before training the defect weld spot generation model, the cropped weld images were resized to 64 \(\times\) 64 pixels and normalized to the range [-1,1]. The dataset includes normal welds and six types of weld defects, with a highly imbalanced class distribution. After simple affine transformations were applied to augment the data, the class distribution for the training, validation and testing sets is shown in Table 2. The defect weld spot generation model was trained using the Adam optimizer, with a learning rate of 0.002, and momentum parameters \(\beta_{1}\) and \(\beta_{2}\) set to 0.5 and 0.9, respectively. The batch size was 128, and the latent vector dimension was set to 128. For comparison, the ACGAN [37], cWGAN-GP [38], and BAGAN [39] models were trained on the same dataset, with hyperparameters largely kept consistent. Currently, there is a lack of standardized and accurate methods for evaluating generative model performance [40]. Therefore, this study uses both qualitative and quantitative methods to evaluate the performance of GAN models. The qualitative evaluation assesses the performance of various GAN models by comparing the quality of generated weld spot image samples. This approach mainly relies  
Figure 8: The weld spot dataset obtained from image segmentation using the WSDDM. on a visual assessment, focusing on the quality of selected images while potentially over-looking issues like overfitting and diversity. Figure 8 presents random samples generated by ACGAN, cWGAN-GP, BAGAN, and the proposed defect weld spot generation model, encompassing defect types such as \"edge welding\", \"overlap\", \"cold solder joint\", \"burr\", \"distortion\", and \"normal\". Due to the high representation of normal weld samples in the dataset, each GAN model was able to generate high-quality images of normal welds. However, ACGAN and cWGAN-GP struggled with minority class defects, often producing images belonging to unintended classes, like \"overlap\" or \"burn-through\". This limitation stems from the discriminator output structure and loss functions of these models, which are less effective for learning minority classes, making it challenging for the generator to synthesize accurate samples for these classes. Both BAGAN and the defect weld spot generation model, however, effectively generated minority defect welds. Yet, the latent vectors produced by the AE model used to initialize BAGAN did not adequately differentiate between weld classes, complicating its training process. When weld images from different classes appeared visually similar, BAGAN struggled to generate images matching the intended class, such as \"distortion\" and \"normal\". For classes with very few samples, like \"burn-through,\" BAGAN also failed to produce correct images. Additionally, BAGAN required an extensive fine-tuning of its network structure and hyperparameters. By contrast, the proposed defect weld spot generation model accurately generated images of specific defect types, demonstrating that it can effectively achieve data augmentation for defect classes, even when defect samples are limited. Figure 9 illustrates the labeling process used in a deep learning dataset, where each image sample of weld spots is annotated with a classification label to differentiate between normal and defective spots. The left section displays various weld spot images grouped by visual characteristics, such as shape and condition, while the right section lists file names with corresponding binary labels, where '0' denotes a normal weld spot, and '1' represents a defective one. Figure 9: Data augmentation and labeling. The generated synthetic defect samples were used in the training of YOLOv8 as part of data augmentation, which can be considered a data preprocessing step. To evaluate the effectiveness of this approach, we conducted additional experiments. Without incorporating augmented data, the model's training performance was suboptimal, lacking a comparative and reference value.