# A Road Crack Detection Method Based on Residual and Attention Mechanism
## 2 Proposed Method
### Convolutional Attention Module  
CBAM (convolutional block attention module) [20] is an attention module used to enhance the performance of convolutional neural networks. Figure 3 shows the structure of CBAM. CBAM is a lightweight general-purpose module consisting of two parts: channel attention module and spatial attention module. This structure not only saves parameters and computational power, but also ensures its successful integration into existing network architectures. The channel attention module can adaptively select important feature channels, while spatial attention can adaptively focus on important image regions. The focus of road crack segmentation is on precise segmentation of crack boundaries. The CBAM module combines channel and spatial attention to help the model capture the feature information of road cracks more comprehensively, further achieving the goal of improving segmentation accuracy. In this article, the feature maps extracted by the residual module are used as inputs to the CBAM module, which can enable the optimized network model to focus more on the key features of road crack formation and ignore irrelevant information, thereby improving the performance of the network. Figure 2: Residual structure. (a) BasicBlock module. (b) BottleNeck module. 1. Channel attention module  
The channel attention module aggregates spatial features through two methods: global average pooling and maximum pooling, as shown in Formula (1). The input features are represented by \(F\), with a size of \(\text{C}\times\text{H}\times\text{W}\). After performing global average pooling and maximum pooling operations on input feature, represented by \(F\), two \(\text{C}\times 1\times 1\) channels are obtained. Then, these two channels are, respectively, fed into a multi-layer perceptron (MLP) with hidden layers. Next, the two obtained features are added together and passed through a sigmoid activation function to obtain the weight coefficient represented by \(Mc\). Finally, \(Mc\) and \(F\) are multiplied to obtain the new feature, represented by \(F^{\prime}\), as shown in Formula (2). The structure of the channel attention module is shown in Figure 4.  
\[Mc(F)=\sigma(\text{MLP}(\text{AvgPool}(\text{ }F))+\text{MPL}(\text{MaxPool}( \text{ }F))) \tag{1}\]  
\[F^{\prime}=Mc(F)\otimes F \tag{2}\]  
Among them, \(F\) represents the input feature, \(Mc\) represents the weight coefficient, and \(F^{\prime}\) represents the new feature obtained using the channel attention module. \(\sigma\) represents the sigmoid function, while AvgPool and MaxPool represent the average pooling and maximum pooling functions, respectively. * Spatial attention module  
The spatial attention module mainly focuses on the positions of meaningful features, which effectively supplement the information that the channel attention module focuses on. The structure of the spatial attention module is shown in Figure 5. The input of the spatial attention module is the feature obtained by the channel attention module represented by \(F^{\prime}\). Similar to the channel attention module, the spatial attention module also performs global average pooling and maximum pooling operations on the input features in the channel dimension, resulting in two \(1\times\text{H}\times\text{W}\) channels. Then, these two channels are concatenated together and compressed through a \(7\times 7\) convolutional layer. Next, the weight coefficients represented by \(Ms\) are obtained through a Sigmoid activation function operation, as shown in Formula (3). Finally, the weight coefficients represented by \(Ms\) and the input features represented by \(F^{\prime}\) are multiplied to obtain the new features processed by the spatial processing module, represented by \(F^{\prime\prime}\), as shown in Formula (4). Where \(\sigma\) represents the sigmoid function and \(f^{\prime\times 7}\) represents a convolution operation with a size of \(7\times 7\).