## 4 Experimental Results and Analysis  
### Experimental Dataset  
Although deep learning-based surface defect detection methods have shown promising results, there are still numerous challenges specific to detecting defects on steel surfaces. The publicly available datasets for steel surface defects generally do not exceed 1024 \(\times\) 1024 pixels. However, in practical engineering applications, images captured with high-definition industrial cameras often far exceed the 1080p standard. It is generally accepted that 4K UHD (3840 \(\times\) 2160) is the new industrial standard and is considered high resolution [16]. Notably, images in public datasets are usually small in size and selectively chosen with obvious defect features. The dataset used in this study consists of images of minor surface defects, specifically porosity defects, captured in actual factory settings. These images were collected based on real production scenarios, featuring diverse lighting conditions, various shooting angles, and complex background interferences, fully reflecting the actual detection needs in industrial production environments. An example is shown in Figure 12.  
Figure 11: Network architecture diagram.  
The dataset covers various defect morphologies, including changes in the size, shape, and distribution of porosities, providing a rich training sample set to improve the generalization performance of the defect detection model, as shown in Figure 13. All images have been manually annotated, with annotations including the location, size, and category of defects, providing high-quality standard data for subsequent model training and evaluation. To address the problem of balanced and sufficient sample numbers for different types of images, the following four steps are used for sample generation:  
* High-Resolution Machining Surface Localization: To minimize the area of the detection region, it is first necessary to segment the surface to be inspected from the high-resolution sample image. Since the shape of the machined surfaces of the workpieces is generally consistent, key-point localization and template matching methods are used to determine the detection surface. Initially, obvious features are selected to determine key points, and then, based on the key points and their composite information, the orientation of the machining surface is determined.
* Segmented Polygonal Area Matching: Based on the detected workpiece machining surface, a predefined polygonal template is used for matching. If there is an angular difference between the detection surface and the template, the workpiece image is rotated to align with the template angle. The polygonal template is pre-optimized to divide the workpiece detection surface into the smallest number of detection sub-images according to the encoder input size requirements.
* Segmenting the Polygon: The size of the sliding window is determined based on the input size of the neural network. Sliding within the template range, training samples are obtained.
* Re-segmentation of Defective Images: To address the issue of a limited number of samples with defects, when a defect is discovered during sample generation, the defect area is re-segmented. First, the minimum bounding rectangle of the sample defect is determined, then randomly generated detection sample images that include the defect's minimum bounding rectangle are created. This allows for multiple defect positions to be randomly distributed in the sub-images. The defect is then split into two parts, with only one part included in the generated test sub-image.  
Figure 12: Original part drawing.  
Finally, since the defects exposed on metal surfaces exhibit rotational invariance, the discovered defects are also rotated and mirrored to obtain more samples, effectively increasing the number of samples and benefiting neural network training, as shown in Figure 14, which illustrates the system flowchart.