# Detection of Defects on Metal Surfaces Based on Deep Learning
## 1 Introduction
[12] used the Shape From Shading (SFS) method combined with a Faster Regional Convolutional Neural Network (Faster R-CNN) model to extract the position, type, and surface characteristics of the defect. [PERSON] et al. [13] proposed a neural network called a lightweight fully convolutional neural network, achieving high accuracy with fewer model parameters. [PERSON] et al. [14] designed and utilized a novel cascaded autoencoder (CASAE) architecture for detecting and locating defects. [PERSON] et al. [15] proposed the self-Supervised Efficient Defect Detector (SEDD) method to achieve low computational consumption and fast detection. [PERSON] et al. [16] suggested the mask gradient response-based threshold segmentation (MGRTS) method for defect detection, combining it with the Difference of Gaussians (DoG) method to increase the detection rate. [PERSON] et al. [17] utilized the ULF module, FGS algorithm, and SIL-Net for effectively extracting and labeling low-contrast and small scratches. [PERSON] et al. [18] used the Swin Transformer for detecting and classifying surface defects, modifying the network structure to improve model performance and proposed the LSwin Transformer. [PERSON] et al. [19] proposed a vision Transformer model for detecting aluminum surface defects, using a multi-layer perceptron (MLP) as the final classifier. [PERSON] et al. [20] applied various optimizations to classify surface defects using the YOLOv8 algorithm. In the automatic detection of defects on metal surfaces, challenges arise from factors such as low contrast on the surface, light reflections, noise, and shadows, leading to false detections or undetected defects. Additionally, high-resolution images, along with large datasets, can negatively impact the training cost of deep learning models, storage, and energy efficiency. This situation hinders the automatic detection of defects using computer vision or deep learning, resulting in delays. The aim of this study is to create a new dataset with a relatively smaller data size by utilizing image processing methods on a limited dataset. The images in the dataset are converted to binary to eliminate external factors that may distort the image and extract the patterns of defects. Furthermore, it is anticipated that training a new deep learning model with the newly produced dataset will yield higher accuracy and energy efficiency with a lower number of epochs. In this study, a dataset that is independent of background variations and has a low data size was created by sequentially applying morphological operations, Gaussian blur, PCA, and Otsu thresholding techniques. The MobileNetV2 model was trained using the new dataset, resulting in high-accuracy and highly efficient classification by the end of the training process. In this study, the NEU dataset containing 1800 defective images was used. This dataset consists of six classes, namely crazing, inclusion, patch, pitted surface, rolled-in scale, and scratch. The images underwent morphological operations, specifically closing and opening, to highlight the defective areas on the metal surface. After clarifying the defects, Gaussian blur was added to the images to reduce noise. PCA was applied to reduce the dimensions of the noise-free images and facilitate the easier detection of defects. In the final stage, Otsu's thresholding technique was used to eliminate environmental effects such as pattern extraction of defects and variations in background and brightness. The final images obtained were saved under their respective classes. A percentage of 80% of the created dataset was allocated for training and 20% for testing, which was utilized in the training of the MobileNetV2 model. The training was conducted using both the grayscale original dataset (G-NEU) and the newly created dataset. A model with high accuracy and efficiency was successfully developed using a lower data volume, independent of environmental effects, and with a small number of epochs. The article is organized as follows: Section 1 outlines the purpose of our study.