# Research on a Surface Defect Detection Algorithm Based on MobileNet-SSD
## 3 Experimental Results and Analysis
### Contrast Experiment  
Three comparative experiments were designed to further validate the proposed algorithm. In the first experiment, the proposed algorithm was compared to five lightweight feature extraction networks, including SqueezeNet [31], MobileNet, performance vs accuracy net (PVANet) [32], MTCNN and Faceness-Net. The feature extraction accuracy of each algorithm for the ImageNet classification task is displayed in Table 5. In the second experiment, the above five networks were contrasted with the proposed algorithm in defect detection of the filling line in terms of correct detection rate, training time and the detection time per image (Table 6). Figure 10: (**a**) Easy precision–recall (PR) curves of three different algorithms; (**b**) Medium PR curves of three different algorithms; (**c**) Hard PR curves of three different algorithms. MS = MobileNet-SSD. MTCNN = multi-task convolution neural network. As shown in the two tables, the MobileNet-SSD surface defect model is fast and stable, thanks to the improved SSD meta-structure of the feature pyramid. In general, the proposed algorithm outperformed the contrastive algorithms in detection rate, training time and detection time. The final detection time of our algorithm was merely 120 milliseconds per piece, which meets the real-time requirements of the industrial filling line. In Contrast Experiment 3, four traditional defect recognition methods of k-nearest neighbor (KNN) [33], HMM [34; 35; 36], SVM and HMM [37] and back propagation neural network (BPNN) [38] are realized, which are compared with the method in this paper. The KNN method selects Euclidean distance as the distance function; the HMM model adopts a sampling window of 5 \(\times\) 4 size and uses the discrete cosine transform (DCT) coefficient as the observation vector of HMM. The SVM and HMM method is the same as in literature [37]. The hidden layer number of the BP neural network is set to 30. The above models are also applied to detect the defects on the sealing surface of a container in the filling line. The statistical results are shown in Table 7.  
As can be seen from Table 6, compared with the other traditional defect detection methods, the MobileNet-SSD method has a higher positive detection rate. Under the same hardware conditions, MobileNet-SSD still maintains the optimal speed despite the small differences between the above five methods. In addition, the results of HMM and KNN are not ideal. The reason for this may be that the proportion of defects is small, and the sealing surface of a container contains a lot of background information. KNN and HMM did not extract specific features of the image before classifying. However, both the BP neural network and MobileNet-SSD are based on neural networks, which can automatically learn features by itself, so the accuracy rate of the two methods are relatively high. MobileNet-SSD, \begin{table}
\begin{tabular}{c c c c} \hline
**Number** & **Model** & **Positive Rate** & **Training Time (Day)** & **Detection Time (s)** \\ \hline
1 & SqueezeNet & 85.83\% & 2 & 0.31 \\
2 & Faceness-Net & 90.83\% & 3 & 0.59 \\
3 & MobileNet & 90.83\% & \textless{}1 & 0.54 \\
4 & MTCNN & 91.67\% & 3 & 0.64 \\
5 & PVANet & 94.17\% & 2 & 0.25 \\
6 & MobileNet-SSD & 95.00\% & \textless{}1 & 0.12 \\ \hline \end{tabular}
\end{table} 
Table 6: Correct detection rate, training time and the detection time per image of each network. \begin{table}
\begin{tabular}{c c c c c} \hline
**Number** & **Model** & **Positive Rate** & **Detection Time (s)** \\ \hline
1 & KNN & 65.83\% & 0.31 \\
2 & HMM & 66.67\% & 0.39 \\
3 & SVM and HMM & 80.83\% & 0.32 \\
4 & BPNN & 84.17\% & 0.14 \\
5 & MobileNet-SSD & 95.00\% & 0.12 \\ \hline \end{tabular}
\end{table} 
Table 7: Correct detection rate and the detection time per image of each model. HMM: Hidden Markov Model. SVM = support vector machine. KNN = k-nearest neighbor. BPNN = back propagation neural network.