원시데이터 수집 시스템
선정목록으로

A high-effective multitask surface defect detection method based on CBAM and atrous convolution

간접 관련 산업용 섬유 · (17) 스펀본드 부직포 (1) 에어백(3) 자동차 인테리어 소재(9) 타이어코드

기본 정보

저자
  1. Xin Xie — School of Information Engineering, East China Jiaotong University
  2. Lei Xu — School of Information Engineering, East China Jiaotong University
  3. Xinlei LI — School of Information Engineering, East China Jiaotong University
  4. Bin Wang — School of Information Engineering, East China Jiaotong University
  5. Tiancheng Wan — School of Information Engineering, East China Jiaotong University
DOI
10.1299/jamdsm.2022jamdsm0063
저널
Journal of Advanced Mechanical Design Systems and Manufacturing
발행년도
2022
발행기관
Japan Society Mechanical Engineers
피인용수
6
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1299/jamdsm.2022jamdsm0063
토픽
Surface Roughness and Optical Measurements
OpenAlex ID
W4313156136

평가 내용

관련도
간접 관련
사업분야
산업용 섬유 · (17) 스펀본드 부직포
부 분야
(1) 에어백, (3) 자동차 인테리어 소재, (9) 타이어코드
R&D 측면
분석·모델링
확신도
0.80
근거 용어
surface defect detection, deep learning, machine vision, segmentation, industrial products
판단 근거
이 논문은 산업 제품의 표면 결함을 탐지하기 위한 딥러닝 기반의 비전 검사 알고리즘을 다루고 있습니다. 이는 코오롱인더스트리의 섬유, 타이어코드, 자동차 소재 등 다양한 제조 공정의 품질 관리(QC) 자동화 시스템에 적용 가능한 기술입니다.
R&D 활용 포인트
에어백 원단, 타이어코드, 부직포 등 고부가가치 산업용 섬유 및 필름 제조 공정에서 실시간 표면 결함(스크래치, 오염, 미세 구멍 등)을 자동으로 검출하는 스마트 팩토리 검사 시스템 구축에 활용 가능합니다.
평가 입력
본문 58,972자 중 30,032자 발췌

초록

Given the shortcomings of conventional machine vision-based surface defect detection methods, including their low accuracy, long development cycle, and poor generalization ability, this paper proposes a surface defect detection model based on the convolutional block attention module and atrous convolution. This model combines the surface defect segmentation task of the product with the classification task, obtains contextual information of the image at multiple scales using atrous spatial pyramid pooling, and then uses the convolutional block attention module to reallocate the weighting of the network to enhance focus on the defect area and improve the discrimination of extracted features. In addition, atrous convolution was introduced in the deep network to simplify the model when used in defect segmentation tasks and enhances the real-time performance of the model defect detection method. Experiments show the superior accuracy and real-time performance of the proposed model when compared with current mainstream surface defect detection methods and indicate its wide applicability in the detection of surface defects in industrial products.

본문 58,972자

