## 3 Method
### Model Improvement and Optimization
#### 3.3.2 Introduction of Coordinate Attention Mechanism  
The accuracy of model identification is impacted because the coal and rock photos in this research include many microscopic cracks that are difficult to see and are quickly obstructed by the backdrop. As a result, some minor target information is lost during the detection process. Deep learning has recently included attention mechanisms, the main goal of which is to have the network to focus on the areas that require greater attention. At CVPR2021, [PERSON] et al. proposed a coordinate attention (CA) mechanism that can embed location information into channel attention. By simultaneously encoding features along the horizontal and vertical axes of space, CA can obtain channel information, position information, and spatial dependencies. Consequently, this article increased the model's capability to precisely locate and identify target features with almost no extra computing expense by incorporating the CA method. The structure diagram of the CA mechanism is shown in Figure 6.  
Figure 5: Replaced Ghost series modules. (**a**) Ghostconv; (**b**) GhostBottleneck; (**c**) C3 Ghost.  
CA encoded the input feature maps with the size \(C\times H\times W\) using pooling kernels with the size \(H\times 1\) horizontally and \(1\times W\) vertically for each channel. After encoding, a pair of feature maps \(Z^{h}\) and \(Z^{w}\) demonstrating the orientation perception were generated. When the height is h, the output formula of the cth channel of \(Z^{h}\) and \(Z^{w}\) is as follows:  
\[Z^{h}_{c}(h)=\frac{1}{W}\sum_{i=0}^{W}X_{c}(h,i) \tag{3}\]  
\[Z^{w}_{c}(w)=\frac{1}{H}\sum_{i=0}^{H}X_{c}(j,w) \tag{4}\]  
Then, the feature maps \(Z^{h}\) and \(Z^{w}\) were cascaded, and the F and \(\delta\) nonlinear activation functions were transformed through \(1\times 1\) convolution. The operation formula is as follows:  
\[f=\delta\Big{(}F\Big{[}Z^{h},Z^{w}\Big{]}\Big{)} \tag{5}\]  
The intermediate feature map \(f\in R^{C/r\times 1\times(H+W)}\) was obtained, and \(r\) represents the downsampling ratio.  
Next, the intermediate feature map \(f\) was decomposed into two separate tensors \(f^{h}\in R^{C/r\times H}\) and \(f^{w}\in R^{C/r\times W}\) along the spatial dimension. Using two \(1\times 1\) convolution operations, \(F_{h}\) and \(F_{w}\), and the sigmoid activation function, \(f^{h}\) and \(f^{w}\) were transformed into the same number of channels as the input feature map. The formula is as follows:  
\[g^{h}=\sigma\Big{(}F_{h}\Big{(}f^{h}\Big{)}\Big{)} \tag{6}\]  
\[g^{w}=\sigma(F_{w}(f^{w})) \tag{7}\]  
Figure 6: Coordinate attention mechanism.  
Finally, the attention weight maps \(g^{h}\) and \(g^{w}\) in the two spatial directions were extended and output. The final output formula of the CA module is as follows:  
\[y_{c}(i,j)=x_{c}(i,j)\times g^{h}_{c}(i)\times g^{w}_{c}(j) \tag{8}\]  
A plug-and-play module that can be installed behind any feature map is the attention mechanism. Adding it to the backbone portion may enable the model to enhance the initial feature extraction of the network and may increase the prediction impact since the features extracted from the backbone component serve as the foundation for further processing. Therefore, this paper embedded the attention mechanism behind the C3 Ghost module in the backbone.