# Image Recognition and Classification of Farmland Pests Based on Improved Yolox-Tiny Algorithm
## 2 Related Work
### Yolox-Tiny Algorithm Model Structure  
As illustrated in Figure 1, the Yolox-tiny network structure primarily comprises three components: the backbone feature extraction network, the enhanced feature extraction network, and the classifier and regressor.  
1. Backbone feature extraction network: CSPDarknet;
2. Enhanced feature extraction network: FPN;
3. Classifier and regressor: Yolo Head.  
The CSPDarknet network primarily employs a residual network architecture to initially extract feature layers of various sizes from the input image. The architecture comprises one Focus module, one Conv2D_BN_SiLU module, and four Resblock_body modules. The input image dimensions are 1600 \(\times\) 1600 pixels with 3 channels. Following multiple 1 \(\times\) 1 and 3 \(\times\) 3 convolutions, downsampling, and maximum pooling, the network produces three differently sized feature layers with varying channel counts: intermediate layer feat1 (200 \(\times\) 200, 256 channels), mid-lower layer feat2 (100 \(\times\) 100, 512 channels), and bottom layer feat3 (50 \(\times\) 50, 1024 channels).  
The FPN network constructs a feature pyramid with three output layers from the CSPDarknet network, enhancing the feature extraction process and thereby improving object detection accuracy. The FPN network comprises a Concat module, CspLayer module, UpSampling2D module, Conv2D module, and Downsample module. The Concat module facilitates effective layer fusion, the UpSampling2D module upsamples feature layers, the Conv2D module applies 1 \(\times\) 1 convolutions to adjust image channel numbers, and the Downsample module downsamples feature layers. The FPN network conducts multiple operations of upsampling, feature fusion, and downsampling on input feature layers feat1, feat2, and feat3, resulting in enhanced feature layers: feat4 (200 \(\times\) 200, 256 channels), feat5 (100 \(\times\) 100, 512 channels), and feat6 (50 \(\times\) 50, 1024 channels).  
In the process of feature fusion, early features and late features can both be considered for integration. However, in limited training sets, this integration may lead to degradation, which is particularly severe in early feature fusion. Therefore, this study opted not to use early feature fusion of the CSPDarknet network, but rather to fuse the late features feat1, feat2, and feat3. This choice helps to reduce degradation and ensures the effectiveness of feature extraction [27]. This study employed a direct upsampling fusion method. This method is simple and effective but can be further optimized. For instance, using graph-based linear or nonlinear regularization \(\alpha\)-integration methods can reduce the discreteness between fused features, enhancing their expressive capability [28].  
In summary, this method of constructing the feature pyramid effectively merges features across different layer sizes, thereby enriching the feature information obtained.  
The Yolo Head consists solely of Conv2D_BN_SiLU convolution modules. The outputs, which include predictions for classification (Cls), regression (Reg), and objectness (Obj), are detailed in Figure 2.  
The Yolo Head is primarily divided into two sections: the left side classifies object types, while the right side assesses object presence within the prediction box and determines the box's coordinates. The enhanced feature layers--feat4, feat5, and feat6--from the FPN network are fed into the Yolo Head, which processes each layer to derive Cls, Reg, and Obj outputs. Here, \"Cls\" represents the object's class, \"Reg\" denotes the prediction box's location, and \"Obj\" indicates the coordinates of the prediction box. Ultimately, these three predictions--box location, coordinates, and class--are integrated to generate comprehensive details about the target objects.  
Figure 1: Yolov-tiny Network Structure.