본문 펼치기
## _Journal of Advanced Mechanical Design, Systems, and Manufacturing_ # A high-effective multitask surface defect detection method based on CBAM and atrous convolution Xin XIE*, Lei XU*, Xinlei LI*, Bin WANG* and Tiancheng WAN* - School of Information Engineering, East China Jiaotong University 808 Shuanggang East Street, Economic and Technological Development Zone, Nanchang 330013, China E-mail: isleixu@sina.com Received: 6 March 2022; Revised: 30 September 2022; Accepted: 26 October 2022 Abstract Given the shortcomings of conventional machine vision-based surface defect detection methods, including their low accuracy, long development cycle, and poor generalization ability, this paper proposes a surface defect detection model based on the convolutional block attention module and atrous convolution. This model combines the surface defect segmentation task of the product with the classification task, obtains contextual information of the image at multiple scales using atrous spatial pyramid pooling, and then uses the convolutional block attention module to reallocate the weighting of the network to enhance focus on the defect area and improve the discrimination of extracted features. In addition, atrous convolution was introduced in the deep network to simplify the model when used in defect segmentation tasks and enhances the real-time performance of the model defect detection method. Experiments show the superior accuracy and real-time performance of the proposed model when compared with current mainstream surface defect detection methods and indicate its wide applicability in the detection of surface defects in industrial products. _Keywords_ : Convolutional block attention module, Atrous convolution, Atrous spatial pyramid pooling, Surface defect detection, Deep learning 1. Introduction In industrial manufacturing, in order to ensure the quality of products, the most effective way is to inspect the surface of the product. Usually, it is trained workers who identify complex surface defects, but this method is susceptible to worker inexperience and subjective factors. This time-consuming and unreliable process cannot be adapted to the developing trend of industrial automation. With the development of intelligent manufacturing, defect detection technology based on machine vision (MV) is favored by most scholars. Sun et al. proposed a background subtraction method based on the Gaussian mixture model to extract the feature area of weld defects and designed a weld detection and classification algorithm (Sun et al., 2019). Shen et al. used template matching and sub-pixel precision to precisely position a printed circuit board (PCB) and then used smart cameras and industrial robots to complete the PCB defect detection (Shen et al., 2018). Huang et al. used a support vector machine (SVM) classifier to identify six common glass bottle defects, which addresses the low classification accuracy of existing machine vision defect detection systems (Huang et al., 2016). Xie et al. proposed an improved sub-pixel detection algorithm combining coarse and fine positioning, using Otsu's method to achieve sub-pixel precise positioning (Xie et al., 2016). The above methods can satisfy the defect detection and classification requirements for specific problems to a certain extent. However, it is difficult to satisfy the real-time, high-accuracy, and generality requirements of defect detection in most industrial environments using defect detection methods based on machine vision due to their long development cycle, the interference of acquisition environmental noise, and the difficulty in finding a general template as a reference for various detection objects. In recent years, with the development of deep learning (DL), especially the in-depth study of convolutional neural networks (CNNs), deep learning has been successfully applied to various image-related tasks (Krizhevsky et al., 2012). Different from conventional machine vision methods, a deep learning algorithm can effectively learn the mapping Paper No.22-00101 <u>[DOI</u> <u>10 1299/j</u> <u>d</u> <u>2022j</u> <u>d</u> <u>0063]</u> © 2022 The Japan Society of Mechanical Engineers. This is an open access article under the terms of the Creative Commons Attribution-NonCommercial-NoDerivs license g g y g ( ) relationship between inputs and outputs hidden in a large amount of training data by using a multi-layer neural network structure, which does not need any precise mathematical expression. Qiu et al. proposed a three-stage defect detection model, which uses a fully convolutional network (FCN) as the basic framework. In the model, separable convolution is used instead of standard convolution to efficiently achieve the pixel-level segmentation of defect images (Qiu et al., 2019). Zhao et al. constructed the model using an auto-encoder (AE) and generative adversarial networks (GANs) and then used local binary pattern (LBP) to detect and locate defects (Zhao et al., 2018). He et al. combined convolutional auto-encoders (CAEs) and GANs to construct a model to accurately detect and classify defects on seven hot-rolled plates (He et al., 2019). Mei et al. proposed a defect detection and localization method that only requires training on non-defect images. It combines the idea of an image pyramid hierarchy with convolutional denoising autoencoder (CDAE) networks to perform defect detection on texture images (Mei et al., 2018). He et al. proposed an end-to-end steel surface defect detection method, which uses a baseline CNN to generate feature maps at each stage, and then the proposed multilevel feature fusion network (MFN) to fuse multiple hierarchical features (He et al., 2020). For these multi-level features, the region proposal network (RPN) is used to generate a region of interest (ROI). For each ROI, a classifier and a bounding box regressor generate the final detection result. Tang et al. proposed an end-to-end spatial attention bilinear convolutional neural network (SA-BCNN), combining the spatial attention mechanism in the deep convolutional neural network and bilinear pool technology, which can enhance the representation ability of CNN and extract more detailed image features, to improve the defect detection ability of the model (Tang et al., 2020). To address the difficulty of defect data collection and the expenses of labeling, He et al. proposed a multi-training semi-supervised method based on DCGAN and Resnet18 and applied it to steel surface defect classification. The method uses GAN to generate a large number of unlabeled samples, and then trains them with classifiers of two different learning strategies. The labeled and unlabeled samples are fused into the semi-supervised learning process to provide sufficient defect data (He et al., 2019). Similarly, Su et al. proposed a new approach to defect segmentation using generative adversarial networks. First, the GAN-based method removes the defect region in the input defective image to obtain a defect-free image while keeping the background almost unchanged. Then, the subtracted image is obtained by taking the difference between the defective input image and the generated defect-free image. Finally, the defect region can be segmented by thresholding the subtracted image (Su et al., 2021). Lin et al. proposed Normal Background Regularization and Crop-and-Paste operations, using abundant Normal image training models without defects to segment defect data with few-shot learning, to prevent model overfitting caused by very limited defect training images (Lin et al., 2020). Although the above-mentioned deep learning–based defect detection methods have solved part of the task of defect detection, the network structure constructed by some methods is too complex to satisfy the real-time requirements for defect detection in an industrial environment. In addition, some networks cannot effectively eliminate the influence of background information on defect images in a relatively complex acquisition environment, which causes part of background noise to be mistaken for defect pixels and affects the accuracy of the defect detection method. Hence, we propose a deep learning network model based on the convolutional block attention module (CBAM) (Woo et al., 2018) and atrous convolution (Yu and Koltun, 2016). The model is composed of a segmentation network and a decision network. The segmentation network and the decision network share some parameters, and the segmentation results of the segmentation network can help the decision network to more accurately detect defects. Our model performs better than current mainstream defect detection methods on both KolektorSDD and magnetic tile datasets. The main contributions are as follows: 1) A surface defect detection model based on CBAM and atrous convolution is proposed to detect and segment product surface defects, which can satisfy the high accuracy and real-time requirements of industrial defect detection. 2) The CBAM with negligible overheads was introduced into the segmentation network. It can not only improve the ability of the CNN to process fine-grained image classification but also reallocate the weighting of feature maps, enhancing the feature extraction ability of the network and improving the detection performance of the network. 3) We replace the standard convolution with atrous convolution in the segmentation network, and expand the receptive field while maintaining the same parameters and computations, simplify the model parameters and computational amount, and enhance the real-time performance of the model for defect detection. In addition, to address the gridding effect of atrous convolution, we used hybrid dilated convolution to design the structure of the convolutional layers, which means all the pixels of the input sample are involved in the calculation and <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) improves the performance of the network. In this paper, the most suitable configuration of atrous convolution layer is found through ablation studies. 4) Atrous spatial pyramid pooling (ASPP) (Chen et al., 2017) is used to obtain multi-scale information of images, to enhance the detection ability of defects of different sizes of the model and enhance the universality of the model. 2. Relevant theoretical To extract better features, accelerate the detection speed of the model, and enhance the real-time performance of the model, the CBAM, atrous convolution, and ASPP were introduced into the segmentation network model. 2.1 Convolutional block attention module The attention mechanism was first proposed in the images (Mnih et al., 2014). The introduction of the attention mechanism in the image field is a very critical technique to enable the deep network model to better focus on a local area of interest to the user while suppressing other areas that are not important. In recent years, models based on attention mechanisms have become a hot research topic and are widely used in various types of deep learning tasks such as natural language processing, image recognition (Wang et al., 2017; Xu et al., 2020), and speech recognition. Fig.1 The structure of convolution block attention module. CBAM is also one of many attention mechanisms, not only telling the user where to focus on but also enhancing the feature extraction ability of the area of interest. It is composed of a channel attention module and a spatial attention module that perform attention operations on the channel and spatial dimensions of the image, respectively. In addition, the use of CBAM can also improve the representational ability of CNN, force CNN to extract fine-grained image features, and make the extracted features more discriminative. The network structure of CBAM is shown in Fig. 1. The module first performs channel attention operation on the feature map to increase the weighting of effective channels and reduce the weighting of invalid channels. As shown in Eq. (1), where _M_ _c_ refers to the channel attention module, F is the input feature map, and the variables _F_ avg _c_, _F_ max _c_ represent the use of average pooling and max pooling operations to input feature map, and the variables _F_ avg _c_, _F_ max _c_ represent the use of average pooling and max pooling operations to aggregate the spatial information of the feature map, respectively. W0  c/r  c and W1  c  c/r represent the network model parameters of the multilayer perceptron, and  represents the sigmoid activation function. _F_ avg _c_, _F_ max _c_ Mc ( F ) = ( W1 ( W0 ( Favgc )) + W1 ( W0 ( Fmaxc ))) . (1) The Hadamard product operation can be carried out between the feature graph F  generated by the channel attention module and the input feature graph F to obtain the input of the spatial attention module. The spatial attention module is then used to increase the attention given to the regions of interest in the spatial dimension. This is shown in Eq. (2), where Ms refers to the spatial attention module, while Favgs and Fmaxs represent the use of average pooling and max where Ms refers to the spatial attention module, while Favgs and Fmaxs represent the use of average pooling and max pooling operations on the channel dimension of the feature map to aggregate its channel information, respectively. f7  7 represents the use of a 7×7 convolution operation. Ms ( F ) = ( f7  7 ( Favgs ;Fmaxs )) . (2) <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> Favgs and Fmaxs g g y g ( ) Finally, the modified feature map is generated by Hadamard product of the feature graph F  of the perform spatial attention module and the input feature map F  . 2.2 Atrous convolution In the field of image semantic segmentation, it is often necessary to make dense predictions of the full resolution of the image. The designed network not only needs to pay attention to local information but also global information, which requires the network to have a larger receptive field. In general, in order to obtain a larger receptive field, a typical segmentation network uses a large-size convolution kernel with a large number of parameters, so the network becomes relatively complex and requires a lot of computing resources. Atrous convolution is a kind of convolution method proposed to solve this problem. It can increase the receptive field of the network and reduce the training time of the model while maintaining the number of network parameters and calculations. Many classical semantic segmentation networks have also adopted this idea of convolution, such as the Deeplab series (Chen et al., 2014; Chen et al., 2016). Deeplab replaces standard convolution in the network with atrous convolution, and the multi-scale atrous convolution operation of the input image can be performed, greatly reducing the complexity of the network. SSD (Liu et al., 2016) and RFBNet (Liu et al., 2018) also refer to this convolution method to simplify the network in object detection. Atrous convolution is often used to deal with how global information is needed in image segmentation or the need for long sequence information in speech text. It introduces a hyper-parameter called a "dilation rate" to the standard convolution, which defines the distance between each element of the convolution kernel. In other words, compared with standard convolution, atrous convolution adds a new hyper-parameter of dilation rate, whose value is equal to the number of intervals between elements of the convolution kernel. Standard convolution is actually atrous convolution with a dilation rate of 1. The introduction of atrous convolution to the network can not only avoid information loss caused by the pooling operation but also increase the receptive field of the network, allowing the network to better capture the global information of the input image. For example, by adding a hole to the standard convolution, the original 3×3 standard convolution kernel can have a larger receptive field of a 5×5 (dilated rate = 2) standard convolution kernel with the same number of parameters and calculation, which avoids the downsampling operation. Atrous convolution is defined as: L g  i =  f  i + r  l   k[l], (3) l = 1 L  i =  f  i + r  l   l = 1 f  i + r  l   k[l] 1 where f[i] and g[i] are the input and output feature maps respectively, k[l] represents the convolution kernel of length l, and r is the dilated rate of the atrous convolution. When the atrous convolution is performing the convolution operation, the value of the atrous position is 0. Figure 2 illustrates the atrous convolution kernels with three different dilation rates. From left to right are the atrous convolution kernels with dilation rates r = 1, 2, and 4. As the dilation rate increases, the receptive field of the convolution kernel also becomes larger, corresponding to 3×3, 5×5, and 9×9 kernel, respectively. The receptive field of the atrous convolution is calculated as Eq. (4): R = ( r - 1 ) ( k - 1 ) + k, (4) where r is the dilation rate, k is the size of the convolution kernel, and R is the actual receptive field. Although atrous convolution has the above advantages, the random design of the dilation rate in the atrous convolution or any combination of atrous convolution in the network may greatly reduce the performance of the network. Wang et al. pointed out that blindly designing the dilation rate of the atrous convolution will make some pixels of the input sample not participate in the calculation, resulting in the gridding effect and affecting the accuracy of the network (Wang et al., 2018). This problem can be avoided by following hybrid dilated convolution in designing the structure of atrous convolution in the network. 2.3 Atrous spatial pyramid pooling Another challenge of deep convolutional neural networks for image segmentation is dealing with the existence of objects at multiple scales. A common method used to solve this is to combine the images of different scales obtained from the input image by rescaling the operation as the input of the network (Rudolph et al., 2018). This method can <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) indeed improve the segmentation effect of the model but it also creates a computational burden, which hinders the realtime performance of the model. Another effective method is to use ASPP to resample the feature maps obtained by the deep convolutional neural network at different scales to obtain feature maps with rich contextual information. Motivated by spatial pyramid pooling (He et al., 2014), Chen et al. proposed ASPP, which uses multiple parallel atrous convolutions with different dilation rates to perform multi-scale sampling for a given feature map (Chen et al., 2016). This is equivalent to using multiple convolution kernels with different receptive fields to resample a given feature map, so the contextual information provided by the image can be captured at multiple scales. In order to further capture global information, Chen et al. augmented ASPP with image-level features (Chen et al., 2017). Figure 3 shows the structure of ASPP with an augmented image-level feature. The improved ASPP uses one 1×1 convolution, three 3×3 atrous convolutions with dilation rates equal to 6, 12, and 18, and image-level feature pooling to perform multi-scale sampling on the input feature map. The resulting features were then concat to obtain an output feature map with rich contextual information. ## (a) (b) (c) Fig.2 Three kinds of atrous convolution kernels with different dilation rates. Fig. 3 The structure of Atrous Spatial Pyramid Pooling. 3. Surface defect detection method based on CBAM and atrous convolution A surface defect detection model based on CBAM and atrous convolution was designed, as shown in Fig. 4. The model is mainly composed of a segmentation network and a decision network that are used to segment and detect surface defects, respectively. In the segmentation network, the data features of the input samples are first learned and a binary segmentation map is generated. Each pixel in the input samples is taken as a separate training sample for the network to increase the effective number of training samples and avoid overfitting. In the decision network, the feature map learned in the segmentation network and the segmentation results generated are used as the input of the decision network. The <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) segmentation result is used to help the decision network better judge whether the input sample contains defects. Then, a denser and smaller space feature map is obtained after a series of convolutional and pooling operations, followed by the fully connected layer (FC) and sigmoid activation function. The final obtained input sample is the predicted value of the defective image. Fig. 4 The network model structure of the proposed. It has been noted that CNN has poor performance in fine-grained image classification, but the surface defect segmentation task needs to deal with defects at the pixel level (Zheng et al., 2017; Lin et al., 2018). Therefore, a CBAM with negligible overheads was introduced into the segmentation network. It can not only improve the ability of the CNN to process fine-grained image classification but also reallocate the weighting of feature maps, improve the attention given to the region of interest, and suppress other invalid information. At the same time, the atrous convolution layer was also designed following the idea of HDC in the segmentation network, which increases the receptive field of the network and simplifies the complexity of the model. In addition, in order to obtain multi-scale information from images, features with rich contextual information are extracted by ASPP to improve the accuracy of the segmentation results of the segmentation network with a small overhead. These factors allow the designed model to satisfy the requirements of high accuracy and strong real-time performance for the industrial surface defect detection method. 3.1 Design of the segmentation network First, the segmentation network learns the features of the input samples from 8 convolutional layers and 3 pooling layers and generates a feature map with 128 channels. In Fig. 4, 2-conv and 4-conv represent the atrous convolution dilation rates of 2 and 4, respectively. The convolution layer mentioned includes the batch normalization (BN) and nonlinear ReLU layer. When designing the convolutional layer, the kernel size is 3, the stride is 1, and the dilation rate is [1, 2, 4] as a basic convolution block, which satisfies the idea of HDC design. The use of a 2×2 kernel pooling layer in the network can not only reduce the computational burden of the network but also eliminate the interference information of invalid noise. Next, ASPP is used to further obtain multi-scale information of the image. Before passing through two convolutional layers with 512 channels, a 1×1 convolutional layer is used to map the number of channels of the feature map to 512 for consistency with the number of subsequent convolutional layer channels. Then, the CBAM is used to adjust the weight distribution of the feature maps to create a stronger representational ability and improve the segmentation accuracy of the segmentation network. Finally, a 1×1 convolutional layer and a sigmoid activation function are used to map the output results between 0 and 1 to generate a single-channel segmentation result whose resolution is 1/8 of the input image. The structure of the segmentation network and the detailed parameters settings are shown in Table 1. <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) 3.2 Design of the decision network The decision network connects the feature map (512 channels) modified by the CBAM in the segmentation network with the segmentation result (1 channel) output by the segmentation network and produces a feature map with 513 channels as the input of the decision network (see Fig. 4). In order to force the decision network to learn global information more easily and reduce the number of network calculations, a max-pooling layer with a step size of 2 is used to halve the length and width of the feature map. Then, a 3×3 convolutional layer and two residual blocks are used to learn the feature map after pooling. Each convolutional layer is followed by a BN and nonlinear ReLU layer to accelerate network convergence. Finally, max pooling and average pooling were carried out for the learned feature map and the single-channel output of the segmentation network, respectively, and were connected to obtain 66 output neurons. The output of the decision network was obtained through the FC layer and the sigmoid activation function. The specific network structure and parameter configuration of the decision network are shown in Table 2. Table 1 Architecture and parameter settings of the segmentation network. <u>Name</u> <u>Layer</u> <u>Filters</u> <u>Kernel size</u> <u>Dilation rate</u> <u>Stride</u> S1 Conv+BN+Relu 32 3×3 1 1 S2 Conv+BN+Relu 32 3×3 1 1 S3 Maxpool - 2×2 - 2 S4 Conv+BN+Relu 64 3×3 1 1 S5 2-Conv+BN+Relu 64 3×3 2 1 S6 3-Conv+BN+Relu 64 3×3 4 1 S7 Maxpool - 2×2 - 2 S8 Conv+BN+Relu 128 3×3 1 1 S9 2-Conv+BN+Relu 128 3×3 2 1 S10 3-Conv+BN+Relu 128 3×3 4 1 S11 Maxpool - 2×2 - 2 S12 ASPP 256 1×1/3×3 6/12/18 1 S13 Concat 1280 - - S14 Conv 1 1×1 1 1 S15 Conv+BN+Relu 512 3×3 1 1 S16 Conv+BN+Relu 512 3×3 1 1 S17 CBAM 512 3×3/7×7 1 1 <u>S18</u> <u>Conv-Sigmoid</u> <u>1</u> <u>1×1</u> <u>1</u> <u>1</u> Table 2 The architecture and parameter settings of the decision network. <u>Name</u> <u>Layer</u> <u>Filters</u> <u>Kernel size</u> <u>Stride</u> D1 Concat 513 - 1 D2 Maxpool - 2×2 2 D3 Conv+BN+Relu 32 3×3 1 D4 Residual Block 32 3×3 1 D5 Residual Block 32 3×3 1 D6 Maxpool&Meanpool - 2×2 2 D7 Concat 66 - 1 <u>D8</u> <u>FC+Sigmoid</u> <u>1</u> <u>3×3</u> <u>1</u> 3.3 Model training The segmentation task of the segmentation network and the classification task of the decision network can be regarded as the binary classification problem at the pixel level and the image level, respectively. Therefore, the crossentropy loss function of the binary classification (namely BCE loss) is used to train the network. The loss function of the decision network is shown as Eq. (5): <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) H ( y ( x ),y  ( x,  )) = y ( x ) log ( y  ( x,  )) + ( 1 - y ( x )) log ( 1 - y  ( x,  )), (5) where x represents the image-level training sample and y(x) is the label of the input sample x. A value of 1 indicates that the input sample x is a defect image (positive samples), while a value of 0 corresponds to a non-defect image (negative samples). In addition,  is the parameter learned by the network, and the probability value of the input sample x belonging to the defective sample through the parameter  is represented by y  ( x, ) . The loss function of the segmentation network is shown as Eq. (6). N 1 N ##,y  ( xi,  ) = −  y ( xi ) log ( y  ( xi, 1 N ##  y ( xi ),y  ( xi,  ) = − h  w i = 1 y ( xi ) log ( y  ( xi,  )) 1 N ## HX  y ( xi ),y  ( xi,  ) = − h  w i = 1 y ( xi ) log ( y  ( xi,  )) + ( 1 − y ( xi )) log ( 1 − y  ( xi,  )) . (6) 1 The pixel point set of the input sample x is represented by X, N is the total number of pixels in the input sample x, while h, w represents the length and width of the input image respectively. y ( xi ) represents the label of the pixel xi in the input sample x, with a value of 1 or 0 indicating whether the pixel belongs to a defective area. y  ( xi, ) represents the predicted probability that the pixel xi is in a defective area. Since the scale of the objects trained by the segmentation network and the decision network are not consistent, it is necessary to train the segmentation network and the decision network separately to achieve a better effect. The specific method is to first train the segmentation network at the pixel level from 0 and then freeze the trained weights. Only the decision networks are trained at the image level. Fine-tuning the decision network avoids the issue of overfitting from the large number of weights in the segmentation network. In addition, the number of positive and negative samples in the train set are also extremely unbalanced. In this dataset, the number of negative samples is about 8 times higher than the number of positive samples, and the number of pixels in the non-defective area is also much higher than in the defective area. If this phenomenon is ignored, the imbalance will not only slow down the convergence speed of the network but also affect the final detection performance of the model. Therefore, we adopted a new sampling method instead of the original random sampling method to alleviate the imbalance in the dataset. Specifically, the positive and negative samples were trained alternately to ensure that samples of the same category were not continuously trained. In this way, the imbalance in the data set is alleviated. 4. Experimental evaluation 4.1 Dataset The surface defect dataset (KolektorSDD) (Tabernik et al., 2020) is was constructed from defected electrical commutators by the Kolektor team. The surface area of each electrical commutator was completely covered with eight images, which were collected in an industrial environment with a resolution of 1408×512 pixels to ensure high-quality images. A total of 50 defective electrical commutators were sampled in the dataset, each with up to eight relevant surfaces, and a total of 399 images were collected. There were 52 positive sample images with defective areas, and the remaining 347 images were negative samples without defective pixels. In the experiment described herein, the dataset is divided into a train set and a test set at a ratio of 7:3. There are 279 images in the train set, of which 33 are defective images and the rest are non-defective images with no defective pixels. Some positive samples with defective pixels and negative samples without defective pixels are shown in Fig. 5. The first and second rows are non-defective samples and annotations, while the third and fourth rows are the defective samples of defective pixels and annotations. Fig. 5 Samples of defect-free and defective images from magnetic tile dataset. <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) As a common choice, we also evaluated the magnetic tile dataset (MTD) (Huang et al., 2020), which included 1344 non-defective and defected images, totaling 392 defective images and 952 normal images. The defects were divided into 5 categories, namely, blowhole, break, crack, fray, and uneven defects. Samples of normal and defective images are shown in Fig. 6. Similarly, this dataset is divided into a training set and a test set at a ratio of 7:3. The allocation details are shown in Table 3. Table 3 Samples of defect-free and defective images from <u>magnetic tile dataset network.</u> <u>Category</u> <u>Train</u> <u>Test</u> Blowhole 81 34 Break 60 25 Defective Crack 40 17 Fray 23 9 <u>Uneven</u> <u>73</u> <u>30</u> <u>Normal</u> <u>Free</u> <u>667</u> <u>285</u> <u>Total</u> <u>-</u> <u>944</u> <u>400</u> Fig.6 Samples of defect-free and defective images from magnetic tile dataset. 4.2 Performance metrics The model can be evaluated in terms of accuracy and real-time performance. The average precision (AP), falsepositive (FP), and false-negative (FN) results were used as performance metrics to measure the accuracy of the model. In this paper, samples with defective areas were known called positive samples, while the samples without defective pixels were called negative samples. Therefore, FP is the number of non-defective samples that are mistaken for defective samples, and FN represents the number of defective samples mistaken as non-defective samples. The primary metric used in evaluating the accuracy of the model is AP, which is more appropriate than FP or FN, since AP is calculated as the area under the precision-recall curve and accurately captures the performance of the model under different threshold values as a single value. As an alternative method, floating-point operations (FLOPs) and the parameter size of the network can be used to evaluate the real-time performance of the model. The FLOPs can be understood as the computation amount of the model, which is used to measure the complexity of the model. 4.3 Implementation details The network structure was implemented using the PyTorch (Paszke et al., 2017) framework. Both the segmentation network and the decision network were trained using the Adam (Kingma et al., 2014) optimizer with the exponential decay parameters  1 = 0.9 and  2 = 0.99. The dilation rate of the atrous convolution block is 1, 2, 4, the kernel size is 3, and the stride size is 1. The learning rate of the segmentation network was set to 0.01 and the batch size was set to 5, while the learning rate and the batch size of the decision network were set to 0.1 and 7, respectively. The segmentation network and the decision network trained 100 epoch and 20 epoch iterations, respectively, to reach convergence on the KolektorSDD. Due to the limitation of the experimental equipment, the resolution of the input image was preprocessed, and the resolution of each image was set to 704×256 pixels. In the MTD, the segmentation network and the decision network respectively trained 920 epochs and 160 epochs to convergence, and the resolution of the input image was set as 500×500. The experimental development environment is as follows: CPU: AMD Ryzen 5 3600 6-core Processor@ 3.60GHz; GPU: NVIDIA GeForce RTX2060 with 6G memory; software environment: PyCharm, python 3.7.4. 4.4 Comparison with other methods To verify the effectiveness and superiority of the proposed method, this paper compares the proposed method with several mainstream image segmentation methods based on deep learning. The following will be evaluated from the accuracy and real-time performance of the model. 4.4.1 Accuracy comparison of models Experiment 1. Because the detection results of the decision network are more important than the segmentation <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) results of the segmentation network, the evaluation of the decision network is only regarded as the final result to measure the quality of the model. In this paper, the proposed model and other mainstream models based on image segmentation are trained and tested on the KolektorSDD dataset, and the accuracy of the model is evaluated by FN, FP, and AP performance metrics. The results are shown in Table 4. It can be seen from Table 4 that the method proposed in this paper is noticeably superior to the other three methods, reaching the detection result of zero errors. Our model had an AP that was 3.9, 2, and 0.1% more precise than the U-Net (Ronneberger et al., 2015), DeepLab v3+ (Chen et al., 2018), and Segmentation decision net (Tabernik et al., 2020) models, respectively, which satisfies the high-accuracy industry requirements for the surface defect detection of products. Table 4 Comparison of the accuracy of several models Table 5 Real-time comparison of several models on KolektorSDD. on KolektorSDD. <u>Model</u> <u>FN</u> <u>FP</u> <u>AP(%)</u> FLOPs Params Detection Model <u>U-Net</u> <u>4</u> <u>5</u> <u>96.1</u> <u>×10</u> <sup>9</sup> <u>Size</u> <u>Time(ms)</u> <u>DeepLab v3+</u> <u>4</u> <u>2</u> <u>98.0</u> <u>U-Net</u> <u>110.3</u> <u>17.2M</u> <u>62</u> <u>Segmentation decision net</u> <u>0</u> <u>1</u> <u>99.9</u> <u>DeepLab v3+</u> <u>18.2</u> <u>5.8M</u> <u>16</u> <u>Ours</u> <u>0</u> <u>0</u> <u>100.0</u> <u>Segmentation decision net</u> <u>62.8</u> <u>15.4M</u> <u>48</u> <u>Ours</u> <u>23.9</u> <u>5.5M</u> <u>18</u> 4.4.2 Real-time comparison of models Experiment 2. In this experiment, the real-time performances of several models are compared and evaluated. The results of the evaluation are measured by the calculation amount of the model, the size of the parameters, and the detection time of a single image. The results are shown in Table 5. Table 5 shows that the model proposed in this paper takes only 18 ms to detect a single image. Compared with the U-Net and Segmentation decision net models, our model is faster by 44 and 30 ms, respectively. The main reason for this is that our model makes fewer calculations and uses fewer parameters, which are only one-third and one-half that of the U-Net and Segmentation decision net models, respectively. DeepLab v3+ with atrous convolution is also used in the model. The number of parameters and calculation amount of the model were only 18.2 GMac and 5.8 M, and the detection time of a single image was less than that of our model. In an industrial environment, the accuracy and real-time detection of product surface defects are equally important. If we only blindly pursue the accuracy of the detection model and constantly deepen the layers of the network model, then the real-time performance of the model will inevitably be hindered. Therefore, a better product surface defect detection model needs to balance accuracy and real-time performance. To provide a more obvious comparison effect, the comparison results of the above four models on the KolektorSDD dataset were analyzed in regard to the accuracy and real-time performance of the model (Fig. 7). Compared with the U-Net and Segmentation decision nets, the average accuracy of our model and the detection speed of a single image were respectively higher and faster. Compared with the DeepLab v3+ model, although our model takes slightly longer to detect a single image, the accuracy of the defect image detection model is significantly higher. 4.4.3 Comparison of model results Experiment 3. In order to demonstrate the effect of the above four models on the detection and segmentation of product surface defects, the experimental results of the four models on the KolektorSDD dataset were collected (Fig. 8). In Fig. 8(a), the detection ability of each model for the defect sample is shown, and Fig. 8(b) shows the detection ability for the non-defect sample. In Figs. 8(a) and 8(b), the first column is the input original image, the last column is the ground truth label corresponding to the original image, and the middle four columns represent the detection and segmentation results of each model. The value in the segmentation results image represents the probability of the input image being a defect image. The results of Fig. 8(a) show that the defect area segmented by our model on the defect image is closer to the ground truth label, and the probability of predicting that the image is a defect image is also higher. It can be concluded from Fig. 8(b) that our model can exclude the interference of noise when processing non-defective samples and can differentiate non-defective samples more accurately. <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> Table 4 Comparison of the accuracy of several models Table 5 Real-time comparison of several models on KolektorSDD. on KolektorSDD. <u>Model</u> <u>FN</u> <u>FP</u> <u>AP(%)</u> <u>U-Net</u> <u>4</u> <u>5</u> <u>96.1</u> <u>DeepLab v3+</u> <u>4</u> <u>2</u> <u>98.0</u> <u>Segmentation decision net</u> <u>0</u> <u>1</u> <u>99.9</u> <u>Ours</u> <u>0</u> <u>0</u> <u>100.0</u> FLOPs Params Detection Model <u>×10</u> <sup>9</sup> <u>Size</u> <u>Time(ms)</u> <u>U-Net</u> <u>110.3</u> <u>17.2M</u> <u>62</u> <u>DeepLab v3+</u> <u>18.2</u> <u>5.8M</u> <u>16</u> <u>Segmentation decision net</u> <u>62.8</u> <u>15.4M</u> <u>48</u> <u>Ours</u> <u>23.9</u> <u>5.5M</u> <u>18</u> FLOPs Model Params <u>Size</u> <u>×10</u> <sup>9</sup> g g y g ( ) Table 6 Comparison of several models for the MTD. Params Model AUC FLOPs×10 <sup>9</sup> <u>Size</u> <u>DifferNet</u> <u>97.7</u> <u>4.41</u> <u>233.24M</u> <u>GANomaly</u> <u>76.6</u> <u>52.44</u> <u>735.46M</u> <u>MCuePushU</u> <u>98.5</u> <u>158.38</u> <u>19.89M</u> <u>PaDiM</u> <u>98.7</u> <u>58.73</u> <u>68.88</u> <u>Ours</u> <u>99.4</u> <u>32.61</u> <u>5.37M</u> Fig.7 Comparison of detection time of single image Fig.8 Defect segmentation and detection results of several models 4.4.4 The model is evaluated on MTD Experiment 4. To verify the universality and effectiveness of the model, our model is also evaluated on the MTD dataset. In the MTD, we calculate the area under the receiver operating characteristic (AUROC) curve of the image level on each test set to measure the performance of the model defect detection method. As can be seen from Table 6, our model achieved the highest AUROC curve of 99.4%, up to 22.8% higher than that of other models (Rudolph et al., 2020, Huang et al., 2020; Samet et al., 2018; Thomas et al., 2021). It can be seen from the data in the last two columns of Table 6 that the complexity of our model is much lower than that of other models, and the amount of calculations and parameter size is only 32.61 GMac and 5.37 M, respectively. Although the amount of computation of our model is higher than that of DifferNet, the number of parameters employed was much fewer and the AUC of our model was 1.7% higher compared to DifferNet. Unlike other networks, DifferNet is mainly composed of fully connected layers and has fewer convolution layers. However, fully connected layers contribute much less to model computation and much more to the model parameter number compared to convolution layers. This explains the large number of parameters, shown in Table 6, as well as the lower computational ability of DifferNet compared to other models. The ROC curve in Fig. 9 shows that our method provides a higher true positive rate for any false positive rate. <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) 5. Ablation studies To better understand the influence of CBAM, atrous convolution, and ASPP modules on model performance, ablation experiments were conducted. All the studies were conducted using the same computer equipment. CBAM, atrous convolution, and ASPP modules were added to the proposed model gradually, and the KolektorSDD dataset was configured with the same hyperparameter for training and testing and the experimental results are shown in Table 7. The first three columns respectively indicate whether CBAM, atrous convolution, or ASPP modules are embedded in the model, while the last three columns show the performance of the corresponding models. It can be seen from rows 1 and 2 of Table 7 that the introduction of CBAM can effectively improve the detection accuracy of the model with negligible overheads. This is because CBAM not only improves the representational ability of CNN but also allocates different weights according to the importance of information, which greatly improves the accuracy of the model. Comparing rows 2 and 3, the introduction of atrous convolution into the network will greatly reduce the number of computations and parameters in the network. It greatly simplifies the network structure of the model, speeds up the detection speed of the model, and ensures that its detection performance is not affected. Based on the data shown in rows 3 and 4, it can be concluded that the introduction of ASPP in the model can greatly increase the capability of the model to detect defects, which verifies the effectiveness of the multi-scale sampling method for a given feature map with different rates of atrous convolution. Therefore, the combination of CBAM, atrous convolution, and ASPP technology in the model can not only improve the detection accuracy of the network but also reduce its complexity, thus achieving a good balance between the accuracy and real-time performance of the model in the detection of defects. <u>Table 7 Results of networks with different embedded modules on KolektorSDD.</u> CBAM Atrous Convolution ASPP AP(%) FLOPs×10 <sup>9</sup> Params Size 96.17 39.35 4.75M √ 98.57 39.35 4.82M √ √ 98.57 18.68 3.67M <u>√</u> <u>√</u> <u>√</u> <u>100.0</u> <u>23.90</u> <u>5.37M</u> In order to obtain the most reasonable dilation rate configuration of the atrous convolution block, we grouped every 3 blocks and changed their dilation rates. As shown in Table 8, we conducted experiments on 5 groups of convolution blocks with different dilation rates, where (1, 2, 1) represents the dilation rates of 3 blocks as 1, 2, and 1, respectively. It can be concluded from Table 8 that as the expansion rate increases, the receptive field of the model also increases. The accuracy of the model defect detection method first increases and then decreases as the expansion rate increases, reaching a maximum when the dilation rate is (1, 2, 4). It was found that when the receptive field of the network becomes too large, the receptive field may lose image detail, reducing the defect detection accuracy of the model. Therefore, we chose the atrous convolution block with a dilation rate of (1, 2, 4) as the final model configuration. Table 8 Comparison of several models for the MTD. <u>Dilation rates</u> <u>Maxinum receptive field</u> <u>AP(%)</u> <u>(1,2,1)</u> <u>3×3</u> <u>98.56</u> <u>(1,2,2)</u> <u>5×5</u> <u>99.03</u> <u>(1,2,3)</u> <u>7×7</u> <u>99.42</u> <u>(1,2,4)</u> <u>9×9</u> <u>100.0</u> <u>(1,2,5)</u> <u>11×11</u> <u>98.72</u> Fig.9 ROC-Curve for different methods for detecting defects in MTD <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) 6. Conclusion In this paper, an efficient surface defect detection model based on CBAM and atrous convolution has been proposed for the detection of product surface defects in an industrial environment, effectively performing segmentation and detection tasks to detect the surface defects of the products. In addition, CBAM, atrous convolution, and ASPP were introduced into the segmentation network and achieved good results in both accuracy and speed of detection. Experimental results revealed that the proposed model performed better than current mainstream defect detection methods for both KolektorSDD and magnetic tile datasets. However, when training the segmentation network, a small number of images with pixel-level annotations on defective images were still needed as training data. To remove the limitation of the required pixel-level annotation data on the model, improving the learning method of the entire model to weakly supervised or even unsupervised learning has become the direction of subsequent research. Acknowledgements This work is supported by the National Natural Science Foundation of China, under Grant No. 61762037 and No. 62162026, the Science and Technology Key Research and Development Program of Jiangxi Province, under Grant No. 20202BBEL53004, Science and Technology Project supported by Education Department of Jiangxi Province, under Grant No. GJJ210611 and Innovation Fund Designated for Graduate Students of Jiangxi Province, under Grant No. YC2020-S366. Conflict of interest All the authors do not have any possible conflicts of interest. References Chen, L., Papandreou, G., Kokkinos, I., Murphy, K. and Yuille, A. L., Semantic Image Segmentation with Deep Convolutional Nets and Fully Connected CRFs, International Conference on Learning Representations (2014), pp.357-361. Chen, L., Papandreou, G., Kokkinos, I., Murphy, K. and Yuille, A. L., DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol.40, No.4 (2016), pp.834-848. Chen, L., Papandreou, G., Schroff, F. and Adam H., Rethinking Atrous Convolution for Semantic Image Segmentation (2017), DOI:10.48550/arXiv.1706.05587. Chen, L., Zhu, Y., Papandreou, G., Schroff, F. and Adam, H., Encoder-decoder with atrous separable convolution for semantic image segmentation, European Conference on Computer Vision (2018), pp.833-851. He, D., Xu, K., Zhou, P. and Zhou, D., Surface defect classification of steels with a new semi-supervised learning method, Optics and Lasers in Engineering (2019), Vol. 117, pp.40-48. He, K., Zhang, X., Ren, S. and Sun, J., Spatial pyramid pooling in deep convolutional networks for visual recognition, European Conference on Computer Vision (2014), pp.346-361. He, Y., Song, K., Dong, H. and Yan, Y., Semi-supervised defect classification of steel surface based on multi-training and generative adversarial network, Optics and Lasers in Engineering, Vol.122 (2019), pp.294-302. He, Y., Song, K., Meng, Q. and Yan, Y., An End-to-End Steel Surface Defect Detection Approach via Fusing Multiple Hierarchical Features, IEEE transactions on instrumentation and measurement, Vol. 69, No.4 (2020), pp.1493-1504. Huang, Y., Qiu, C. and Yuan, K., Surface defect saliency of magnetic tile, The Visual Computer, Vol 36, No.1 (2020), pp. 85–96. Huang, Z., Mao, J., Wang, Y., Zhou, X., Li, Y. and Liu, X., Research on beer bottle defect classification detection method based on machine vision, Journal of Electronic Measurement and Instrumentation, Vol.30 (2016), pp.873-879. Kingma, D., Ba, J., Adam: A Method for Stochastic Optimization (2014), DOI: 10.48550/arXiv.1412.6980. Krizhevsky, A., Sutskever, I. and Hinton, G. E., ImageNet classification with deep convolutional neural networks, Conference and Workshop on Neural Information Processing Systems (2012), pp.1097-1105. Lin, D., Cao, Y., Zhu, W. and Li, Y., Few-Shot Defect Segmentation Leveraging Abundant Normal Training Samples <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u> g g y g ( ) Through Normal Background Regularization and Crop-and-Paste Operation (2021), DOI:10.48550/arXiv.2007.0 9438. Liu, S., Huang, D., Wang, Y., Receptive Field Block Net for Accurate and Fast Object Detection, European Conference on Computer Vision (2018), pp.404-419. Lin, T., RoyChowdhury, A. and Maji, S., Bilinear Convolutional Neural Networks for Fine-Grained Visual Recognition, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol.40, No,6 (2018), pp.1309-1322. Liu, W., Anguelov, D., Erhan, D., Szegedy, C., Reed, S., Fu, C. and Berg, A., SSD: Single Shot MultiBox Detector, European Conference on Computer Vision (2016), pp.21-37. Mei, S., Yang, H. and Yin, Z., An Unsupervised-Learning-Based Approach for Automated Defect Inspection on Textured Surfaces, IEEE Transactions on Instrumentation and Measurement, Vol.67, No,6 (2018), pp.1266-1277. Mnih, V., Heess, N., Graves, A., Kavukcuoglu, K., Recurrent Models of Visual Attention, Conference and Workshop on Neural Information Processing Systems (2014), pp.2204-2212. Paszke, A., Gross, S., Chintala, S., Chanan, G., Yang, E., DeVito, Z., Lin, Z., Desmaison, A., Antiga, L. and Lerer, A., Automatic differentiation in pytorch, NIPS Autodiff Workshop (2017), pp.1-4. Qiu, L., Wu, X. and Yu, Z., A High-Efficiency Fully Convolutional Networks for Pixel-Wise Surface Defect Detection, IEEE Access, Vol.7 (2019), pp.15884-15893. Ronneberger, O., Fischer, P., and Brox, T., U-Net: Convolutional networks for biomedical image segmentation, Medical Image Computing and Computer-Assisted Intervention (2015), pp.234-241. Rudolph, M., Wandt, B. and Rosenhahn, B., Same Same But DifferNet: Semi-Supervised Defect Detection with Normalizing Flows, IEEE Winter Conference on Applications of Computer Vision (2020), pp.9876-9885. Samet, A., Amir, A. and Toby, P. B., Ganomaly: Semi-supervised anomaly detection via adversarial training, Asian Conference on Computer Vision (2018), pp.622–637. Shen, Z., Wang, S., Dou, J. and Tu, Z., Design and Implementation of PCB Detection and Classification System Based on Machine Vision, Advanced Manufacturing and Automation VIII, Vol.484 (2018), pp.253-261. Su, B., Zhou, Z., Chen, H. and Cao, X., SIGAN: A Novel Image Generation Method for Solar Cell Defect Segmentation and Augmentation (2021), DOI:10.48550/arXiv.2104.04953. Sun, J., Li, C., Wu, X., Palade, V. and Fang, W., An Effective Method of Weld Defect Detection and Classification Based on Machine Vision, IEEE Transactions on Industrial Informatics, Vol.15, No.12 (2019), pp.6322-6333. Tabernik, D., Sela, S., Skvarc, J. and Skocaj, D., Segmentation-based deep-learning approach for surface-defect detection, Journal of Intelligent Manufacturing, Vol.31, No.3 (2020), pp.759-776. Tang, Z., Tian, E., Wang, Y., Wang, L. and Yang, T., Non-Destructive Defect Detection in Castings by Using Spatial Attention Bilinear Convolutional Neural Network, IEEE Transactions on Industrial Informatics, Vol.17, No.1 (2020), pp.82-89. Thomas, D., Aleksandr, S., Angelique, L. and Romaric, A., Padim: a patch distribution modeling framework for anomaly detection and localization (2021), DOI:10.48550/arXiv.2011.08785. Wang, F., Jiang, M., Qian, C., Yang, S., Li, C., Zhang, H., Wang, X. and Tang, X., Residual Attention Network for Image Classification, IEEE Conference on Computer Vision and Pattern Recognition (2017), pp.6450-6458. Wang, P., Chen, P., Yuan, Y., Liu, D., Huang, Z., Hou, X. and Cottrell, G., Understanding Convolution for Semantic Segmentation, IEEE Winter Conference on Applications of Computer Vision (2018), pp.1451-1460. Woo, S., Park, J., Lee, JY. and Kweon, I. S., CBAM: Convolutional Block Attention Module, European Conference on Computer Vision (2018), pp.3-19. Xie, X., Ge, S., Xie, M., Hu, F. and Jiang, N., An improved industrial sub-pixel edge detection algorithm based on coarse and precise location, Journal of Ambient Intelligence and Humanized Computing,Vol.11,No.5(2019), pp.2061-2070. Xu, L., Lv, S., Deng, Y. and Li, X., A Weakly Supervised Surface Defect Detection Based on Convolutional Neural Network, IEEE Access, Vol.8 (2020), pp.42285-42296. Yu, F. and Koltun, V., Multi-Scale Context Aggregation by Dilated Convolutions, International Conference on Learning Representations (2016), pp.187-190. Zhao, Z., Li, B., Dong, R. and Zhao, P., A Surface Defect Detection Method Based on Positive Samples, Pacific Rim International Conference on Artificial Intelligence (2018), pp.473-481. Zheng, H., Fu, J., Mei, T. and Luo, J., Learning Multi-attention Convolutional Neural Network for Fine-Grained Image Recognition, IEEE International Conference on Computer Vision (2017), pp.5219-5227. <u><mark>[DOI</mark></u> <u><mark>10 1299/j</mark></u> <u><mark>d</mark></u> <u><mark>2022j</mark></u> <u><mark>d</mark></u> <u><mark>0063]</mark></u> <u><mark>© 2022 Th</mark></u> <u><mark>J</mark></u> <u><mark>S</mark></u> <u><mark>i</mark></u> <u><mark>t</mark></u> <u><mark>f M</mark></u> <u><mark>h</mark></u> <u><mark>i</mark></u> <u><mark>l E</mark></u> <u><mark>i</mark></u>

