## 3 Methodology
### Multi-Scale Convolutional Attention Module  
The Multi-Scale Convolutional Attention Module (MSCAM) significantly augments the model's ability to identify complex defects on railway surfaces by synergizing channel attention, spatial attention, and multi-scale convolution. As illustrated in Figure 5, MSCAM sequentially chains a Channel Attention Block (CAB), a Spatial Attention Block (SAB), and a Multi-Scale Convolution Block (MSCB) to adaptively highlight informative feature map regions while suppressing background interference. Figure 4: FasterNet overall architecture. In the figure, h and w are the spatial dimensions of the feature map, while C and C denote the number of channels. Similarly, the PConv operation is applied to only a subset of the input channels, thereby effectively reducing memory access overhead. Given an input feature map \(F_{\text{in}}\in R^{\text{C}\times H\times W}\), the data first enter the channel attention block. Through adaptive max pooling \(P_{max}\) and average pooling \(P_{\text{avg}}\), channel-level descriptors are formed and subsequently compressed and restored via two \(1\times 1\) convolutions, ultimately producing the channel weight map \(A_{\text{c}}\in R^{\text{C}\times 1\times 1}\). The calculation of \(A_{\text{c}}\) is shown in Equation (1):  
\[A_{\text{c}}=\sigma\big{(}Conv_{1\times 1}(ReLU(Conv_{1\times 1}(P_{\text{ max}}(F_{\text{i}}))))+Conv_{1\times 1}\big{(}ReLU\big{(}Conv_{1\times 1}\big{(}P_{ \text{avg}}(F_{\text{in}})\big{)}\big{)}\big{)}\big{)} \tag{1}\]  
where \(\sigma\) denotes the Sigmoid activation and Conv\({}_{1\times 1}\) is the \(1\times 1\) convolution operator. Channel weights A\({}_{\text{c}}\) are then multiplied across \(F_{\text{in}}\) channel by channel, resulting in \(F_{CAB}=A_{\text{c}}\odot F_{\text{in}}\), thereby accentuating channels critical for detecting subtle cracks and corrosion deposits. Subsequently, the feature map \(F_{CAB}\) moves through the spatial attention block, where maximum pooling \(C_{\text{max}}\) and average pooling \(C_{\text{avg}}\) are performed along the channel dimension. These single-channel spatial descriptors are concatenated and convolved with a \(7\times 7\) kernel to capture extended spatial dependencies, yielding the spatial weight \(A_{\text{s}}\in R^{1\times H\times W}\). The calculation of \(A_{\text{s}}\) is shown in Equation (2):  
\[A_{\text{s}}=\sigma\big{(}Conv_{7\times 7}\big{(}Concat\big{(}C_{\text{max}}(F_{ CAB}),C_{\text{avg}}(F_{ CAB})\big{)}\big{)}\big{)} \tag{2}\]  
This weight map is multiplied pixel-wise with \(F_{CAB}\), producing \(F_{SAB}=A_{\text{s}}\odot F_{\text{CAB}}\). The wide receptive field of the \(7\times 7\) convolution effectively captures elongated crack edges and attenuates noise arising from uneven illumination or rusted surfaces. Finally, the Multi-Scale Convolution Block (MSCB) applies parallel depthwise separable convolutions at \(1\times 1\), \(3\times 3\), and \(5\times 5\) scales to extract both local details and  
Figure 5: MSCAM architecture. broader context. The resulting feature maps \(F_{1},F_{2},F_{3}\) undergo a channel shuffle operation to facilitate cross-group information exchange, followed by a \(1\times 1\) convolution for fusion and a residual connection to the input. The final output \(F_{MSCB}\) is computed as shown in Equation (3):  
\[F_{\text{MSCB}}=BN(Conv_{1\times 1}(Shuffle(Concat(F_{1},F_{2},F_{3}))))+F_{SAB} \tag{3}\]  
where BN denotes batch normalization and Shuffle represents the channel shuffle process. This design yields robust representations of both micro-level cracks and extensive spalling without imposing significant computational overhead. By integrating three complementary attention mechanisms--channel, spatial, and multi-scale--MSCAM suppresses irrelevant background noise while enhancing multi-resolution defect features. The CAB filters salient channels, the SAB emphasizes pivotal spatial regions, and the MSCB captures both localized and global contexts through parallel convolutions.