# Intelligent Diagnosis of Concrete Defects Based on Improved Mask R-CNN
## 2 Methods
### Improvement on Mask-RCNN
Figure 4: The depthwise separable convolution structure. Figure 3: The standard convolution structure. MobileNet V2 adopts Linear Bottlenecks on the basis of MobileNet V1. In MobileNet V1, the activation function is ReLU. Using ReLU in a low dimensional space will cause great information loss, so in MobileNet V2, the last ReLU function is removed from each residual block, no activation function is used, and the module is called Linear BottleNecks; it can reduce the information loss caused by the activation function ReLU. MobileNet V3 adds the attention mechanism based on MobileNet V2, and redesigns the activation function and the structure of the time-consuming layer. In view of the stability and applicability of the network structure, this paper selected MobileNet V2 as the backbone network. For better identification of concrete defect features, the co-ordinate attention module is added to the feature extraction network to improve the detection performance of the model. The structure of the CA attention module is shown in Figure 7. For the feature layer of size W \(\times\) H \(\times\) C, firstly, average pooling is carried out along the horizontal X-direction and the vertical Y-direction, respectively, to generate the two feature layers of size 1 \(\times\) H \(\times\) C and W \(\times\) 1 \(\times\) C, which are subsequently spliced, and then downscaled by the convolution kernel of size 1 \(\times\) 1, which reduces the number of its channels to the original C/r (r is the downsampling ratio), and then input to the batch normalization layer (BN) to improve the stability and convergence speed of the model. Then, through the activation function of h-Swish, the output feature layer after dimensionality reduction is separated according to the original height and width, and the feature layer is separated by using the two 1 \(\times\) 1 convolution kernels, the separated two feature layers are transformed to the same number of channels as the input feature layer and the probability distributions of the above two feature layers are calculated by the Sigmoid function to obtain the attention weights in the horizontal and vertical directions, and the weights in the two directions are multiplied by the original feature map matrix to obtain the feature map with co-ordinate attention. Figure 5: The residual block. Figure 6: The inverted residual block. In the original Mask-RCNN, the feature pyramid networks (FPNs) use a bottom-up to top-down path to extract the multiscale feature map, the feature information is transmitted from the bottom layer to the top layer (the P5 layer) which would take dozens or even hundreds of convolutional layers, as shown by the red dotted line in Figure 8. After so many layers of transmission, it will lose a lot of feature information. In FPN, candidate regions are assigned to different feature layers according to their sizes. A small candidate region is allocated to a low-level layer (such as layer P2), while a large candidate region is allocated to a high-level layer (such as layer P5). This processing method is simple and effective, but it may not be able to obtain optimal feature fusion results. For example, candidate regions with a smaller pixel difference may be assigned to different feature layers, but in fact, the two candidate regions are very approximate. This paper added a bottom-up feature fusion layer and adaptive feature pool to the FPN network to solve the above problem, it included the FPN network, bottom-up path augmentation and adaptive feature pooling, as shown in Figure 8. The path augmentation used a bottom-up path to fuse the feature information; in this way, the feature information of the lower layer was transmitted to the N2-N5 layer through only a few layers, as shown by the green dotted line in Figure 8. It will reduce the loss of feature information from the low layer to the high layer. In adaptive feature pooling, every region proposal was aligned to each pixel of the N2-N5 feature maps through ROI Align.