섹션 본문 67문단 · 68,805자

(제목 없음)

1Given the shortcomings of conventional machine vision-based surface defect detection methods, including their low accuracy, long development cycle, and poor generalization ability, this paper proposes a surface defect detection model based on the convolutional block attention module and atrous convolution. This model combines the surface defect segmentation task of the product with the classification task, obtains contextual information of the image at multiple scales using atrous spatial pyramid pooling, and then uses the convolutional block attention module to reallocate the weighting of the network to enhance focus on the defect area and improve the discrimination of extracted features. In addition, atrous convolution was introduced in the deep network to simplify the model when used in defect segmentation tasks and enhances the real-time performance of the model defect detection method. Experiments show the superior accuracy and real-time performance of the proposed model when compared with current mainstream surface defect detection methods and indicate its wide applicability in the detection of surface defects in industrial products. relationship between inputs and outputs hidden in a large amount of training data by using a multi-layer neural network structure, which does not need any precise mathematical expression. Qiu et al. proposed a three-stage defect detection model, which uses a fully convolutional network (FCN) as the basic framework. In the model, separable convolution is used instead of standard convolution to efficiently achieve the pixel-level segmentation of defect images(Qiu et al., 2019). Zhao et al. constructed the model using an auto-encoder (AE) and generative adversarial networks (GANs) and then used local binary pattern (LBP) to detect and locate defects (Zhao et al., 2018). He et al. combined convolutional auto-encoders (CAEs) and GANs to construct a model to accurately detect and classify defects on seven hot-rolled plates (He et al., 2019). Mei et al. proposed a defect detection and localization method that only requires training on non-defect images. It combines the idea of an image pyramid hierarchy with convolutional denoising autoencoder (CDAE) networks to perform defect detection on texture images (Mei et al., 2018). He et al. proposed an end-to-end steel surface defect detection method, which uses a baseline CNN to generate feature maps at each stage, and then the proposed multilevel feature fusion network (MFN) to fuse multiple hierarchical features (He et al., 2020). For these multi-level features, the region proposal network (RPN) is used to generate a region of interest (ROI). For each ROI, a classifier and a bounding box regressor generate the final detection result. Tang et al. proposed an end-to-end spatial attention bilinear convolutional neural network (SA-BCNN), combining the spatial attention mechanism in the deep convolutional neural network and bilinear pool technology, which can enhance the representation ability of CNN and extract more detailed image features, to improve the defect detection ability of the model (Tang et al., 2020). To address the difficulty of defect data collection and the expenses of labeling, He et al. proposed a multi-training semi-supervised method based on DCGAN and Resnet18 and applied it to steel surface defect classification. The method uses GAN to generate a large number of unlabeled samples, and then trains them with classifiers of two different learning strategies. The labeled and unlabeled samples are fused into the semi-supervised learning process to provide sufficient defect data (He et al., 2019).Similarly, Su et al. proposed a new approach to defect segmentation using generative adversarial networks. First, the GAN-based method removes the defect region in the input defective image to obtain a defect-free image while keeping the background almost unchanged. Then, the subtracted image is obtained by taking the difference between the defective input image and the generated defect-free image. Finally, the defect region can be segmented by thresholding the subtracted image(Su et al., 2021). Lin et al. proposed Normal Background Regularization and Crop-and-Paste operations, using abundant Normal image training models without defects to segment defect data with few-shot learning, to prevent model overfitting caused by very limited defect training images (Lin et al., 2020). Although the above-mentioned deep learning-based defect detection methods have solved part of the task of defect detection, the network structure constructed by some methods is too complex to satisfy the real-time requirements for defect detection in an industrial environment. In addition, some networks cannot effectively eliminate the influence of background information on defect images in a relatively complex acquisition environment, which causes part of background noise to be mistaken for defect pixels and affects the accuracy of the defect detection method.Hence, we propose a deep learning network model based on the convolutional block attention module (CBAM)(Woo et al., 2018)and atrous convolution(Yu and Koltun, 2016). The model is composed of a segmentation network and a decision network. The segmentation network and the decision network share some parameters, and the segmentation results of the segmentation network can help the decision network to more accurately detect defects. Our model performs better than current mainstream defect detection methods on both KolektorSDD and magnetic tile datasets. The main contributions are as follows:1) A surface defect detection model based on CBAM and atrous convolution is proposed to detect and segment product surface defects, which can satisfy the high accuracy and real-time requirements of industrial defect detection.2) The CBAM with negligible overheads was introduced into the segmentation network. It can not only improve the ability of the CNN to process fine-grained image classification but also reallocate the weighting of feature maps, enhancing the feature extraction ability of the network and improving the detection performance of the network. 3) We replace the standard convolution with atrous convolution in the segmentation network, and expand the receptive field while maintaining the same parameters and computations, simplify the model parameters and computational amount, and enhance the real-time performance of the model for defect detection. In addition, to address the gridding effect of atrous convolution, we used hybrid dilated convolution to design the structure of the convolutional layers, which means all the pixels of the input sample are involved in the calculation and As a common choice, we also evaluated the magnetic tile dataset (MTD)(Huang et al., 2020), which included 1344 non-defective and defected images, totaling 392 defective images and 952 normal images. The defects were divided into 5 categories, namely, blowhole, break, crack, fray, and uneven defects. Samples of normal and defective images are shown inFig. 6. Similarly, this dataset is divided into a training set and a test set at a ratio of 7:3. The allocation details are shown inTable 3.Performance metricsThe model can be evaluated in terms of accuracy and real-time performance. The average precision (AP), falsepositive (FP), and false-negative (FN) results were used as performance metrics to measure the accuracy of the model. In this paper, samples with defective areas were known called positive samples, while the samples without defective pixels were called negative samples. Therefore, FP is the number of non-defective samples that are mistaken for defective samples, and FN represents the number of defective samples mistaken as non-defective samples. The primary metric used in evaluating the accuracy of the model is AP, which is more appropriate than FP or FN, since AP is calculated as the area under the precision-recall curve and accurately captures the performance of the model under different threshold values as a single value. As an alternative method, floating-point operations (FLOPs) and the parameter size of the network can be used to evaluate the real-time performance of the model. The FLOPs can be understood as the computation amount of the model, which is used to measure the complexity of the model.

