# Image Recognition and Classification of Farmland Pests Based on Improved Yolox-Tiny Algorithm
## 4 Experiment and Analysis
### Experimental Results  
This experiment employed mean Average Precision (mAP) and Average Precision (AP) as evaluation metrics for pest target detection.  
mAP and AP calculations are based on the Precision and Recall of the model's training samples, with the corresponding formulas presented as follows:  
\[\text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{1}\]  
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{2}\]  
In the formulas, TP denotes true positives, correctly identified; FP represents false positives, incorrectly identified as negative; and FN indicates false negatives, incorrectly identified as positive.  
Average Precision (AP) is calculated from the area under the Precision-Recall (P-R) curve, as follows:  
\[\text{AP}=\int_{0}^{1}\text{Precision}\text{Recall} \tag{3}\]  
Mean Average Precision (mAP) is calculated as the average of the Average Precision (AP) across all categories, expressed as follows:  
\[\text{mAP}=\frac{1}{n}\sum_{i=1}^{n}\text{AP}_{i} \tag{4}\]  
In the formula, n represents the number of sample categories, and i denotes the current index.  
The complete dataset was employed to train two models, generating both training and testing loss curves, as illustrated in Figure 9.  
To verify the reliability of the experimental results, this study assessed the recognition and classification performance of the YoloV4-tiny model from the same series on this dataset. The evaluation of the Yolox-tiny, modified Yolox-tiny, and YoloV4-tiny models involved calculating the AP for each pest type and the overall mAP. For a comparison of the APs, refer to Figure 10.  
Figure 9: Model Loss Function Curves.  
According to data from Figure 11 and Table 4, the AP values for six types of pests in the enhanced Yolox-tiny model are at least equivalent to, if not higher than, those in the original Yolox-tiny model, except for the rice leafroller (pest ID: 7), which shows a slightly lower AP value. Furthermore, the AP values of the enhanced Yolox-tiny model exceed those of the YoloV4-tiny model. These findings demonstrate that the enhancements significantly improved the pest-detection capabilities of the model. For detailed mAP comparison results, see Table 4.  
According to Table 4, the mAP for the Yolox-tiny model is 63.55%, for the YoloV4-tiny model is 54%, and for the enhanced Yolox-tiny model is 70.73%. The Precision-Recall (P-R) curve of each type of pest is shown in Figure 11.  
The P-R curve indicates that it is challenging to balance Precision and Recall for pests numbered 10 and 256. There is a significant negative correlation between Precision and Recall for pest number 10, while for pest number 256, there is a sharp drop in Precision after Recall exceeds 0.5, suggesting that the model still requires improvements in detecting these two types of pests. However, the detection of the other five types of pests shows better results in the P-R graph, with the Area Under the Curve (AUC) estimates all exceeding 0.7.  
Compared to the Yolox-tiny and YoloV4-tiny models, the enhanced Yolox-tiny model achieved increases in average precision of 7.18% and 16.73%, respectively, underscoring its superiority over the original Yolox-tiny and YoloV4-tiny models.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Pest ID** & **Yolox-Tiny** & **YoloV4-Tiny** & **Improved Yolox-Tiny** \\ \hline  & AP & AP & AP \\
7 & 86\% & 71\% & 80\% \\
9 & 66\% & 59\% & 69\% \\
10 & 46\% & 34\% & 58\% \\
148 & 74\% & 66\% & 74\% \\
156 & 59\% & 48\% & 74\% \\
256 & 48\% & 37\% & 52\% \\
280 & 46\% & 61\% & 88\% \\ mAP & 63.55\% & 54\% & 70.73\% \\ \hline \hline \end{tabular}
\end{table}
Table 4: Comparison of Training Results between Original and Improved Models.  
Figure 10: Comparative Results of Pest Detection by Category.  
Figure 11: Precision-Recall (P-R) curve of each type of pest.