# Automatic Metallic Surface Defect Detection and Recognition with Convolutional Neural Networks
## 1 Introduction
Traditional image processing methods often need multiple thresholds aiming at various defects in the algorithms, which are very sensitive to lighting conditions and background colors. When a new problem arises, those thresholds need to be adjusted, or it may even be necessary to redesign the algorithms. Moreover, features identified via handcrafted or shallow learning techniques are not sufficiently discriminative for a complex condition. These methods are generally aiming at a specific scenario, lacking adaptability and robustness to the above detection environment. In recent years, neural network methods have achieved excellent results in many computer vision applications, such as natural scene classification, face recognition, fault diagnosis and target tracking, etc. [26; 27; 28; 29]. Several defect detection methods based on convolutional neural networks (CNN) have  
Figure 1: Challenges of detecting surface defects of metallic components. (**a**) Defects with various shapes and sizes, (**b1**) defects with ambiguous edges and low contrast, (**b2**) defects with different background, (**b3**) fiber, (**b4**) dust, (**b5,b6**) scratches. also been proposed. [PERSON] et al. [30] used a multi-scale pyramidal pooling network for the classification of steel defects, which can adapt to the input images of different size. [PERSON] et al. [31] proposed a flexible multi-layered deep feature extraction framework based on CNN via transfer learning to detect anomalies in anomaly datasets. A majority voting mechanism is also designed to overcome the problems of overfitting by combining deep features with linear support vector machine (SVM) classifiers. The deep network structures designed by the above two methods are primarily aimed at the classification task of the defect image, and the position of the defect is not localized. [PERSON] et al. [32] proposed a fast and robust automated quality visual inspection method that utilized traditional CNN with a sliding window to localize the product damage. [PERSON] et al. [33] developed a structural damage detection method based on Faster R-CNN to detect five types of surface damages: concrete cracks, steel corrosion (medium and high levels), bolt corrosion, and steel delamination. [PERSON] et al. [34] built a convolutional neural network (CNN) for light emitting diode (LED) chip defect inspection. The defect regions are localized by using a class activation mapping technique without region-level human annotations. [PERSON] et al. [35] proposed a detection system that has three deep convolutional neural network (DCNN) based detection stages, including two detectors to localize key components and a classifier to diagnose their status. Those above-mentioned methods convert the surface defect detection task into an object detection problem in computer vision. The localization of defects is often within a bounding box that does not actually representing a defect's borders and cannot describe its shape. In [11], [PERSON] et al. proposed a deep learning-based approach that used a pre-trained deep learning network to classify defect image patches. The pixel-wise prediction of defect is obtained by [PERSON]'s segmentation method based on the heatmap. This pixel-wise prediction method is a graph-based method that is susceptible to various thresholds and does not obtain the defect category. [PERSON] et al. [36] used a fully convolutional network (FCN) for the inspection of galvanized stamping parts. In this paper, automated metallic surface defect inspection architecture is presented in a twofold procedure to overcome these challenges, which consists detection and classification modules. The detection module, which we called a cascaded autoencoder (CASAE), segments and localizes defects. In classification modules, the accurate defect category is obtained by a compact CNN network. The main contributions of this paper are as follows:  
(1) We propose a novel CASAE network to deal with the defect inspection task.