## 2 Materials and Methods
### Network Model Construction
#### Multiscale feature fusion  
The Concat module in the Neck section, which includes both FPN and PAN, plays a critical role in the fusion of image information. As depicted in Figure 4a and described by Equation (1), traditional FPN networks use input features \(P_{i}^{in}=\left(P_{3}^{in}\cdots P_{7}^{in}\right)\) with 3-7 layers, where \(P_{i}^{in}\) denotes the resolution level \(in/2^{i}\) of the input image. Features are aggregated from top to bottom, and _resize_ usually involves upsampling or downsampling for resolution matching, while _Conv_ is typically used for feature processing. This results in feature fusion being limited by a unidirectional flow of information, which is ineffective in extracting features of small weed targets in agricultural settings with high similarity and indistinct color features. To enhance the detection capabilities of small targets in agricultural environment, this paper introduces a Bidirectional Feature Pyramid Network (BiFPN). \[ \begin{array}{l}P_{7}^{out}=Conv\big{(}P_{7}^{in}\big{)}\\ P_{6}^{out}=Conv\big{(}P_{6}^{in}+resize\big{(}P_{7}^{out}\big{)}\big{)}\\ \cdots\\ P_{3}^{out}=Conv\big{(}P_{3}^{in}+resize\big{(}P_{4}^{out}\big{)}\big{)}\\ \end{array}  \tag{1}\]  
BiFPN represents an efficient bidirectional framework for cross-scale connections and fast normalization of feature fusion. From the network topology (Figure 4b,c), it can be seen that BiFPN modifies the multiscale connections within the PAN architecture: Initially, \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Scale** & **Depth** & **Width** & **mAP50** & **FPS** & **Size (MB)** \\ \hline N & 0.33 & 0.25 & 0.859 & 277.7 & 6.8 \\ S & 0.33 & 0.50 & 0.872 & 147.0 & 23.9 \\ M & 0.67 & 0.75 & 0.875 & 33.2 & 54.9 \\ L & 1.00 & 1.00 & 0.876 & 5.4 & 92.3 \\ X & 1.00 & 1.25 & 0.878 & 1.2 & 548 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Results of training multiscale models. Figure 4: Topology diagram of the FPN [26], PAN [27], and BiFPN [24] networks. it removes network nodes that have a single input feature edge without fusion, creating a simplified bidirectional network. Subsequently, when the original input and output nodes are at the same level, an additional pathway is added between them to enable more feature fusion without significantly increasing computational costs; Lastly, unlike PAN, which features only one top-down and one bottom-up pathway, each bidirectional (top-down and bottom-up) pathway is implemented as a feature network layer, repeated multiple times to achieve advanced feature fusion. Different input features have varying resolutions, and compared to the high resolution of crops, the smaller resolution of weed inputs leads to a significant imbalance in the network's output contributions. Traditional methods treat all input features equally without distinction, which is not ideal in practical applications. [PERSON] et al. [24] assigned varying weights to input features, significantly enhancing the network's performance in detecting small objects. Therefore, we propose adding an additional weight to each input feature, enabling the network to learn the significance of each feature and preventing it from overlooking the small-scale features of weeds. Based on this concept, BiFPN uses fast normalized fusion, as described in Equation (2), an efficient and stable weighted fusion mechanism that applies an \(ReLu\) activation function after each \(w_{i}\) to ensure that \(w_{i}\geq 0\) and \(\varepsilon=0.001\) are small, keeping each normalized weight between 0 and 1. Fast normalized fusion, similar in learning behavior and accuracy to Equation (3) (Softmax-based fusion), omits the \(Softmax\) operation, allowing BiFPN to run 30% faster on GPUs. To further enhance efficiency, we use depthwise separable convolutions for feature fusion and add batch normalization and activation after each convolution.