## 3 Drill Pipe Counting Method Based on YOLOV7-GFCA Network
### Backbone Network Improvements  
In the coal mine drilling site environment, a crucial role is played by the YOLOv7 backbone network in the extraction of essential features, including the appearance, color, and shape of the drilling rig. However, the utilization of the ELAN module by the original backbone network introduces feature representation redundancy, leading to increased computational requirements and model complexity. To address these issues, a proposal is made in this study to replace the ELAN structure with GhostNetV2, serving as a more efficient backbone network for feature extraction. With its ability to reduce redundancy and computational overhead, higher efficiency is offered by GhostNetV2, rendering it a suitable choice for enhancing the performance of the detection system in the coal mine drilling environment. Lightweight GhostNetV2 is comprised of two Ghost modules and one DFC module. The generation of feature maps with an increased number of channels is undertaken by the first Ghost module. Subsequently, the channel dimension of the feature maps is effectively compressed by the second Ghost module, reducing redundancy. Furthermore, the decoupled fully connected (DFC) attention mechanism is employed to capture long-range pixel dependencies both horizontally and vertically. Through the collaborative operation of these combined components, the network's capacity for extracting meaningful features is enhanced. A visual representation of the proposed GhostNetV2 architecture is provided in Figure 3 for reference. Figure 2: Flow chart of drill pipe counting based on YOLOV7-GFCA target detection network (the red part in the backbone network Ghost and neck network FCA is our improvement, and Conv*4 is the input tensor passing through four convolutional layers continuously). Designed for the generation of more feature maps using fewer parameters, the Ghost module serves as a key component in GhostNetV2. In each convolutional layer of the neural network, numerous multiplication and accumulation operations are involved in the convolution operation. This results in a substantial computational resource demand during the model's training and inference processes. To generate feature maps, the Ghost module employs simple linear transformation operations in place of convolution operations, thereby assisting the network in maintaining a high level of representational capacity. When considering the same number of input and output feature maps, fewer parameters are required by the Ghost module compared to conventional convolutional modules. All pixels in the row and column of a certain pixel position in DFC directly participate in the calculation of point attention, and all pixel positions in this area also indirectly participate in the calculation of point attention through decoupling operations, thus avoiding reorganization and recombination and other computationally intensive operations. The input is the original feature \(Z\in R^{W\times H\times C}\), and it is regarded as a \(H\times WToken\); \(Z\in\{Z_{11},Z_{12},\ldots,Z_{HW}\}\) is the generated feature map. The width, height, and number of channels of the input feature map are represented by \(W\), \(H\), and \(C\), respectively, where _Token_ is represented a single element in the input sequence. The attention map generated by the fully connected layer is generated by Equation (1). The long-range correlations along both horizontal and vertical directions are then captured separately. \[ \begin{split} a_{hw}=\sum\limits_{h^{\prime},w^{\prime}}F_{hw,h^{ \prime}w^{\prime}}\otimes Z_{h^{\prime}w^{\prime}}\\ h=1,2,\ldots,H,w=1,2,\ldots,W\end{split}  \tag{1}\]  
where \(\otimes\) is represented matrix multiplication; \(F\) is the weight coefficient in the fully connected layer; \(h,w\) are the width and height of the feature map, and \(\{a_{11},a_{12},\ldots,a_{HW}\}\) is the generated attention map. Equation (2) is used to capture aggregated features in the horizontal direction.