## 3 Proposed Methods
### A Multi-Scale MobileNet-v2-Dense Network  
Considering the limited storage and computing power of the hardware in practical applications, we chose a network with fewer parameters called MobileNet-v2 as our backbone. As stated above, the transmission of multi-scale information can prevent the feature vanish when the network goes deeper. Therefore, we incorporated multi-scale design into MobileNet-v2 and designed our defect detection network MobileNet-v2-dense. The network structure is shown in Figure 1.  
The main component of the network is composed of multiple cascaded inverted residual blocks with downsampling. The structure of the inverted residual block is shown in Figure 2. The inverted residual block takes a low-dimensional compressed representation as an input, which first expanded to high dimension and filtered with lightweight depthwise convolution. Features are subsequently projected back to a low-dimensional representation. The dense concatenation is used between inverted residual blocks to carry shallow features to deeper layers of the network, which is the fusion of multi-scale information. The network structure of MobileNet-v2-dense is formed by dense cascades  
Figure 1: The structure of the MobileNet-v2-dense network. Where the block names correspond to Table 1. Solid lines in a diagram are concatenation from a shallow feature map to the deep one. between multi-scale channels, with six cascades. 1 2, and 3 are cascades of feature maps with the same scale, 4 and 5 are cascades of feature maps with 1/4 down sampling, and 6 is a cascade of feature maps with 1/16 down sampling. The configuration of MobilNet-v2-dense is shown in Table 1. BN indicates batch normalization layer, and LRelu denotes leaky relu layer. All the activation functions of the network are leaky_relu. Additionally, C1/4 means 4 times downsampling of the C1 layer. Inverted Residual Block x2 states there are two inverted residual blocks in Block2. The input image size of the network is \(224\times 224\), and the resolution of the feature image changes to \(112\times 112\) after Conv1. Subsequently, features are extracted through several blocks. The \"Concat layer\" concatenate the features of the shallow layer. Finally, after aggregation by a Pooling layer, global features are fed into a softmax layer to obtain the final probability scores, which indicate the possibility that the image is a defect. The network topology can transfer and fuse multi-scale features via shortcuts from the shallow to deep layers to avoid the feature missing of selected samples in the streamlined network. The experimental results in Section 4 show that the structure improves the detection accuracy. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Layers** & **Output Size** & **Operation** \\ \hline Conv1 & \(112\times 112\times 24\) & Conv \(3\times 3\), BN, LRelu \\ \hline Block1 & \(112\times 112\times 16\) & Inverted Residual Block \(\times 1\) \\ \hline C1 & \(112\times 112\times 40\) & Concat (Conv1, Block1) \\ \hline Block2 & \(56\times 56\times 40\) & Inverted Residual Block \(\times 2\) \\ \hline Block3 & \(28\times 28\times 48\) & Inverted Residual Block \(\times 3\) \\ \hline Block4 & \(28\times 28\times 56\) & Inverted Residual Block \(\times 4\) \\ \hline C2 & \(28\times 28\times 124\) & Concat (C1/4, Block3, Block4) \\ \hline Block5 & \(14\times 14\times 96\) & Inverted Residual Block \(\times 3\) \\ \hline Block6 & \(7\times 7\times 120\) & Inverted Residual Block \(\times 3\) \\ \hline Block7 & \(7\times 7\times 160\) & Inverted Residual Block \(\times 1\) \\ \hline C3 & \(7\times 7\times 320\) & Concat (C1/16, C2/4, Block6, Block7) \\ \hline Conv2 & \(7\times 7\times 1280\) & Conv \(1\times 1\), BN, LRelu \\ \hline Pooling & \(1\times 1\times 1280\) & Global Pooling \\ \hline Conv3 & \(1\times 1\times 2\) & Conv \(1\times 1\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Mobilenet-v2-Dense configuration. (“Conv” and “Concat” denote convolution and concatenation, respectively). Figure 2: The inverted residual block in MobileNet-v2.