# Detection of Welding Defects Using the YOLOv8-ELA Algorithm
## 3 Experiments and Results
### Dataset Collection and Processing  
The dataset consists of DR defect images of aluminum alloy welds acquired by the Shanghai Nuclear Power Group through non-destructive testing between 2018 and 2022. A total of 823 defect images are included, among which 415 images contain air holes, 295 images exhibit incomplete welding, and 113 images show slag inclusion. Figure 7 illustrates the DR images of the different defects, revealing distinct imaging characteristics. Table 1 summarizes the imaging characteristics and potential causes of defects.  
The dataset was labeled by Labelimg (version 1.8.1) software, and the text of the training data required in the training process can be generated by drawing rectangular boxes for the defects in the image. Each picture will generate a text file. Figure 8 shows the data-labeling interface and the corresponding target box information after labeling, and each rectangular box marked with defects will generate a column of data. From left to right are the category of the defect, the x-coordinate of the center point of the target box, the y-coordinate of the center point of the target box, the width of the target box w, and the height of the target box h.  
Due to the limited dataset of 823 defect images causing suboptimal model performance, data augmentation techniques were applied to expand it. The dataset was expanded to  
\begin{table}
\begin{tabular}{c c c c} \hline
**Defect Type** & **Imagefeature** & **Characteristics** & **Cause** \\ \hline \multirow{2}{*}{Pores} & \multirow{2}{*}{Dark spots} & Smooth (single)/ & \multirow{2}{*}{Low X-ray attenuation in voids} \\  & & Complex (clustered) & \\ \hline \multirow{2}{*}{\
\begin{tabular}{c} Slag inclusions \\ \end{tabular} } & \multirow{2}{*}{Bright regions} & \multirow{2}{*}{Sharp and well-defined} & High attenuation from tungsten \\  & & & reduces transmitted X-rays \\ \hline \multirow{2}{*}{
\begin{tabular}{c} Incomplete penetrations \\ \end{tabular} } & \multirow{2}{*}{Black lines} & \multirow{2}{*}{Linear and distinct} & Unpenetrated regions allow \\  & & & unimpeded X-ray transmission \\ \hline \end{tabular}
\end{table}
Table 1: DR characteristics of pores, slag inclusions, and incomplete penetrations.  
Figure 7: A defects dataset of weld radiographs.  
5724 images through horizontal rotation, vertical flipping, random brightness adjustments, and the addition of speckle noise and Gaussian noise. These methods enriched the dataset and strengthened the model robustness.  
Speckle noise is generated by randomly modifying the RGB values of the pixels to produce a noisy effect similar to salt-and-pepper noise. Gaussian noise is created by generating random values from a normal distribution and adding them to the input data. For a three-channel RGB image, represented as a three-dimensional matrix, a normally distributed three-dimensional matrix is generated and added to the input data to produce a new image with added Gaussian noise. Figure 9 shows an example of a tungsten slag defect image after data augmentation.  
Figure 8: Data-labeling procedure.  
Figure 9: Schematic diagram of data augmentation. (**a**) Original drawings of defects; (**b**) Horizontal rotation; (**c**) Vertical flipping; (**d**) randomly adjust the image brightness; (**e**) salt and pepper noise; (**f**) Gaussian noise.  
Our dataset was split into training, validation, and test sets in a 9:1:1 ratio. The distribution of the object classes across the sets is shown in Figure 10. It is important to note that the data used for the subsequent comparison experiments were obtained from the test set.  
Additionally, in the course of training, the Mosaic data augmentation method was employed to further enhance the diversity of the dataset. This approach involves randomly arranging four images and merging them into one by cropping, effectively increasing the richness of individual images and improving the training efficiency.