Introduction

2In industrial manufacturing, in order to ensure the quality of products, the most effective way is to inspect the surface of the product. Usually, it is trained workers who identify complex surface defects, but this method is susceptible to worker inexperience and subjective factors. This time-consuming and unreliable process cannot be adapted to the developing trend of industrial automation. With the development of intelligent manufacturing, defect detection technology based on machine vision (MV) is favored by most scholars. Sun et al. proposed a background subtraction method based on the Gaussian mixture model to extract the feature area of weld defects and designed a weld detection and classification algorithm (Sun et al., 2019). Shen et al. used template matching and sub-pixel precision to precisely position a printed circuit board (PCB) and then used smart cameras and industrial robots to complete the PCB defect detection (Shen et al., 2018). Huang et al. used a support vector machine (SVM) classifier to identify six common glass bottle defects, which addresses the low classification accuracy of existing machine vision defect detection systems (Huang et al., 2016). Xie et al. proposed an improved sub-pixel detection algorithm combining coarse and fine positioning, using Otsu's method to achieve sub-pixel precise positioning (Xie et al., 2016). The above methods can satisfy the defect detection and classification requirements for specific problems to a certain extent. However, it is difficult to satisfy the real-time, high-accuracy, and generality requirements of defect detection in most industrial environments using defect detection methods based on machine vision due to their long development cycle, the interference of acquisition environmental noise, and the difficulty in finding a general template as a reference for various detection objects.

