## 3 Drill Pipe Counting Method Based on YOLOV7-GFCA Network
### Feature Fusion Network Improvement  
Feature fusion networks play a key role in the integration of multi-scale features. In the original feature fusion network, a deep residual structure is adopted. As the depth of the network increases, a surplus of redundant features will be generated. These features contain complex backgrounds, such as coal dust and strong light, which may adversely affect the detection of drilling rigs. Therefore, an optimized method is needed to deal with the challenges brought by the existence of redundant features and complex backgrounds, and to ensure accurate and efficient detection of rigs. ELAN is replaced by the FasterNet module as the main component of the feature fusion network. Figure 4a shows the components of FasterNet, which consists of a Pconv module and two Convs. This combination can extract spatial features more efficiently by reducing redundant computation and memory access. However, due to the special operating environment of coal mines, neural networks can easily extract useless features, such as coal dust, strong light, and miners who are working. In order to improve the Fasternet module's ability to express rigs, we introduced an improved CA attention mechanism on the left, which makes the network more focused on extracting rig features in complex environments, while reducing the extraction of redundant features and improving the accuracy of detecting rigs. Figure 4b is the overall module structure diagram of FCA. The reduced computational load achieved by the FasterNet module can be attributed to the clever design of the PConv. Unlike the conventional convolution approach that applies a comprehensive convolution to the feature map, PConv exclusively executes convolution on a section of the input channels, leaving the other channels unaltered. To leverage the entirety of channel information, two \(1\times 1\) pointwise convolutions are subsequently employed following the PConv to comprehensively extract features from all channels. For the input feature map \(D\in R^{c\times m\times n}\), use \(c\) convolution kernels \(k\times k\) for convolution operation and \(m\), \(n\) are the height and width of the input feature map. The amount of parameters to calculate the ordinary convolution is generated by Equation (4). \[Flops_{\textit{conv}}=m\times n\times k^{2}\times c^{2} \tag{4}\]  
For PConv, it only convolutes some features. When the ratio is set to \(1/4\) of the original channel. The amount of parameters to calculate the PConv is generated by Equation (5). \[Flops_{\textit{pconv}}=m\times n\times k^{2}\times\left(\frac{1}{4}c\right)^{2} \tag{5}\]The amount of parameters generated by PConv is only \(1/16\) of the amount of ordinary convolution parameters. For the remaining channels, two \(1\times 1\) convolution kernels are used for convolution. In order to enhance the ability of the device to deal with complex backgrounds, such as coal dust, an improved CA attention mechanism is integrated in the original FasterNet, and a deep convolution branch is added to better extract context information (\(F_{2}\)). This improved attention layer consists of three branches: deep convolution branch, residual branch and attention branch (\(F_{1}\)). Within the attention branch, feature extraction is performed on the feature maps in the horizontal and vertical directions, then the coordinate matrix is derived and the similarity is calculated to obtain the attention matrix (\(F_{1}\)) by Equations (6)-(8). By incorporating the improved CA attention mechanism, the network obtains improved feature representation and enhanced discriminative ability, resulting in enhanced detection performance in coal dust and similar challenging environments.