## 2 Methodology
### Image Labeling  
At present, the popular image labeling tools for computer vision are \"labelme\", \"labelme\" or \"CVAT\". In this work, the image labeling tool \"Image Labeler\" that comes along with the MATLAB software was used. The semantic segmentation model used belongs to supervised learning. In order for the neural network to achieve better results in learning and to clearly identify weld defects and weld metal, each class was labeled. An original image and a labeled image are shown in Figure 2. Both were used as input to the neural network. The original image was needed for the training of the neural network. Finally, the predicted segmented image was compared with the labeled image.  
Figure 1: Obtaining images from welds: (**a**) Circumferential welds formed during welding of two cylindrical specimens cut as preparation for metallography. (**b**) Two micrographs resulting from metallography.  
Five classes were initially defined for the classification, as follows:  
* The part inside the base material having a clear weld boundary belongs to the weld area, while the rest belongs to the background colored in red;
* A weld reinforcement or sagging that causes a deviation in the expected weld seam shape requirements is defined as a seam shape defect. The label color is pink;
* The remaining parts that are in the weld area without defects are weld metal. The label color of weld metal is blue;
* If there is a long and thin weld defect within the weld area, it is defined as crack. The label color is green;
* Weld defects formed like a bubble are defined as pores. The label color of pores is purple.  
Since some defects are very small, image labeling is done pixel-by-pixel. Although there is a clear rule for image labeling, there is still the problem of ambiguous error in the process of image labeling, which can mainly be divided into the following three situations:  
* Ambiguous defects between weld metal and background: From the original image in Figure 3a, it can be seen that the fusion line of weld metal is difficult to distinguish from the background. The reason is that the colors of weld metal and base metal or heat affected zone are very similar, so no clear boundary can be obtained. In this case, image labeling requires enlarging the image to obtain a finer texture for an artificially based estimation of the position of the boundary;
* Ambiguous defects between pores and cracks: The purple label in Figure 3b represents pores. According to the definition, pores are spherical cavities formed by gas inclusions. It should be spherical, but in the actual image labeling, it refers to voids that do not match the thin and long properties of cracks and which are located in the weld area;
* Ambiguous defects between seam shape defects and the background: The pink label stands for seam shape defects. Seam shape defects describe the deviation between the actual weld geometry and the expected weld geometry, but it is difficult to determine a fixed shape standard for a weld reinforcement. To solve this problem, in the case that the weld metal is higher than the base metal, it is assumed that there is no seam shape defect. In the case that the weld metal is lower than the  
Figure 2: Original image, labeled image and class differentiation.  
base metal, the rest is artificially filled according to the shape of weld metal, forming a full arc.