3In recent years, with the development of deep learning (DL), especially the in-depth study of convolutional neural networks (CNNs), deep learning has been successfully applied to various image-related tasks (Krizhevsky et al., 2012). Different from conventional machine vision methods, a deep learning algorithm can effectively learn the mapping improves the performance of the network. In this paper, the most suitable configuration of atrous convolution layer is found through ablation studies. 4) Atrous spatial pyramid pooling (ASPP) (Chen et al., 2017) is used to obtain multi-scale information of images, to enhance the detection ability of defects of different sizes of the model and enhance the universality of the model.

Relevant theoretical

4To extract better features, accelerate the detection speed of the model, and enhance the real-time performance of the model, the CBAM, atrous convolution, and ASPP were introduced into the segmentation network model.

Convolutional block attention module

5The attention mechanism was first proposed in the images (Mnih et al., 2014). The introduction of the attention mechanism in the image field is a very critical technique to enable the deep network model to better focus on a local area of interest to the user while suppressing other areas that are not important. In recent years, models based on attention mechanisms have become a hot research topic and are widely used in various types of deep learning tasks such as natural language processing, image recognition (Wang et al., 2017;Xu et al., 2020), and speech recognition. CBAM is also one of many attention mechanisms, not only telling the user where to focus on but also enhancing the feature extraction ability of the area of interest. It is composed of a channel attention module and a spatial attention module that perform attention operations on the channel and spatial dimensions of the image, respectively. In addition, the use of CBAM can also improve the representational ability of CNN, force CNN to extract fine-grained image features, and make the extracted features more discriminative. The network structure of CBAM is shown in Fig. 1. The module first performs channel attention operation on the feature map to increase the weighting of effective channels and reduce the weighting of invalid channels. As shown in Eq. (1), where c M refers to the channel attention module, F is the input feature map, and the variables avg c F , max c F represent the use of average pooling and max pooling operations to aggregate the spatial information of the feature map, respectively.

6The Hadamard product operation can be carried out between the feature graph  F generated by the channel attention module and the input feature graph F to obtain the input of the spatial attention module. The spatial attention module is then used to increase the attention given to the regions of interest in the spatial dimension. This is shown in Eq. (2) Xie, Xu, Li, Wang and Wan, Journal of Advanced Mechanical Design, Systems, and Manufacturing, Vol.16, No.6 (2022) Finally, the modified feature map is generated by Hadamard product of the feature graph  F of the perform spatial attention module and the input feature map  F .

Atrous convolution

7In the field of image semantic segmentation, it is often necessary to make dense predictions of the full resolution of the image. The designed network not only needs to pay attention to local information but also global information, which requires the network to have a larger receptive field. In general, in order to obtain a larger receptive field, a typical segmentation network uses a large-size convolution kernel with a large number of parameters, so the network becomes relatively complex and requires a lot of computing resources. Atrous convolution is a kind of convolution method proposed to solve this problem. It can increase the receptive field of the network and reduce the training time of the model while maintaining the number of network parameters and calculations. Many classical semantic segmentation networks have also adopted this idea of convolution, such as the Deeplab series (Chen et al., 2014;Chen et al., 2016). Deeplab replaces standard convolution in the network with atrous convolution, and the multi-scale atrous convolution operation of the input image can be performed, greatly reducing the complexity of the network. SSD and RFBNet ) also refer to this convolution method to simplify the network in object detection.

8Atrous convolution is often used to deal with how global information is needed in image segmentation or the need for long sequence information in speech text. It introduces a hyper-parameter called a "dilation rate" to the standard convolution, which defines the distance between each element of the convolution kernel. In other words, compared with standard convolution, atrous convolution adds a new hyper-parameter of dilation rate, whose value is equal to the number of intervals between elements of the convolution kernel. Standard convolution is actually atrous convolution with a dilation rate of 1. The introduction of atrous convolution to the network can not only avoid information loss caused by the pooling operation but also increase the receptive field of the network, allowing the network to better capture the global information of the input image. For example, by adding a hole to the standard convolution, the original 3×3 standard convolution kernel can have a larger receptive field of a 5×5 (dilated rate = 2) standard convolution kernel with the same number of parameters and calculation, which avoids the downsampling operation. Atrous convolution is defined as:

9where f[i] and g [i] are the input and output feature maps respectively, k[l] represents the convolution kernel of length l, and r is the dilated rate of the atrous convolution. When the atrous convolution is performing the convolution operation, the value of the atrous position is 0. Figure 2 illustrates the atrous convolution kernels with three different dilation rates. From left to right are the atrous convolution kernels with dilation rates r = 1, 2, and 4. As the dilation rate increases, the receptive field of the convolution kernel also becomes larger, corresponding to 3×3, 5×5, and 9×9 kernel, respectively. The receptive field of the atrous convolution is calculated as Eq. (4):

10where r is the dilation rate, k is the size of the convolution kernel, and R is the actual receptive field. Although atrous convolution has the above advantages, the random design of the dilation rate in the atrous convolution or any combination of atrous convolution in the network may greatly reduce the performance of the network. Wang et al. pointed out that blindly designing the dilation rate of the atrous convolution will make some pixels of the input sample not participate in the calculation, resulting in the gridding effect and affecting the accuracy of the network . This problem can be avoided by following hybrid dilated convolution in designing the structure of atrous convolution in the network.

Atrous spatial pyramid pooling

11Another challenge of deep convolutional neural networks for image segmentation is dealing with the existence of objects at multiple scales. A common method used to solve this is to combine the images of different scales obtained from the input image by rescaling the operation as the input of the network (Rudolph et al., 2018). This method can indeed improve the segmentation effect of the model but it also creates a computational burden, which hinders the realtime performance of the model. Another effective method is to use ASPP to resample the feature maps obtained by the deep convolutional neural network at different scales to obtain feature maps with rich contextual information.

12Motivated by spatial pyramid pooling (He et al., 2014), Chen et al. proposed ASPP, which uses multiple parallel atrous convolutions with different dilation rates to perform multi-scale sampling for a given feature map (Chen et al., 2016). This is equivalent to using multiple convolution kernels with different receptive fields to resample a given feature map, so the contextual information provided by the image can be captured at multiple scales. In order to further capture global information, Chen et al. augmented ASPP with image-level features (Chen et al., 2017). Figure 3 shows the structure of ASPP with an augmented image-level feature. The improved ASPP uses one 1×1 convolution, three 3×3 atrous convolutions with dilation rates equal to 6, 12, and 18, and image-level feature pooling to perform multi-scale sampling on the input feature map. The resulting features were then concat to obtain an output feature map with rich contextual information.

13Three kinds of atrous convolution kernels with different dilation rates.

Surface defect detection method based on CBAM and atrous convolution

14A surface defect detection model based on CBAM and atrous convolution was designed, as shown in Fig. 4. The model is mainly composed of a segmentation network and a decision network that are used to segment and detect surface defects, respectively. In the segmentation network, the data features of the input samples are first learned and a binary segmentation map is generated. Each pixel in the input samples is taken as a separate training sample for the network to increase the effective number of training samples and avoid overfitting. In the decision network, the feature map learned in the segmentation network and the segmentation results generated are used as the input of the decision network. The segmentation result is used to help the decision network better judge whether the input sample contains defects. Then, a denser and smaller space feature map is obtained after a series of convolutional and pooling operations, followed by the fully connected layer (FC) and sigmoid activation function. The final obtained input sample is the predicted value of the defective image. Fig. 4 The network model structure of the proposed.

15It has been noted that CNN has poor performance in fine-grained image classification, but the surface defect segmentation task needs to deal with defects at the pixel level (Zheng et al., 2017;Lin et al., 2018). Therefore, a CBAM with negligible overheads was introduced into the segmentation network. It can not only improve the ability of the CNN to process fine-grained image classification but also reallocate the weighting of feature maps, improve the attention given to the region of interest, and suppress other invalid information. At the same time, the atrous convolution layer was also designed following the idea of HDC in the segmentation network, which increases the receptive field of the network and simplifies the complexity of the model. In addition, in order to obtain multi-scale information from images, features with rich contextual information are extracted by ASPP to improve the accuracy of the segmentation results of the segmentation network with a small overhead. These factors allow the designed model to satisfy the requirements of high accuracy and strong real-time performance for the industrial surface defect detection method.

Design of the segmentation network

