## 2 Related Work
### BiFPN  
As the network depth increases, the convolutional neural network progressively extracts image features, leading to the abstraction of semantic information. This abstraction  
Figure 1: Structure of self-attention mechanism.  
may result in the neglect of features related to small objects. YOLOv1 utilized a single feature map structure (depicted in Figure 2a), which limited the feature scale of the prediction layer and consequently affected its detection performance for small targets. To enhance the model's adaptability to various input sizes, YOLOv3 integrated the Feature Pyramid Network (FPN) structure [11] into the original network architecture [13].  
A Feature Pyramid Network (FPN) addresses the issue of excessive computation in image pyramids by establishing a distinctive feature pyramid, as illustrated in Figure 2b. It effectively tackles the challenge of multi-scale variations in target detection, achieving a state-of-the-art performance at the time. Notably, as the network depth increases within the FPN architecture, the extraction of high-level semantic features significantly enhances the network's image recognition capability, albeit at the expense of diminishing target location information. To address this concern, YOLOv4 integrates a Path Aggregation Network (PANet) with the FPN to amalgamate image features. PANet introduces supplementary bottom-up connections on top of the FPN to facilitate a more efficient information transfer from the lower to the upper layers, as depicted in Figure 2c. YOLOv5 similarly adopts the FPN + PANet combination structure for feature fusion. The top-down FPN structure offers enhanced semantic information (Figure 3a), while the bottom-up PANet structure provides superior positional information (Figure 3b), thereby delivering heightened semantic and positional details during feature layer prediction and enhancing the accuracy of target detection tasks. However, in YOLOv5, PANet functions solely as a straightforward bidirectional feature fusion mechanism. By overlaying and sampling feature images with varying resolutions, high-resolution feature images are generated and subsequently fed into the subsequent detection head for target identification. Given that feature maps of different resolutions contribute disparately to the output features, this simplistic addition approach may lead to uneven output features. To address these challenges, we substituted the FPN + PANet network [33] in the original YOLOv5 with BiFPN.  
The enhancement of the network's multi-scale target recognition capability can be achieved without escalating computational costs, thereby enhancing the identification accuracy of small and medium-sized targets in sewage images. BiFPN incorporates trainable weights to assess the significance of various input features and merges them based on the assigned weights to concentrate on crucial layers and diminish superfluous layer node connections. Moreover, when the dimensions of input and output nodes are identical, the integration of additional input channels allows for the fusion of more features without a rise in computational expenses.  
Figure 2: Structure of BiFPN.