## 2 Principle of the Crack Detection and Lifetime Prediction Model
### Operation of MSE-Faster R-CNN Crack Detector  
The MSE-Faster R-CNN detector takes multiple ROIs as input. For each ROI (see Figure 1), a fixed-length feature vector is extracted by the ROIs pooling layer from the convolutional layer. The final feature vector is fed into a sequence of fully connected (FC) layers. The outputs of the detector through the Softmax layer and the bounding-box regressor layer include (1) Softmax probabilities which estimate over the crack class and the background class and (2) the crack bounding-box. As many bounding-boxes overlap highly with each other, non-maximum suppression (NMS) is applied to merge bounding-boxes that have high Intersection-over-Union (IoU). After NMS, the remaining bounding-box is ranked based on the crack probability score, and only the top oneis used for detection. For training RPNs, each proposal is assigned a binary class label which indicates whether the proposal is a crack or just background. A positive training example is designated if the proposal overlaps with a ground-truth box with an IoU more than a predefined threshold (0.7), or if it has the highest IoU with a ground-truth. A proposal will be assigned as a negative example if its maximum IoU is lower than the predefined threshold (0.3) for all ground-truth boxes. Following the multitask loss in Faster R-CNN network, the RPN is trained by a multitask loss, which is defined as [28]:  
\[L(\{p_{i}\},\{t_{i}\})=\frac{1}{N_{cls}}\sum_{i}L_{cls}(p_{i},{p_{i}}^{*})+ \lambda\frac{1}{N_{rgg}}\sum_{i}{p_{i}}^{*}L_{rgg}(t_{i},{t_{i}}^{*}) \tag{1}\]  
where \(i\) is the index of an anchor. The multi-task loss has two parts, a classification component \(cls\) and a regression component \(reg\). In Equation (1), \(p_{i}\) is the predicted probability of the anchor being a crack while \({p_{i}}^{*}\) is the true category of the anchor. The ground-truth label is 1 if the anchor is positive and 0 if the anchor is negative. \(t_{i}\) is a vector representing the 4 parameterized coordinates of the predicted bounding-box; and \({t_{i}}^{*}\) is the vector of the ground-truth box associated with a positive anchor. The classification loss \(L_{cls}\) is normalized by \(N_{cls}\) and the regression loss \(L_{rgg}\) is normalized and weighted by a balancing parameter \(\lambda\). In this paper, considering a large number of small pores in the coating model, \(\lambda\) is set to 6. Such a balancing parameter setting will increase the influence of diagnostic error, so as to minimize the influence of pores. The \(N_{cls}\) term in (1) is normalized by the mini-batch size. Bounding-box regression aims to find the best nearby ground-truth box of an anchor box. The parameterization of the 4 coordinates of an anchor is described as follows [27]:  
\[\left\{ \begin{array}{l}t_{x}=\dfrac{(x-x_{a})}{w_{a}}\\ t_{y}=\dfrac{(y-y_{a})}{w_{a}}\\ t_{w}=\log\dfrac{w}{w_{a}}\\ t_{h}=\log\dfrac{h}{h_{a}}\end{array} \right. \tag{2}\]  
\[\left\{ \begin{array}{l}t_{x}*=\dfrac{(x*-x_{a})}{w_{a}}\\ t_{y}*=\dfrac{(y*-y_{a})}{w_{a}}\\ t_{w}*=\log\dfrac{w*}{w_{a}*}\\ t_{h}*=\log\dfrac{h*}{h_{a}*}\end{array} \right. \tag{3}\]  
where \(x\), \(y\), \(w\), and \(h\) denote the bounding-box's center coordinates, width, and depth, respectively. \(x\), \(x_{a}\) and \(x_{a}\)* are for the predicted box, anchor box and ground-truth box, respectively. Similar definitions are also applied for \(y\), \(w\) and \(h\). The bounding-box regression is achieved by using features with the same spatial size on the feature maps. A set of bounding-box regressors is trained to adapt for varying size of cracks. The adjusted bounding-box scale is more suitable for crack detection. VGG-19 is used for generating candidate crack regions for the RPN. It is pre-trained in the ImageNet Dataset.