16First, the segmentation network learns the features of the input samples from 8 convolutional layers and 3 pooling layers and generates a feature map with 128 channels. In Fig. 4, 2-conv and 4-conv represent the atrous convolution dilation rates of 2 and 4, respectively. The convolution layer mentioned includes the batch normalization (BN) and nonlinear ReLU layer. When designing the convolutional layer, the kernel size is 3, the stride is 1, and the dilation rate is [1, 2, 4] as a basic convolution block, which satisfies the idea of HDC design. The use of a 2×2 kernel pooling layer in the network can not only reduce the computational burden of the network but also eliminate the interference information of invalid noise. Next, ASPP is used to further obtain multi-scale information of the image. Before passing through two convolutional layers with 512 channels, a 1×1 convolutional layer is used to map the number of channels of the feature map to 512 for consistency with the number of subsequent convolutional layer channels. Then, the CBAM is used to adjust the weight distribution of the feature maps to create a stronger representational ability and improve the segmentation accuracy of the segmentation network. Finally, a 1×1 convolutional layer and a sigmoid activation function are used to map the output results between 0 and 1 to generate a single-channel segmentation result whose resolution is 1/8 of the input image. The structure of the segmentation network and the detailed parameters settings are shown in Table 1. Xie, Xu, Li, Wang and Wan, Journal of Advanced Mechanical Design, Systems, and Manufacturing, Vol.16, No.6 (2022)

Design of the decision network

17The decision network connects the feature map (512 channels) modified by the CBAM in the segmentation network with the segmentation result (1 channel) output by the segmentation network and produces a feature map with 513 channels as the input of the decision network (see Fig. 4). In order to force the decision network to learn global information more easily and reduce the number of network calculations, a max-pooling layer with a step size of 2 is used to halve the length and width of the feature map. Then, a 3×3 convolutional layer and two residual blocks are used to learn the feature map after pooling. Each convolutional layer is followed by a BN and nonlinear ReLU layer to accelerate network convergence. Finally, max pooling and average pooling were carried out for the learned feature map and the single-channel output of the segmentation network, respectively, and were connected to obtain 66 output neurons. The output of the decision network was obtained through the FC layer and the sigmoid activation function. The specific network structure and parameter configuration of the decision network are shown in Table 2.

Model training

18The segmentation task of the segmentation network and the classification task of the decision network can be regarded as the binary classification problem at the pixel level and the image level, respectively. Therefore, the crossentropy loss function of the binary classification (namely BCE loss) is used to train the network. The loss function of the decision network is shown as Eq. (5)

19where x represents the image-level training sample and y(x) is the label of the input sample x. A value of 1 indicates that the input sample x is a defect image (positive samples), while a value of 0 corresponds to a non-defect image (negative samples). In addition,  is the parameter learned by the network, and the probability value of the input sample x belonging to the defective sample through the parameter  is represented by

20. The loss function of the segmentation network is shown as Eq. (6).

21The pixel point set of the input sample x is represented by X, N is the total number of pixels in the input sample x, while h, w represents the length and width of the input image respectively. Since the scale of the objects trained by the segmentation network and the decision network are not consistent, it is necessary to train the segmentation network and the decision network separately to achieve a better effect. The specific method is to first train the segmentation network at the pixel level from 0 and then freeze the trained weights. Only the decision networks are trained at the image level. Fine-tuning the decision network avoids the issue of overfitting from the large number of weights in the segmentation network.

22In addition, the number of positive and negative samples in the train set are also extremely unbalanced. In this dataset, the number of negative samples is about 8 times higher than the number of positive samples, and the number of pixels in the non-defective area is also much higher than in the defective area. If this phenomenon is ignored, the imbalance will not only slow down the convergence speed of the network but also affect the final detection performance of the model. Therefore, we adopted a new sampling method instead of the original random sampling method to alleviate the imbalance in the dataset. Specifically, the positive and negative samples were trained alternately to ensure that samples of the same category were not continuously trained. In this way, the imbalance in the data set is alleviated.

Experimental evaluation 4.1 Dataset

23The surface defect dataset (KolektorSDD) (Tabernik et al., 2020) is was constructed from defected electrical commutators by the Kolektor team. The surface area of each electrical commutator was completely covered with eight images, which were collected in an industrial environment with a resolution of 1408×512 pixels to ensure high-quality images. A total of 50 defective electrical commutators were sampled in the dataset, each with up to eight relevant surfaces, and a total of 399 images were collected. There were 52 positive sample images with defective areas, and the remaining 347 images were negative samples without defective pixels. In the experiment described herein, the dataset is divided into a train set and a test set at a ratio of 7:3. There are 279 images in the train set, of which 33 are defective images and the rest are non-defective images with no defective pixels. Some positive samples with defective pixels and negative samples without defective pixels are shown in Fig. 5. The first and second rows are non-defective samples and annotations, while the third and fourth rows are the defective samples of defective pixels and annotations.

Implementation details

24The network structure was implemented using the PyTorch (Paszke et al., 2017) framework. Both the segmentation network and the decision network were trained using the Adam (Kingma et al., 2014) optimizer with the exponential decay parameters 1  = 0.9 and 2  = 0.99. The dilation rate of the atrous convolution block is 1, 2, 4, the kernel size is 3, and the stride size is 1. The learning rate of the segmentation network was set to 0.01 and the batch size was set to 5, while the learning rate and the batch size of the decision network were set to 0.1 and 7, respectively. The segmentation network and the decision network trained 100 epoch and 20 epoch iterations, respectively, to reach convergence on the KolektorSDD. Due to the limitation of the experimental equipment, the resolution of the input image was preprocessed, and the resolution of each image was set to 704×256 pixels. In the MTD, the segmentation network and the decision network respectively trained 920 epochs and 160 epochs to convergence, and the resolution of the input image was set as 500×500.

25The experimental development environment is as follows: CPU: AMD Ryzen 5 3600 6-core Processor@ 3.60GHz; GPU: NVIDIA GeForce RTX2060 with 6G memory; software environment: PyCharm, python 3.7.4.

Comparison with other methods

26To verify the effectiveness and superiority of the proposed method, this paper compares the proposed method with several mainstream image segmentation methods based on deep learning. The following will be evaluated from the accuracy and real-time performance of the model.

Accuracy comparison of models

27Experiment 1. Because the detection results of the decision network are more important than the segmentation results of the segmentation network, the evaluation of the decision network is only regarded as the final result to measure the quality of the model. In this paper, the proposed model and other mainstream models based on image segmentation are trained and tested on the KolektorSDD dataset, and the accuracy of the model is evaluated by FN, FP, and AP performance metrics. The results are shown in Table 4. It can be seen from Table 4 that the method proposed in this paper is noticeably superior to the other three methods, reaching the detection result of zero errors. Our model had an AP that was 3.9, 2, and 0.1% more precise than the U-Net (Ronneberger et al., 2015), DeepLab v3+ , and Segmentation decision net (Tabernik et al., 2020) models, respectively, which satisfies the high-accuracy industry requirements for the surface defect detection of products.

Real-time comparison of models

28Experiment 2. In this experiment, the real-time performances of several models are compared and evaluated. The results of the evaluation are measured by the calculation amount of the model, the size of the parameters, and the detection time of a single image. The results are shown in Table 5. Table 5 shows that the model proposed in this paper takes only 18 ms to detect a single image. Compared with the U-Net and Segmentation decision net models, our model is faster by 44 and 30 ms, respectively. The main reason for this is that our model makes fewer calculations and uses fewer parameters, which are only one-third and one-half that of the U-Net and Segmentation decision net models, respectively. DeepLab v3+ with atrous convolution is also used in the model. The number of parameters and calculation amount of the model were only 18.2 GMac and 5.8 M, and the detection time of a single image was less than that of our model.

29In an industrial environment, the accuracy and real-time detection of product surface defects are equally important. If we only blindly pursue the accuracy of the detection model and constantly deepen the layers of the network model, then the real-time performance of the model will inevitably be hindered. Therefore, a better product surface defect detection model needs to balance accuracy and real-time performance. To provide a more obvious comparison effect, the comparison results of the above four models on the KolektorSDD dataset were analyzed in regard to the accuracy and real-time performance of the model (Fig. 7). Compared with the U-Net and Segmentation decision nets, the average accuracy of our model and the detection speed of a single image were respectively higher and faster. Compared with the DeepLab v3+ model, although our model takes slightly longer to detect a single image, the accuracy of the defect image detection model is significantly higher.

Comparison of model results

30Experiment 3. In order to demonstrate the effect of the above four models on the detection and segmentation of product surface defects, the experimental results of the four models on the KolektorSDD dataset were collected (Fig. 8). In Fig. 8(a), the detection ability of each model for the defect sample is shown, and Fig. 8(b) shows the detection ability for the non-defect sample. In Figs. 8(a) and 8(b), the first column is the input original image, the last column is the ground truth label corresponding to the original image, and the middle four columns represent the detection and segmentation results of each model. The value in the segmentation results image represents the probability of the input image being a defect image. The results of Fig. 8(a) show that the defect area segmented by our model on the defect image is closer to the ground truth label, and the probability of predicting that the image is a defect image is also higher. It can be concluded from Fig. 8(b) that our model can exclude the interference of noise when processing non-defective samples and can differentiate non-defective samples more accurately.

The model is evaluated on MTD

31Experiment 4. To verify the universality and effectiveness of the model, our model is also evaluated on the MTD dataset. In the MTD, we calculate the area under the receiver operating characteristic (AUROC) curve of the image level on each test set to measure the performance of the model defect detection method. As can be seen from Table 6, our model achieved the highest AUROC curve of 99.4%, up to 22.8% higher than that of other models (Rudolph et al., 2020, Huang et al., 2020Samet et al., 2018;Thomas et al., 2021). It can be seen from the data in the last two columns of Table 6 that the complexity of our model is much lower than that of other models, and the amount of calculations and parameter size is only 32.61 GMac and 5.37 M, respectively. Although the amount of computation of our model is higher than that of DifferNet, the number of parameters employed was much fewer and the AUC of our model was 1.7% higher compared to DifferNet. Unlike other networks, DifferNet is mainly composed of fully connected layers and has fewer convolution layers. However, fully connected layers contribute much less to model computation and much more to the model parameter number compared to convolution layers. This explains the large number of parameters, shown in Table 6, as well as the lower computational ability of DifferNet compared to other models. The ROC curve in Fig. 9 shows that our method provides a higher true positive rate for any false positive rate.

Ablation studies

32To better understand the influence of CBAM, atrous convolution, and ASPP modules on model performance, ablation experiments were conducted. All the studies were conducted using the same computer equipment. CBAM, atrous convolution, and ASPP modules were added to the proposed model gradually, and the KolektorSDD dataset was configured with the same hyperparameter for training and testing and the experimental results are shown in Table 7. The first three columns respectively indicate whether CBAM, atrous convolution, or ASPP modules are embedded in the model, while the last three columns show the performance of the corresponding models. It can be seen from rows 1 and 2 of Table 7 that the introduction of CBAM can effectively improve the detection accuracy of the model with negligible overheads. This is because CBAM not only improves the representational ability of CNN but also allocates different weights according to the importance of information, which greatly improves the accuracy of the model. Comparing rows 2 and 3, the introduction of atrous convolution into the network will greatly reduce the number of computations and parameters in the network. It greatly simplifies the network structure of the model, speeds up the detection speed of the model, and ensures that its detection performance is not affected. Based on the data shown in rows 3 and 4, it can be concluded that the introduction of ASPP in the model can greatly increase the capability of the model to detect defects, which verifies the effectiveness of the multi-scale sampling method for a given feature map with different rates of atrous convolution. Therefore, the combination of CBAM, atrous convolution, and ASPP technology in the model can not only improve the detection accuracy of the network but also reduce its complexity, thus achieving a good balance between the accuracy and real-time performance of the model in the detection of defects.

33In order to obtain the most reasonable dilation rate configuration of the atrous convolution block, we grouped every 3 blocks and changed their dilation rates. As shown in Table 8, we conducted experiments on 5 groups of convolution blocks with different dilation rates, where (1, 2, 1) represents the dilation rates of 3 blocks as 1, 2, and 1, respectively. It can be concluded from Table 8 that as the expansion rate increases, the receptive field of the model also increases. The accuracy of the model defect detection method first increases and then decreases as the expansion rate increases, reaching a maximum when the dilation rate is (1, 2, 4). It was found that when the receptive field of the network becomes too large, the receptive field may lose image detail, reducing the defect detection accuracy of the model. Therefore, we chose the atrous convolution block with a dilation rate of (1, 2, 4) as the final model configuration.

Conclusion

34In this paper, an efficient surface defect detection model based on CBAM and atrous convolution has been proposed for the detection of product surface defects in an industrial environment, effectively performing segmentation and detection tasks to detect the surface defects of the products. In addition, CBAM, atrous convolution, and ASPP were introduced into the segmentation network and achieved good results in both accuracy and speed of detection. Experimental results revealed that the proposed model performed better than current mainstream defect detection methods for both KolektorSDD and magnetic tile datasets. However, when training the segmentation network, a small number of images with pixel-level annotations on defective images were still needed as training data. To remove the limitation of the required pixel-level annotation data on the model, improving the learning method of the entire model to weakly supervised or even unsupervised learning has become the direction of subsequent research.

Introduction

