# A Lightweight Residual Model for Corrosion Segmentation with Local Contextual Information
## 3 Method
### Encoder-Decoder Architecture  
To improve preservation of original pixel position information, we removed all pooling layers and changed the downsampling factor to \(8\times\) in the encoder. The image was downsampled at the beginning to filter out irrelevant information to alleviate the computational effort of the subsequent process. In stage 1, small convolution kernels were used to extract local information, and then a downsampling module from ShuffleNetv2 was employed, as shown in Figure 3. After each downsampling step, feature maps at different scales were extracted by stacking the local contextual block. The detailed parameter settings are shown in Table 1.  
We implemented a simple decoder architecture to fuse multi-scale features. The four feature scales are first compressed to the same number of channels \(C\), and then upsampled to recover to the same resolution \(H\times W\). Subsequently, concatenation was performed in the channel dimension, and then the final result was obtained through two layers of point convolution as shown in (4). The overall architecture of the proposed network is shown in Figure 3.  
Figure 2: Details of the local contextual block. DWConv stands for DepthWise Convolution.  
\[\begin{split}\hat{F}_{i}&=Conv(C_{i},C)(F_{i}),\forall_{i} \\ \hat{F}_{i}&=Upsample(H\times W)(\hat{F}_{i}),\forall_{i}\\ F&=Conv(4C,C)(Concat(\hat{F}_{i})),\forall_{i}\\ M&=Conv(C,nclass)(F)\end{split} \tag{4}\]  
where \(M\) refers to the predicted output; \(nclass\) represents the number of classes; \(F_{i}\) stands for the feature; \(Conv(C_{in},C_{out})\) refers to the input channel \(C_{in}\) and the output channel \(C_{out}\) after point convolution; and \(Upsample(H\times W)\) represents up-sampling to the size of \(H\times W\). Unlike the huge decoder structure of Unet [43] and SegNet [44], our decoder achieved high accuracy with a small number of parameters.  
To explore the most suitable kernel size, we tested the changing accuracy with the kernel size variation as shown in Figure 4. The corresponding model parameters can also be seen. We finally choose 17 \(\times\) 17 for the large kernal size to make a good trade-off between model size and segmentation accuracy.  
We designed two different sizes of models, small and large, for devices that had different computing power. Large models had relatively more channels compared to small models and thus a larger model size. The large model was more suitable for sensitive equipment or applications that require high accuracy in corrosion segmentation of metal  
Figure 4: The accuracy and model size vs. the kernel size. A good trade-off was obtained when the kernel size was 17 \(\times\) 17.  
Figure 3: The overall architecture of the proposed network, which consists of two main modules. The CNN encoder extractd details and semantic features, and the decoder fuses the multi-scale features. The specific module parameters of the encoder are shown in Table 1.  
surfaces, such as aerospace equipment, hydride tanks, automotive wheels, or the metal links of bridges. The small model requires daily inspections. By embedding the corrosion segmentation model in drones, mobile robots and edge computation chips, the corrosion area and degree of corrosion were obtained online and transmitted to the upper computer to help engineers make further decisions.