# Fish Detection in Fishways for Hydropower Stations Using Bidirectional Cross-Scale Feature Fusion
## 2 Materials and Methods
### Bidirectional Cross-Scale Feature Fusion in Backbone  
The backbone is engineered for efficient and high-performance feature extraction, in which the Cross Stage Partial Fusion (C2f) module offers strong feature extraction and fusion capabilities by utilizing partial connections and multiple bottleneck layers. However, its performance may be hindered by the challenges of low-contrast imagery, complex backgrounds, and small object detection. In this paper, we propose a C2f-Faster-EMA module by integrating C2f, EMA [27], and Faster Block [28] modules to enhance multi-scale feature fusion, global attention, and computational efficiency in the detection process, as shown in Figure 3b. The approach is as follows. Inspired by FasterNet, we integrate Partial Convolution (_PConv_) with C2f, aiming to achieve a faster network and reduce floating-point computations. Figure 3a illustrates the basic principle of _PConv_, which applies a conventional convolution on a portion of the input channels for spatial feature extraction while keeping the remaining channels unchanged. The computational cost of conventional convolution is denoted as \(h\;*\;w\;*\;k^{2}\;*\;c^{2}\), while the computational cost of _PConv_ is denoted as \(h\;*\;w\;*\;k^{2}\;*\;c_{p}^{2}\). In the case of a classic offset ratio of \(r=\frac{c_{p}}{c}=\frac{1}{4}\), the floating-point operations of _PConv_ are only \(\frac{1}{16}\) of those of full convolution. This significantly reduces computational overhead while improving computational efficiency. By treating the first or last continuous channel as a representative of the entire feature map for computation, memory access is further minimized. Memory access count of _Conv_, as illustrated in Equation (1)  
\[h\times w\times 2c+k^{2}*c^{2}=h\times w\times 2c \tag{1}\]  
Figure 2: The overall framework of the fishway fish detection model and the details of some modules. Memory access count of _PConv_, as illustrated in Equation (2)  
\[h\times w\times 2c_{p}+k^{2}\times c_{p}^{2}=h\times w\times 2c_{p} \tag{2}\]  
With the offset ratio remaining unchanged, _PConv_ accesses memory \(\frac{1}{4}\) as many times as conventional convolution during convolution calculations. By using _PConv_ in C2f-Faster, the advantages of parallel computation can be leveraged to accelerate the training and inference processes of the model, thereby improving its efficiency. In addition, to more effectively focus on important feature information and improve object detection accuracy, we have added a multi-scale feature extraction module, EMA, based on the above. EMA utilizes three parallel paths to extract attention-weight descriptors from the grouped feature maps, as shown in Figure 3c. The input tensor shape is defined as \(C//G\times H\times W\) where the first two parallel paths are \(1\times 1\) branches, and the third parallel path is a \(3\times 3\) branch. To capture the dependencies among all channels and reduce computational load, a one-dimensional global average pooling operation is applied in the horizontal or vertical dimension direction in the \(1\times 1\) branch, represented by Equations (3) and (4):  
\[Z_{\text{C}}^{H}(H)=\frac{1}{W}{\sum}_{0\leq i\leq W}\,X_{\text{C}}(H,i) \tag{3}\]  
\[Z_{\text{C}}^{W}(W)=\frac{1}{H}{\sum}_{0\leq j\leq H}\,X_{\text{C}}(j,W) \tag{4}\]  
where \(C\) is the number of channels, \(H\) and \(W\) are the spatial dimensions of the input features. Feature extraction is performed without dimensionality reduction, followed by fitting the 2D binomial distribution after linear convolution using two nonlinear Sigmoid functions. The channel attention maps within each group are aggregated through multiplication, achieving different cross-channel interaction features between the two parallel paths. On the other path, a \(3\times 3\) convolution captures local cross-channel interactions, expanding the feature space. Figure 3: The improved structure diagram of each part of the C2f module: (**a**) Structure diagram of the Faster Block module and a schematic of the convolution principle.