35In industrial manufacturing, in order to ensure the quality of products, the most effective way is to inspect the surface of the product. Usually, it is trained workers who identify complex surface defects, but this method is susceptible to worker inexperience and subjective factors. This time-consuming and unreliable process cannot be adapted to the developing trend of industrial automation. With the development of intelligent manufacturing, defect detection technology based on machine vision (MV) is favored by most scholars. Sun et al. proposed a background subtraction method based on the Gaussian mixture model to extract the feature area of weld defects and designed a weld detection and classification algorithm (Sun et al., 2019). Shen et al. used template matching and sub-pixel precision to precisely position a printed circuit board (PCB) and then used smart cameras and industrial robots to complete the PCB defect detection (Shen et al., 2018). Huang et al. used a support vector machine (SVM) classifier to identify six common glass bottle defects, which addresses the low classification accuracy of existing machine vision defect detection systems (Huang et al., 2016). Xie et al. proposed an improved sub-pixel detection algorithm combining coarse and fine positioning, using Otsu's method to achieve sub-pixel precise positioning (Xie et al., 2016). The above methods can satisfy the defect detection and classification requirements for specific problems to a certain extent. However, it is difficult to satisfy the real-time, high-accuracy, and generality requirements of defect detection in most industrial environments using defect detection methods based on machine vision due to their long development cycle, the interference of acquisition environmental noise, and the difficulty in finding a general template as a reference for various detection objects.

36In recent years, with the development of deep learning (DL), especially the in-depth study of convolutional neural networks (CNNs), deep learning has been successfully applied to various image-related tasks (Krizhevsky et al., 2012). Different from conventional machine vision methods, a deep learning algorithm can effectively learn the mapping improves the performance of the network. In this paper, the most suitable configuration of atrous convolution layer is found through ablation studies. 4) Atrous spatial pyramid pooling (ASPP) (Chen et al., 2017) is used to obtain multi-scale information of images, to enhance the detection ability of defects of different sizes of the model and enhance the universality of the model.

Relevant theoretical

37To extract better features, accelerate the detection speed of the model, and enhance the real-time performance of the model, the CBAM, atrous convolution, and ASPP were introduced into the segmentation network model.

Convolutional block attention module

38The attention mechanism was first proposed in the images (Mnih et al., 2014). The introduction of the attention mechanism in the image field is a very critical technique to enable the deep network model to better focus on a local area of interest to the user while suppressing other areas that are not important. In recent years, models based on attention mechanisms have become a hot research topic and are widely used in various types of deep learning tasks such as natural language processing, image recognition (Wang et al., 2017;Xu et al., 2020), and speech recognition. CBAM is also one of many attention mechanisms, not only telling the user where to focus on but also enhancing the feature extraction ability of the area of interest. It is composed of a channel attention module and a spatial attention module that perform attention operations on the channel and spatial dimensions of the image, respectively. In addition, the use of CBAM can also improve the representational ability of CNN, force CNN to extract fine-grained image features, and make the extracted features more discriminative. The network structure of CBAM is shown in Fig. 1. The module first performs channel attention operation on the feature map to increase the weighting of effective channels and reduce the weighting of invalid channels. As shown in Eq. (1), where c M refers to the channel attention module, F is the input feature map, and the variables avg c F , max c F represent the use of average pooling and max pooling operations to aggregate the spatial information of the feature map, respectively.

39The Hadamard product operation can be carried out between the feature graph  F generated by the channel attention module and the input feature graph F to obtain the input of the spatial attention module. The spatial attention module is then used to increase the attention given to the regions of interest in the spatial dimension. This is shown in Eq. (2) Xie, Xu, Li, Wang and Wan, Journal of Advanced Mechanical Design, Systems, and Manufacturing, Vol.16, No.6 (2022) Finally, the modified feature map is generated by Hadamard product of the feature graph  F of the perform spatial attention module and the input feature map  F .

Atrous convolution

40In the field of image semantic segmentation, it is often necessary to make dense predictions of the full resolution of the image. The designed network not only needs to pay attention to local information but also global information, which requires the network to have a larger receptive field. In general, in order to obtain a larger receptive field, a typical segmentation network uses a large-size convolution kernel with a large number of parameters, so the network becomes relatively complex and requires a lot of computing resources. Atrous convolution is a kind of convolution method proposed to solve this problem. It can increase the receptive field of the network and reduce the training time of the model while maintaining the number of network parameters and calculations. Many classical semantic segmentation networks have also adopted this idea of convolution, such as the Deeplab series (Chen et al., 2014;Chen et al., 2016). Deeplab replaces standard convolution in the network with atrous convolution, and the multi-scale atrous convolution operation of the input image can be performed, greatly reducing the complexity of the network. SSD and RFBNet ) also refer to this convolution method to simplify the network in object detection.

41Atrous convolution is often used to deal with how global information is needed in image segmentation or the need for long sequence information in speech text. It introduces a hyper-parameter called a "dilation rate" to the standard convolution, which defines the distance between each element of the convolution kernel. In other words, compared with standard convolution, atrous convolution adds a new hyper-parameter of dilation rate, whose value is equal to the number of intervals between elements of the convolution kernel. Standard convolution is actually atrous convolution with a dilation rate of 1. The introduction of atrous convolution to the network can not only avoid information loss caused by the pooling operation but also increase the receptive field of the network, allowing the network to better capture the global information of the input image. For example, by adding a hole to the standard convolution, the original 3×3 standard convolution kernel can have a larger receptive field of a 5×5 (dilated rate = 2) standard convolution kernel with the same number of parameters and calculation, which avoids the downsampling operation. Atrous convolution is defined as:

42where f[i] and g [i] are the input and output feature maps respectively, k[l] represents the convolution kernel of length l, and r is the dilated rate of the atrous convolution. When the atrous convolution is performing the convolution operation, the value of the atrous position is 0. Figure 2 illustrates the atrous convolution kernels with three different dilation rates. From left to right are the atrous convolution kernels with dilation rates r = 1, 2, and 4. As the dilation rate increases, the receptive field of the convolution kernel also becomes larger, corresponding to 3×3, 5×5, and 9×9 kernel, respectively. The receptive field of the atrous convolution is calculated as Eq. (4):

43where r is the dilation rate, k is the size of the convolution kernel, and R is the actual receptive field. Although atrous convolution has the above advantages, the random design of the dilation rate in the atrous convolution or any combination of atrous convolution in the network may greatly reduce the performance of the network. Wang et al. pointed out that blindly designing the dilation rate of the atrous convolution will make some pixels of the input sample not participate in the calculation, resulting in the gridding effect and affecting the accuracy of the network . This problem can be avoided by following hybrid dilated convolution in designing the structure of atrous convolution in the network.

Atrous spatial pyramid pooling

44Another challenge of deep convolutional neural networks for image segmentation is dealing with the existence of objects at multiple scales. A common method used to solve this is to combine the images of different scales obtained from the input image by rescaling the operation as the input of the network (Rudolph et al., 2018). This method can indeed improve the segmentation effect of the model but it also creates a computational burden, which hinders the realtime performance of the model. Another effective method is to use ASPP to resample the feature maps obtained by the deep convolutional neural network at different scales to obtain feature maps with rich contextual information.

45Motivated by spatial pyramid pooling (He et al., 2014), Chen et al. proposed ASPP, which uses multiple parallel atrous convolutions with different dilation rates to perform multi-scale sampling for a given feature map (Chen et al., 2016). This is equivalent to using multiple convolution kernels with different receptive fields to resample a given feature map, so the contextual information provided by the image can be captured at multiple scales. In order to further capture global information, Chen et al. augmented ASPP with image-level features (Chen et al., 2017). Figure 3 shows the structure of ASPP with an augmented image-level feature. The improved ASPP uses one 1×1 convolution, three 3×3 atrous convolutions with dilation rates equal to 6, 12, and 18, and image-level feature pooling to perform multi-scale sampling on the input feature map. The resulting features were then concat to obtain an output feature map with rich contextual information.

46Three kinds of atrous convolution kernels with different dilation rates.

Surface defect detection method based on CBAM and atrous convolution

47A surface defect detection model based on CBAM and atrous convolution was designed, as shown in Fig. 4. The model is mainly composed of a segmentation network and a decision network that are used to segment and detect surface defects, respectively. In the segmentation network, the data features of the input samples are first learned and a binary segmentation map is generated. Each pixel in the input samples is taken as a separate training sample for the network to increase the effective number of training samples and avoid overfitting. In the decision network, the feature map learned in the segmentation network and the segmentation results generated are used as the input of the decision network. The segmentation result is used to help the decision network better judge whether the input sample contains defects. Then, a denser and smaller space feature map is obtained after a series of convolutional and pooling operations, followed by the fully connected layer (FC) and sigmoid activation function. The final obtained input sample is the predicted value of the defective image. Fig. 4 The network model structure of the proposed.

48It has been noted that CNN has poor performance in fine-grained image classification, but the surface defect segmentation task needs to deal with defects at the pixel level (Zheng et al., 2017;Lin et al., 2018). Therefore, a CBAM with negligible overheads was introduced into the segmentation network. It can not only improve the ability of the CNN to process fine-grained image classification but also reallocate the weighting of feature maps, improve the attention given to the region of interest, and suppress other invalid information. At the same time, the atrous convolution layer was also designed following the idea of HDC in the segmentation network, which increases the receptive field of the network and simplifies the complexity of the model. In addition, in order to obtain multi-scale information from images, features with rich contextual information are extracted by ASPP to improve the accuracy of the segmentation results of the segmentation network with a small overhead. These factors allow the designed model to satisfy the requirements of high accuracy and strong real-time performance for the industrial surface defect detection method.

Design of the segmentation network

49First, the segmentation network learns the features of the input samples from 8 convolutional layers and 3 pooling layers and generates a feature map with 128 channels. In Fig. 4, 2-conv and 4-conv represent the atrous convolution dilation rates of 2 and 4, respectively. The convolution layer mentioned includes the batch normalization (BN) and nonlinear ReLU layer. When designing the convolutional layer, the kernel size is 3, the stride is 1, and the dilation rate is [1, 2, 4] as a basic convolution block, which satisfies the idea of HDC design. The use of a 2×2 kernel pooling layer in the network can not only reduce the computational burden of the network but also eliminate the interference information of invalid noise. Next, ASPP is used to further obtain multi-scale information of the image. Before passing through two convolutional layers with 512 channels, a 1×1 convolutional layer is used to map the number of channels of the feature map to 512 for consistency with the number of subsequent convolutional layer channels. Then, the CBAM is used to adjust the weight distribution of the feature maps to create a stronger representational ability and improve the segmentation accuracy of the segmentation network. Finally, a 1×1 convolutional layer and a sigmoid activation function are used to map the output results between 0 and 1 to generate a single-channel segmentation result whose resolution is 1/8 of the input image. The structure of the segmentation network and the detailed parameters settings are shown in Table 1. Xie, Xu, Li, Wang and Wan, Journal of Advanced Mechanical Design, Systems, and Manufacturing, Vol.16, No.6 (2022)

Design of the decision network

50The decision network connects the feature map (512 channels) modified by the CBAM in the segmentation network with the segmentation result (1 channel) output by the segmentation network and produces a feature map with 513 channels as the input of the decision network (see Fig. 4). In order to force the decision network to learn global information more easily and reduce the number of network calculations, a max-pooling layer with a step size of 2 is used to halve the length and width of the feature map. Then, a 3×3 convolutional layer and two residual blocks are used to learn the feature map after pooling. Each convolutional layer is followed by a BN and nonlinear ReLU layer to accelerate network convergence. Finally, max pooling and average pooling were carried out for the learned feature map and the single-channel output of the segmentation network, respectively, and were connected to obtain 66 output neurons. The output of the decision network was obtained through the FC layer and the sigmoid activation function. The specific network structure and parameter configuration of the decision network are shown in Table 2.

Model training

51The segmentation task of the segmentation network and the classification task of the decision network can be regarded as the binary classification problem at the pixel level and the image level, respectively. Therefore, the crossentropy loss function of the binary classification (namely BCE loss) is used to train the network. The loss function of the decision network is shown as Eq. (5)

52where x represents the image-level training sample and y(x) is the label of the input sample x. A value of 1 indicates that the input sample x is a defect image (positive samples), while a value of 0 corresponds to a non-defect image (negative samples). In addition,  is the parameter learned by the network, and the probability value of the input sample x belonging to the defective sample through the parameter  is represented by

53. The loss function of the segmentation network is shown as Eq. (6).

54The pixel point set of the input sample x is represented by X, N is the total number of pixels in the input sample x, while h, w represents the length and width of the input image respectively. Since the scale of the objects trained by the segmentation network and the decision network are not consistent, it is necessary to train the segmentation network and the decision network separately to achieve a better effect. The specific method is to first train the segmentation network at the pixel level from 0 and then freeze the trained weights. Only the decision networks are trained at the image level. Fine-tuning the decision network avoids the issue of overfitting from the large number of weights in the segmentation network.

55In addition, the number of positive and negative samples in the train set are also extremely unbalanced. In this dataset, the number of negative samples is about 8 times higher than the number of positive samples, and the number of pixels in the non-defective area is also much higher than in the defective area. If this phenomenon is ignored, the imbalance will not only slow down the convergence speed of the network but also affect the final detection performance of the model. Therefore, we adopted a new sampling method instead of the original random sampling method to alleviate the imbalance in the dataset. Specifically, the positive and negative samples were trained alternately to ensure that samples of the same category were not continuously trained. In this way, the imbalance in the data set is alleviated.

Experimental evaluation 4.1 Dataset

