# Gender Identification of Chinese Mitten Crab Juveniles Based on Improved Faster R-CNN
## 2 Materials and Methods
### Methods
#### 2.3.2 PAPPN  
The Feature Pyramid Network (FPN) is the basic structure of the target detection framework and is widely used in multi-scale fusion [27]. The research subject of this article, Chinese mitten crab juveniles, presents challenges such as small size, similar shapes, and complex backgrounds. In the conventional FPN structure, different levels of feature maps convey varying degrees of information. Low-level features usually contain more edge information, while high-level features contain more global semantic information. This leads to an imbalance of information between feature maps, making it difficult to effectively fuse and transfer them. It reduces the number of channels of the feature map through a \(1\times 1\) convolution operation for feature fusion. However, this process may result in partial loss of semantic information due to the compression of feature channels. At the same time, FPN's feature map fusion mainly focuses on local areas and lacks global attention to other levels of feature maps. This may introduce noise during feature map fusion, thus affecting detection performance. Given this, this article proposes an improved feature pyramid network--Path Aggregation Feature Pyramid Network (PAFPN) combined with Swin Transformer. Different from traditional FPN, the core advantage of Path Aggregation Network (PAN) is that it can effectively aggregate features at different levels to provide a more comprehensive and continuous information flow. By combining this advantage of PAN with FPN, PAFPN can not only reduce feature loss but also enhance the model's detection ability for small, similar-shaped targets with complex backgrounds such as Chinese mitten crab larvae.  
The PAFPN in this research combines a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN). As shown in Figure 5, the input image of a crab undergoes FPN's bottom-up feedforward processing to generate features [C2, C3, C4, C5]. This process transitions the information flow from low-level features, like the edge and color of the crab's abdomen, to high-level features, such as the overall part of the abdomen. Each stage involves down-sampling, resulting in subsequent feature maps that are higher in semantic level but smaller in size, which potentially leads to the loss of detailed information. Then, FPN performs top-down path enhancement, starting from the highest-level feature map, up-sampling it, and fusing it with the next-level feature map. This process repeats at each stage, ultimately yielding multi-scale feature maps rich in semantic information [P2, P3, P4, P5]. To better preserve the shallow feature information, this paper introduces bottom-up path aggregation, as illustrated by the dotted arrows. Shallow features first reach the P2 layer through lateral connections in the original FPN, then ascend to the top layer via bottom-up path augmentation. This approach enables feature maps at different levels to share information, undergo multiple iterations of bottom-up and top-down collection and fusion, and eventually form the fused {N2, N3, N4, N5} features for subsequent classification and regression tasks.  
The detailed structure of bottom-up path augmentation is shown in Figure 6. After a convolution with a size of 3 \(\times\) 3 and a stride of 2, the feature map size is reduced to half of the original size, and then compared with \(P_{i+1}\) The feature map is tensor connected, and the result is passed through a convolution layer with a convolution kernel size of 3 \(\times\) 3 and a stride of 1 to obtain \(N_{i+1}\).