# Extracting Weld Bead Shapes from Radiographic Testing Images with U-Net
## 3 Data and Training  
### Data Configuration  
In this study, 500 weld images were obtained for use in the experiments, and the CLAHE image preprocessing technique was used to improve the contrast of the weld images. The 500 weld images were from three in three different shipyards and each shipyard had own radiographic testing environment such as X-ray energy. Figure 3a,b show the original image and the image after CLAHE was performed, respectively. In the images presented in this paper, there is a white rectangular box, which covers the information about the radiographic image for security. Figure 4a,b show the histograms of the original image and the image after CLAHE was performed, respectively. Furthermore, among data augmentation techniques, rotating, cropping, flipping, and brightness adjustment were used to expand the weld images to a total of 2500 images.  
Figure 2: U-Net architecture.  
This study also used mask images as training data for the U-Net model. Mask images are created by performing a labeling process. These mask images only contained pixel intensities of 0 or 1, where 0 indicates the area outside bead and 1 indicates the bead area. Figure 5 shows a binary mask image in which labeling is performed on the image presented in Figure 3.  
Figure 4: Pixel distribution of the image was broadened through HE: (**a**) histogram for the raw image; (**b**) histogram for the CLAHE image.  
Figure 5: Mask image consisting of pixel intensity 0 of basic metal and 1 of weld bead.  
Figure 3: An average of 33 differences were present in the pixels in the bead area before and after HE was applied: (**a**) raw image; (**b**) CLAHE image.  
When image data are read, the images are saved in PNG and JPEG formats, and the label information is saved separately. Additionally, when images are read in the PNG or JPEG format and encoded and decoded several times, significant performance reductions occur in the training stage, which become an inefficient part of the process.  
To perform the training efficiently and improve the speed, the weld images were combined with the mask images that had gone through the labeling process and contained only the 0 and 1 values, and the Tfrecord files were created. A Tfrecord file is a binary data format for storing TensorFlow training data. Tfrecord files allow the management of the training data and the label information in one file. Tasks such as encoding and decoding can be batch processed in a single file, eliminating the need for additional work and increasing the training efficiency and speed [18]. The weld images and mask images are encoded into a Tfrecord file, and the width and height of the image are additionally saved. Additionally, the encoding format is set to bytes.  
The most common method for evaluating deep learning models is to divide and use the collected data [19]. The 500 raw images and 2500 images after data augmentation was performed were divided and specified as the training and test dataset: 350 and 1750 images were used for training, and the remaining 150 and 750 images were used for testing. Of the collected data, the training data were used in the model training process. The test data were used to deduce the model's performance; that is, how well the model learned using the training data.