56The surface defect dataset (KolektorSDD) (Tabernik et al., 2020) is was constructed from defected electrical commutators by the Kolektor team. The surface area of each electrical commutator was completely covered with eight images, which were collected in an industrial environment with a resolution of 1408×512 pixels to ensure high-quality images. A total of 50 defective electrical commutators were sampled in the dataset, each with up to eight relevant surfaces, and a total of 399 images were collected. There were 52 positive sample images with defective areas, and the remaining 347 images were negative samples without defective pixels. In the experiment described herein, the dataset is divided into a train set and a test set at a ratio of 7:3. There are 279 images in the train set, of which 33 are defective images and the rest are non-defective images with no defective pixels. Some positive samples with defective pixels and negative samples without defective pixels are shown in Fig. 5. The first and second rows are non-defective samples and annotations, while the third and fourth rows are the defective samples of defective pixels and annotations.

Implementation details

57The network structure was implemented using the PyTorch (Paszke et al., 2017) framework. Both the segmentation network and the decision network were trained using the Adam (Kingma et al., 2014) optimizer with the exponential decay parameters 1  = 0.9 and 2  = 0.99. The dilation rate of the atrous convolution block is 1, 2, 4, the kernel size is 3, and the stride size is 1. The learning rate of the segmentation network was set to 0.01 and the batch size was set to 5, while the learning rate and the batch size of the decision network were set to 0.1 and 7, respectively. The segmentation network and the decision network trained 100 epoch and 20 epoch iterations, respectively, to reach convergence on the KolektorSDD. Due to the limitation of the experimental equipment, the resolution of the input image was preprocessed, and the resolution of each image was set to 704×256 pixels. In the MTD, the segmentation network and the decision network respectively trained 920 epochs and 160 epochs to convergence, and the resolution of the input image was set as 500×500.

58The experimental development environment is as follows: CPU: AMD Ryzen 5 3600 6-core Processor@ 3.60GHz; GPU: NVIDIA GeForce RTX2060 with 6G memory; software environment: PyCharm, python 3.7.4.

Comparison with other methods

59To verify the effectiveness and superiority of the proposed method, this paper compares the proposed method with several mainstream image segmentation methods based on deep learning. The following will be evaluated from the accuracy and real-time performance of the model.

Accuracy comparison of models

60Experiment 1. Because the detection results of the decision network are more important than the segmentation results of the segmentation network, the evaluation of the decision network is only regarded as the final result to measure the quality of the model. In this paper, the proposed model and other mainstream models based on image segmentation are trained and tested on the KolektorSDD dataset, and the accuracy of the model is evaluated by FN, FP, and AP performance metrics. The results are shown in Table 4. It can be seen from Table 4 that the method proposed in this paper is noticeably superior to the other three methods, reaching the detection result of zero errors. Our model had an AP that was 3.9, 2, and 0.1% more precise than the U-Net (Ronneberger et al., 2015), DeepLab v3+ , and Segmentation decision net (Tabernik et al., 2020) models, respectively, which satisfies the high-accuracy industry requirements for the surface defect detection of products.

Real-time comparison of models

61Experiment 2. In this experiment, the real-time performances of several models are compared and evaluated. The results of the evaluation are measured by the calculation amount of the model, the size of the parameters, and the detection time of a single image. The results are shown in Table 5. Table 5 shows that the model proposed in this paper takes only 18 ms to detect a single image. Compared with the U-Net and Segmentation decision net models, our model is faster by 44 and 30 ms, respectively. The main reason for this is that our model makes fewer calculations and uses fewer parameters, which are only one-third and one-half that of the U-Net and Segmentation decision net models, respectively. DeepLab v3+ with atrous convolution is also used in the model. The number of parameters and calculation amount of the model were only 18.2 GMac and 5.8 M, and the detection time of a single image was less than that of our model.

62In an industrial environment, the accuracy and real-time detection of product surface defects are equally important. If we only blindly pursue the accuracy of the detection model and constantly deepen the layers of the network model, then the real-time performance of the model will inevitably be hindered. Therefore, a better product surface defect detection model needs to balance accuracy and real-time performance. To provide a more obvious comparison effect, the comparison results of the above four models on the KolektorSDD dataset were analyzed in regard to the accuracy and real-time performance of the model (Fig. 7). Compared with the U-Net and Segmentation decision nets, the average accuracy of our model and the detection speed of a single image were respectively higher and faster. Compared with the DeepLab v3+ model, although our model takes slightly longer to detect a single image, the accuracy of the defect image detection model is significantly higher.

Comparison of model results

63Experiment 3. In order to demonstrate the effect of the above four models on the detection and segmentation of product surface defects, the experimental results of the four models on the KolektorSDD dataset were collected (Fig. 8). In Fig. 8(a), the detection ability of each model for the defect sample is shown, and Fig. 8(b) shows the detection ability for the non-defect sample. In Figs. 8(a) and 8(b), the first column is the input original image, the last column is the ground truth label corresponding to the original image, and the middle four columns represent the detection and segmentation results of each model. The value in the segmentation results image represents the probability of the input image being a defect image. The results of Fig. 8(a) show that the defect area segmented by our model on the defect image is closer to the ground truth label, and the probability of predicting that the image is a defect image is also higher. It can be concluded from Fig. 8(b) that our model can exclude the interference of noise when processing non-defective samples and can differentiate non-defective samples more accurately.

The model is evaluated on MTD

64Experiment 4. To verify the universality and effectiveness of the model, our model is also evaluated on the MTD dataset. In the MTD, we calculate the area under the receiver operating characteristic (AUROC) curve of the image level on each test set to measure the performance of the model defect detection method. As can be seen from Table 6, our model achieved the highest AUROC curve of 99.4%, up to 22.8% higher than that of other models (Rudolph et al., 2020, Huang et al., 2020Samet et al., 2018;Thomas et al., 2021). It can be seen from the data in the last two columns of Table 6 that the complexity of our model is much lower than that of other models, and the amount of calculations and parameter size is only 32.61 GMac and 5.37 M, respectively. Although the amount of computation of our model is higher than that of DifferNet, the number of parameters employed was much fewer and the AUC of our model was 1.7% higher compared to DifferNet. Unlike other networks, DifferNet is mainly composed of fully connected layers and has fewer convolution layers. However, fully connected layers contribute much less to model computation and much more to the model parameter number compared to convolution layers. This explains the large number of parameters, shown in Table 6, as well as the lower computational ability of DifferNet compared to other models. The ROC curve in Fig. 9 shows that our method provides a higher true positive rate for any false positive rate.

Ablation studies

65To better understand the influence of CBAM, atrous convolution, and ASPP modules on model performance, ablation experiments were conducted. All the studies were conducted using the same computer equipment. CBAM, atrous convolution, and ASPP modules were added to the proposed model gradually, and the KolektorSDD dataset was configured with the same hyperparameter for training and testing and the experimental results are shown in Table 7. The first three columns respectively indicate whether CBAM, atrous convolution, or ASPP modules are embedded in the model, while the last three columns show the performance of the corresponding models. It can be seen from rows 1 and 2 of Table 7 that the introduction of CBAM can effectively improve the detection accuracy of the model with negligible overheads. This is because CBAM not only improves the representational ability of CNN but also allocates different weights according to the importance of information, which greatly improves the accuracy of the model. Comparing rows 2 and 3, the introduction of atrous convolution into the network will greatly reduce the number of computations and parameters in the network. It greatly simplifies the network structure of the model, speeds up the detection speed of the model, and ensures that its detection performance is not affected. Based on the data shown in rows 3 and 4, it can be concluded that the introduction of ASPP in the model can greatly increase the capability of the model to detect defects, which verifies the effectiveness of the multi-scale sampling method for a given feature map with different rates of atrous convolution. Therefore, the combination of CBAM, atrous convolution, and ASPP technology in the model can not only improve the detection accuracy of the network but also reduce its complexity, thus achieving a good balance between the accuracy and real-time performance of the model in the detection of defects.

66In order to obtain the most reasonable dilation rate configuration of the atrous convolution block, we grouped every 3 blocks and changed their dilation rates. As shown in Table 8, we conducted experiments on 5 groups of convolution blocks with different dilation rates, where (1, 2, 1) represents the dilation rates of 3 blocks as 1, 2, and 1, respectively. It can be concluded from Table 8 that as the expansion rate increases, the receptive field of the model also increases. The accuracy of the model defect detection method first increases and then decreases as the expansion rate increases, reaching a maximum when the dilation rate is (1, 2, 4). It was found that when the receptive field of the network becomes too large, the receptive field may lose image detail, reducing the defect detection accuracy of the model. Therefore, we chose the atrous convolution block with a dilation rate of (1, 2, 4) as the final model configuration.

Conclusion

67In this paper, an efficient surface defect detection model based on CBAM and atrous convolution has been proposed for the detection of product surface defects in an industrial environment, effectively performing segmentation and detection tasks to detect the surface defects of the products. In addition, CBAM, atrous convolution, and ASPP were introduced into the segmentation network and achieved good results in both accuracy and speed of detection. Experimental results revealed that the proposed model performed better than current mainstream defect detection methods for both KolektorSDD and magnetic tile datasets. However, when training the segmentation network, a small number of images with pixel-level annotations on defective images were still needed as training data. To remove the limitation of the required pixel-level annotation data on the model, improving the learning method of the entire model to weakly supervised or even unsupervised learning has become the direction of subsequent research.

참고문헌 25건

  1. U-Net: Convolutional Networks for Biomedical Image Segmentation Lecture notes in computer science · Springer Science+Business Media · 2015 10.1007/978-3-319-24574-4_28
  2. DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs IEEE Transactions on Pattern Analysis and Machine Intelligence · IEEE Computer Society · 2017 10.1109/tpami.2017.2699184
  3. Understanding Convolution for Semantic Segmentation 2018 10.1109/wacv.2018.00163
  4. Bilinear Convolutional Neural Networks for Fine-Grained Visual Recognition IEEE Transactions on Pattern Analysis and Machine Intelligence · IEEE Computer Society · 2017 10.1109/tpami.2017.2723400
  5. Learning Multi-attention Convolutional Neural Network for Fine-Grained Image Recognition 2017 10.1109/iccv.2017.557
  6. An Unsupervised-Learning-Based Approach for Automated Defect Inspection on Textured Surfaces IEEE Transactions on Instrumentation and Measurement · Institute of Electrical and Electronics Engineers · 2018 10.1109/tim.2018.2795178
  7. A Surface Defect Detection Method Based on Positive Samples Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-319-97310-4_54
  8. CBAM: Convolutional Block Attention Module Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-030-01234-2_1
  9. Surface defect saliency of magnetic tile The Visual Computer · Springer Science+Business Media · 2018 10.1007/s00371-018-1588-5
  10. Design and Implementation of PCB Detection and Classification System Based on Machine Vision Lecture notes in electrical engineering · Springer Science+Business Media · 2018 10.1007/978-981-13-2375-1_32
  11. An Effective Method of Weld Defect Detection and Classification Based on Machine Vision IEEE Transactions on Industrial Informatics · Institute of Electrical and Electronics Engineers · 2019 10.1109/tii.2019.2896357
  12. An improved industrial sub-pixel edge detection algorithm based on coarse and precise location Journal of Ambient Intelligence and Humanized Computing · Springer Science+Business Media · 2019 10.1007/s12652-019-01232-2
  13. Surface defect classification of steels with a new semi-supervised learning method Optics and Lasers in Engineering · Elsevier BV · 2019 10.1016/j.optlaseng.2019.01.011
  14. A High-Efficiency Fully Convolutional Networks for Pixel-Wise Surface Defect Detection IEEE Access · Institute of Electrical and Electronics Engineers · 2019 10.1109/access.2019.2894420
  15. An End-to-End Steel Surface Defect Detection Approach via Fusing Multiple Hierarchical Features IEEE Transactions on Instrumentation and Measurement · Institute of Electrical and Electronics Engineers · 2019 10.1109/tim.2019.2915404
  16. Semi-supervised defect classification of steel surface based on multi-training and generative adversarial network Optics and Lasers in Engineering · Elsevier BV · 2019 10.1016/j.optlaseng.2019.06.020
  17. Residual Attention Network for Image Classification 2017 10.1109/cvpr.2017.683
  18. Receptive Field Block Net for Accurate and Fast Object Detection Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-030-01252-6_24
  19. Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation Lecture notes in computer science · Springer Science+Business Media · 2018 10.1007/978-3-030-01234-2_49
  20. A Weakly Supervised Surface Defect Detection Based on Convolutional Neural Network IEEE Access · Institute of Electrical and Electronics Engineers · 2020 10.1109/access.2020.2977821
  21. Nondestructive Defect Detection in Castings by Using Spatial Attention Bilinear Convolutional Neural Network IEEE Transactions on Industrial Informatics · Institute of Electrical and Electronics Engineers · 2020 10.1109/tii.2020.2985159
  22. Segmentation-based deep-learning approach for surface-defect detection Journal of Intelligent Manufacturing · Springer Science+Business Media · 2019 10.1007/s10845-019-01476-x
  23. SSD: Single Shot MultiBox Detector Lecture notes in computer science · Springer Science+Business Media · 2016 10.1007/978-3-319-46448-0_2
  24. Same Same But DifferNet: Semi-Supervised Defect Detection with Normalizing Flows 2021 10.1109/wacv48630.2021.00195
  25. Few-Shot Defect Segmentation Leveraging Abundant Defect-Free Training Samples Through Normal Background Regularization And Crop-And-Paste Operation 2022 IEEE International Conference on Multimedia and Expo (ICME) · 2021 10.1109/icme51207.2021.9428468