# Research on a Surface Defect Detection Algorithm Based on MobileNet-SSD
## 2 Surface Defect Detection Method
### Defect Detection Model Based on MobileNet-SSD Network  
#### 2.2.1 Principles of MobileNet Feature Extraction  
The MobileNet network [27] was developed to improve the real-time performance of deep learning under limited hardware conditions. This network can reduce the number of parameters without sacrificing accuracy. Previous studies have shown that MobileNet only needs 1/33 of the parameters of Visual geometry group -16 (VGG-16) to achieve the same classification accuracy in ImageNet-1000 classification tasks. Figure 3 shows the basic convolution structure of MobileNet. Conv_Dw_Pw is a deep and separable convolution structure. It is composed of depth-wise layers (Dw) and point-wise layers (Pw). The Dw are deep convolutional layers using 3 \(\times\) 3 kernels, while the Pw are common convolutional layers using 1 \(\times\) 1 kernels. Each convolution result is treated by the batch normalization algorithm and the activation function rectified liner unit (ReLU). Figure 2: (**a**) Original image; (**b**) Gaussian smooth image; (**c**) X directional gradient graph; (**d**) Y directional gradient graph; (**e**) Amplitude image; (**f**) Angle image; (**g**) Non-maximum value suppression graph; (**h**) Edge detection chart; (**i**) Maximum circle detection; (**j**) Maximum circle position of the original graph; (**k**) Cutting; (**l**) Normalization. In this paper, the activation function ReLU is replaced by ReLU6, and the normalization is carried out by the batch normalization (BN) algorithm, which supports the automatic adjustment of data distribution. The ReLU6 activation function can be expressed as:  
\[y=\min(\max(z,0),6) \tag{6}\]  
where \(z\) is the value of each pixel in the feature map. The deep and separable convolutional structure enables the MobileNet to speed up the training and greatly reduces the amount of calculation. The reasons are as follows:  
The standard convolution structure can be expressed as:  
\[\mathrm{G_{N}}=\sum_{\mathrm{M}}\mathrm{K_{M,N}}*\mathrm{F_{M}} \tag{7}\]  
where \(\mathrm{K_{M,N}}\) is the filter; and M and N are respectively the number of input channels and output channels. During the standard convolution, the input image, including the feature image, \(\mathrm{F_{M}}\) means input images, including feature maps, which use the fill style of zero padding. When the size and channels of input images respectively are \(\mathrm{D_{F}}*\mathrm{D_{F}}\) and M, it is necessary to have N filters with M channels and the size of \(\mathrm{D_{K}}*\mathrm{D_{K}}\) before outputting N feature images of the size \(\mathrm{D_{K}}*\mathrm{D_{K}}\). The computing cost is \(\mathrm{D_{K}}*\mathrm{D_{K}}*\mathrm{M}*\mathrm{N}*\mathrm{D_{F}}*\mathrm{D_{F}}\). By contrast, the Dw formula can be expressed as:  
\[\mathrm{\hat{G}_{M}}=\sum\mathrm{\hat{K}_{1,M}*F_{M}} \tag{8}\]  
where \(\mathrm{\hat{K}_{1,M}}\) is the filter. \(\mathrm{F_{M}}\) has the same meaning as Formula (7). When the step size is one, the filling of zero ensures that the size of the characteristic graph is invariable after the application of deep and separable convolutional structure. When the step size is two, zero filling ensures that the size of the feature graph obtained after the application of deep and separable convolutional structure becomes half of the input image/feature graph; that is, the dimensional reduction operation is realized. The deep separable convolution structure of MobileNet can obtain the same outputs as those of standard convolution based on the same inputs. The Dw phase needs M filters with one channel and the size of \(\mathrm{D_{K}}*\mathrm{D_{K}}\). The Dw phase needs N filters with M channels and the size of \(1\times 1\). In this case, the computing cost of the deep separable convolution structure is \(\mathrm{D_{K}}*\mathrm{D_{K}}*\mathrm{M}*\mathrm{D_{F}}*\mathrm{D_{F}}+\mathrm{ M}*\mathrm{N}*\mathrm{D_{F}}*\mathrm{D_{F}}\), about \(\frac{1}{N}+\frac{1}{\mathrm{D_{K}^{\prime}}}\) of that of standard convolution.