# A Lightweight Residual Model for Corrosion Segmentation with Local Contextual Information
## 4 Experiment
### Experiment Settings  
**Data Requirement and Augmentation.** We used a corrosion image dataset produced by University Libraries Virginia Tech [45], which was collected from Virginia Department of Transportation bridge inspection reports. These were annotated semantically according to the corrosion condition status guidelines reported by the American Association of State Highway and Transportation Officials (AASHTO) and the Bridge Inspector's Reference Manual (BIRM). The entire dataset was divided into four categories: Background, Fair, Poor, and Severe. We expanded the number of images from 440 to 3850 through data enhancement, such as random cropping and contrast or saturation enhancement. The size of the image was adjusted to 512 \(\times\) 512.  
**Implementation Protocol.** All experiments were performed on the PyTorch 1.10.1 with 1\(\times\) V100 GPU and 4\(\times\) 2080 Ti. The network was trained using the SGD optimizer with an initial learning rate of 0.007, which declined to 0.00007 by the cosine curve method. The loss function as shown in (7) was defined as the sum of Dice loss (5) and Focal loss (6). The \(\alpha_{t}\) was used to regulate the ratio between the two losses. The Dice loss [46] is a metric function used to calculate the similarity between set \(X\) and set \(Y\). \(|X|\) and \(|Y|\) stand for the number of pixels in \(X\) and \(Y\), respectively, and \(|X|\bigcap Y|\) represents the intersection pixel numbers between \(X\) and \(Y\). The Focal loss [47] is an improved cross-entropy loss function to solve the sample imbalance, where \(\gamma\) is the modulation factor guiding the algorithm focus on the difficult samples and \(p_{t}\) is the proportion of pixel numbers of four categories to the total numbers in image. Based on experience, we set \(\gamma=2\) and \(\alpha_{t}=0.5\):  
\[DL=1-\frac{2|X|\bigcap Y|}{|X|+|Y|} \tag{5}\]  
\[FL(p_{t})=-(1-p_{t})^{\gamma}log(p_{t}) \tag{6}\]  
\begin{table}
\begin{tabular}{c c c c c} \hline \multirow{2}{*}{**Layer**} & \multirow{2}{*}{**Kernel Size**} & \multirow{2}{*}{**Stride**} & \multirow{2}{*}{**Repeat**} & \multicolumn{2}{c}{**Output Channels**} \\ \cline{3-4}  & & & & **Small** & **Large** \\ \hline \hline \multirow{2}{*}{Image} & & & & 3 & 3 \\ \hline \multirow{3}{*}{Stage 1} & \(3\times 3\) & 2 & 1 & 32 & 72 \\  & \(3\times 3\) (DW) & 1 & 1 & 32 & 72 \\  & \(1\times 1\) & 1 & 1 & 32 & 72 \\ \hline \multirow{3}{*}{Stage 2} & & 2 & 1 & 32 & 72 \\  & & 1 & 3 & 64 & 144 \\ \hline \multirow{3}{*}{Stage 3} & & 2 & 1 & 64 & 144 \\  & & 1 & 7 & 128 & 288 \\ \hline \multirow{3}{*}{Stage 4} & 1 & 1 & 128 & 288 \\  & & 1 & 3 & 256 & 576 \\ \hline \multirow{2}{*}{Params} & & & 2.41 MB & 8.25 MB \\ \end{tabular}
\end{table}
Table 1: The detailed parameter settings of the encoder. The large and small models had different output channels and model sizes.  
\[Totalloss=(1-\alpha_{t})DL+\alpha_{t}FL(p_{t}) \tag{7}\]  
**Evaluation Metrics.** Five indicators were employed to evaluate performance through all experiments: mean Pixel Accuracy (mPA), mean Intersection over Union (mIoU), F1-score, Frames Per Second (FPS) and the volume of the model. We used 2080 Ti uniformly to test the FPS of all models with the same image. The model with high evaluation metrics and a small number of parameters is what we expected.  
\[mIoU=\frac{1}{k+1}\sum_{i=0}^{k}\frac{p_{ii}}{\sum_{j=0}^{k}p_{ij}+\sum_{j=0}^ {k}p_{ji}-p_{ii}} \tag{8}\]  
\[mPA=\frac{1}{k+1}\sum_{i=0}^{k}\frac{p_{ii}}{\sum_{j=0}^{k}p_{ij}} \tag{9}\]  
where \(p_{ij}\) denotes the number of true values of \(i\) that are predicted to be \(j\); \(K+1\) is the number of categories (including the background); \(p_{ii}\) is the True Positive(TP); and \(p_{ij}\) and \(p_{ji}\) denote false positive (FP) and false negative (FN), respectively.