# An Enhanced YOLOv5-Based Algorithm for Metal Surface Defect Detection
## 1 Introduction  
The identification of surface irregularities on metal workpieces plays a pivotal role in guaranteeing the quality of industrial manufacturing during the production process. During the fabrication and manufacturing of metal workpieces, factors such as machining methods and manufacturing conditions can result in the emergence of imperfections like scratches, protrusions, and abrasions on the surface of material. These defects exert a substantial influence on the quality and functionality of the products, diminishing their longevity and potentially leading to the production mishaps in more serious instances. Manual screening is typically employed for detecting metal surface defects in industrial production currently. Nevertheless, this method is marked by elevated expenses, reduced efficiency, and the quality of detection is significantly affected by factors like the skill level of workers, posing challenges in fulfilling the requirements of large-scale product inspection. There are two main categories of methods for metal surface defect detection [1]. One relies on conventional image processing methodologies, and the other is rooted in deep learning techniques. [PERSON] et al. [2] introduced a similarity assessment approach reliant on color histograms to evaluate the Electromagnetic Resonance Tomography (ERT) imagery of resistor blocks. An Adaptive Cuckoo Search (ACS) algorithm is used to compute the optimal threshold for multi-level grayscale image thresholding improvement. [PERSON] et al. [3] used a Genetic Algorithm (GA) to calculate the optimal Gabor filters to suppress texture interference. A novel fabric defect detection method is proposed, which used ACS-based thresholdingand GA-based optimal Gabor filters. [PERSON] et al. [4] introduced a technique for detecting color-based point defects. This approach relies on factors such as local contrast analysis, point defect enhancement, noise reduction, and background suppression, all in conjunction with the utilization of the OR operation. Defect detection methods based on deep learning primarily encompass the Faster R-CNN, various networks from the YOLO series, and the SSD network. [PERSON] et al. [5] leveraged the strengths of GANs while addressing the limitations of conventional approaches, ultimately improving the overall performance of surface defect detection. [PERSON] et al. [6] proposed an innovative defect detection approach utilizing Faster R-CNN specifically designed for identifying plate surface imperfections. A bilateral filtering algorithm was used, in which a shape-adaptive convolution with ResNet50 was applied to obtain defect semantic feature mapping in the feature pyramid network. [PERSON] et al. [7] introduced a surface defect detection approach utilizing MobileNet-SSD as the foundation. They streamlined the detection model by making adjustments to both the network structure and parameters. [PERSON] et al. [8] improved the YOLOv4-Tiny algorithm by employing a parallel feature processing strategy to extract features from bimodal images. Features from different layers were fused to enhance the defect feature extraction approach. However, the ACS algorithm may require a large number of iterations to find a satisfactory optimization solution, especially for complex optimization problems. This may result in long runtimes. Faster R-CNN only employs features extracted from the final convolutional layer of the underlying network for detection. This deficiency in incorporating shallow features results in subpar performance when identifying minor defects in small targets, and it also results in a relatively bulky model that hampers detection speed. Although the SSD algorithm predicts smaller targets using shallow features, it still lacks sufficient deep feature information, resulting in limited capability in detecting small targets. The YOLOv4-Tiny algorithm has faster detection speed but requires improvement in accuracy.