A lightweight rice pest detection algorithm based on improved YOLOv8 Authors: Yong Zheng, Weiheng Zheng, Xia Du Published: 2024 ABSTRACT AbstractTimely and accurate detection of rice pests is highly important for pest control, as well as for improving rice yield and quality. However, owing to the high interclass similarity, significant intraclass age differences, and complex backgrounds among different pests, accurately and rapidly identifying a variety of rice pests via deep neural network models poses a significant challenge. To address this issue, this paper presents a fast and accurate method for rice pest detection and identification named Rice-YOLO (You Only Look Once). This model is based on YOLOv8-N and incorporates an efficient detection head designed for the complex characteristics of pests. Additionally, deep supervision layers were introduced into the network, along with the incorporation and improvement of the dynamic upsampling module. The experimental data included the large-scale pest public dataset IP102 and the sixteen-class rice pest dataset R2000. The experimental results demonstrated that Rice-YOLO outperformed previous object detection algorithms, with 78.1% mAP@0.5, 62.9% mAP@0.5:0.95, and 74.3% F1 scores.Keywords: Rice pest detection, YOLOv8, Object detection, Deep learning, Computer visionSubject terms: Biological techniques, Computational biology and bioinformatics, Plant sciences, Zoology, Ecology, Environmental sciences, Mathematics and computing Introduction With the continuous increase in the global population, the demand for food is also constantly rising. Rice is a staple food for more than half of the world’s population1. It plays a crucial role in agricultural production, and its high yield characteristics can effectively alleviate the problem of food shortages. Rice cultivation not only provides a livelihood for farmers but also drives the development of the agricultural economy. However, rice is susceptible to various pests during its growth process. These pests can cause damage to rice leaves, reduce the moisture content, and lead to bacterial infections, all of which severely affect the yield and quality of rice2,3. According to the International Rice Research Institute, pests cause an average annual loss of 37% in rice production for farmers. Therefore, the detection and prevention of rice pests are urgently needed. Traditional pest detection methods rely primarily on manual identification, which places certain demands on the judgement abilities of personnel and identification equipment4. Additionally, manual identification not only requires significant human labour but also carries the risk of erroneous judgement by staff; this can affect the selection of pesticides and potentially lead to environmental pollution. With the development of computer technology, traditional image processing techniques have been widely used to identify specific pests5. Manually designed image features alleviate the labour and time issues associated with pest detection and improve the efficiency of pest identification. However, traditional image processing techniques are often suitable only for the detection of specific pests in simple scenarios, making it difficult for these methods to be widely applied in various complex environments. With the development of deep learning, convolutional neural networks, which can automatically extract image features, have gained widespread attention. In recent years, many classic deep learning architectures, such as AlexNet6,7, VGGNet8,9, Inception10,11, ResNet12,13, and DenseNet14,15, have been applied to agricultural pest detection. Owing to the small interclass differences, complex backgrounds, and significant variations in the appearance of the same type of pest at different developmental stages, designing an efficient algorithm for rice pest detection has become a major challenge. Ali et al.16 proposed a lightweight pest detection method that is based on Faster R-CNN and uses MobileNet as the backbone network, which improves the model’s ability to identify pests. Wang et al.17 proposed an agricultural pest detection algorithm based on an improved Faster R-CNN. They combined an improved feature pyramid network with the backbone network, used the bilinear interpolation method of the ROI align algorithm instead of the rounding quantization in the ROI pooling algorithm for calculations, and introduced a convolutional block attention module. The improved model has better feature extraction capabilities and significantly improved detection accuracy. Li et al.18 proposed a greenhouse tiny pest detection method based on Faster R-CNN. By employing a transfer learning strategy, they enhanced the robustness of pest detection under greenhouse conditions, enabling rapid collection of pest count information. The aforementioned algorithms are two-stage detection algorithms. They first search for regions in the image that may contain objects and then perform object localization and classification on these candidate regions. Compared with one-stage algorithms, two-stage detection algorithms have higher accuracy but slower detection speed. Chu et al.19 proposed a grain storage pest detection model based on YOLOv5. This model incorporates a bidirectional feature pyramid and a channel attention mechanism, and improves the nonmaximum suppression algorithm using distance intersection over union. The improved model can achieve grain storage pest detection in complex storage environments. Xiang et al.20 proposed an improved pest recognition model based on YOLOv5. This model incorporates the squeeze-and-excitation attention mechanism and ConvNeXt module, and constructs a feature extraction module for small sample learning based on the stacked residual structure of the standard bottleneck module. The improved model offers higher detection accuracy and robustness. Yang et al.21 proposed a tea plantation pest detection model based on YOLOv7. This model utilizes deformable convolutions and a dynamic attention mechanism, incorporates a new implicit decoupling head, and uses a softened nonmaximum suppression algorithm in place of the original nonmaximum suppression algorithm in model predictions. The improved model has fewer parameters and can achieve fast and accurate tea pest detection. One-stage algorithms do not have a candidate box screening process; instead, they directly regress the position coordinates of the object box and the classification probability of the object; as entirely end-to-end object detection algorithms, this gives them a significant advantage in terms of detection speed. Researchers have already applied one-stage object detection models to agricultural pest detection, but these models still lack efficiency. Therefore, it is necessary to develop an accurate and efficient algorithm for rice pest detection. The YOLO series of algorithms are mainstream one-stage object detection algorithms. This study uses YOLOv8 for rice pest detection and proposes an improved version, named Rice-YOLO, that achieves precise detection of rice pests. The main contributions of this study are as follows: Lightweight Detection Head: Given the diverse types of pests and complex back-grounds, we propose a lightweight detection head that not only improves the detection performance of the model but also reduces hardware overhead. Lightweight Detection Head: Given the diverse types of pests and complex back-grounds, we propose a lightweight detection head that not only improves the detection performance of the model but also reduces hardware overhead. Deep Supervision Technology: We introduce deep supervision technology, integrating multiple detection heads for joint detection; this enhances the model’s perception of complex pest-related information without adding an extra inference burden. Deep Supervision Technology: We introduce deep supervision technology, integrating multiple detection heads for joint detection; this enhances the model’s perception of complex pest-related information without adding an extra inference burden. Dynamic Upsampling Module: We incorporate a dynamic upsampling module and improve the sampling offset strategy to enhance sampling flexibility and the model’s feature upsampling capability. Dynamic Upsampling Module: We incorporate a dynamic upsampling module and improve the sampling offset strategy to enhance sampling flexibility and the model’s feature upsampling capability. Materials and methods Dataset Owing to the current scarcity of rice pest datasets, the experimental data include both the large public crop pest dataset IP102 and the R2000 rice pest dataset, which are collectively referred to as IPR16 in this study. IP102 IP10222 is a large-scale benchmark dataset for pest identification, covering 102 common crop pests with over 75,000 images. The data encompass images of pests throughout their entire lifecycles. This dataset is characterized by significant intraclass variation, small intraclass variation, and complex backgrounds, making the object detection task based on IP102 a substantial challenge. For this study, only the rice-related pest data from IP102 were used, which comprise 14 classes and 1248 images. Importantly, the publicly available IP102 dataset contains duplicate and misclassified images. Therefore, the rice pest data from IP102 were screened and cleaned, resulting in a preprocessed dataset containing 16 categories and 532 images. R2000 The R2000 dataset originated from our previous work, which was constructed by referencing the rice pest data from IP102, and shares the same data characteristics. The images were sourced from common image search engines, including Google, Flickr, and Bing etc. The use of internet-collected images is a widely adopted method for constructing large public datasets such as IP102, ImageNet23, and Microsoft COCO24. The R2000 rice pest dataset contains 16 categories and 2024 images. IPR16 The limited amount of data restricts the model’s ability to acquire comprehensive information, thereby reducing the scientific value and reliability of the experiments. Therefore, in this study, the above two datasets with similar characteristics were merged, to form IPR16, which includes 16 categories and 2556 images. The details regarding the categories and the number of samples are shown in Table 1. Table 1Categories and sample counts of rice-related pests in IPR16.Class IDPest speciesIP102 (Rice Pest)R2000IPR16ImagesInstancesImagesInstancesImagesInstances1Rice leaf roller909474771641712Pink rice borer15151471491621643Asiatic rice borer555788931431504Yellow rice borer37371031081401455Rice leaf caterpillar891131191211286Small brown plant hopper262698981241247White backed plant hopper30316970991018Brown plant hopper39425265911079Rice leaf hopper454716018220522910Rice gall midge363813115016718811Paddy stem maggot212110911313013412Rice stem fly8836240937041713Grain spreader thrips101013722514723514Rice weevil929211614320823515Rice shell pest151514616016117516Rice horned caterpillar55119120124125Total5325472024228125562828 Categories and sample counts of rice-related pests in IPR16. The number of instances for each category is shown in Fig. 1. As shown in the figure, there is a significant variation in the number of instances across different categories. This variation indicates that the dataset exhibits a characteristic similar to a long-tailed distribution. This more realistic and challenging dataset imposes greater demands on the learning capabilities of the model. Number of instances in each category. The bounding boxes for the instances in each category are shown in Fig. 2. The horizontal axis represents the number of instances corresponding to different bounding box widths, and the vertical axis represents the number of instances corresponding to different bounding box heights. The bars on the axes reflect the quantity of bounding boxes present in the dataset. Different colours of the bounding boxes indicate different categories. There is significant variation in the bounding boxes within the same category. For example, the red bounding boxes in the figure have a range of different sizes. However, there are similarities in the bounding boxes across different categories, as observed with the bounding boxes of varying colours that are similar in size; this highlights the challenges of complex bounding box regression in detecting rice pests. Bounding boxes for instances in each category. Figure 3 shows the distribution of the centre positions of all the instance bounding boxes in the images. The horizontal and vertical axes represent the percentages of instance bounding box centre positions corresponding to the image dimensions. Each instance bounding box centre is depicted as a pixel point in the figure, with darker pixel colours indicating a higher concentration of centre points within that area. Most instances are located near the centre of the images, but some instances are positioned farther from the centre. From the relationship between the positions and the number of instances, it can be observed that IPR16 also exhibits a long-tailed distribution of instance object locations. This characteristic imposes greater demands on the model’s object localization capabilities. Positions of bounding boxes for instances in each category. Figure 4 shows the size distribution of the bounding boxes for all the instances. The horizontal and vertical axes represent the width and height, respectively, of the bounding box. Each instance bounding box is represented by a pixel point in the figure, where darker pixel colours indicate more bounding boxes within that pixel area. The figure, clearly shows that the pixels are widely scattered across the two-dimensional coordinate space. The relationships between the widths and heights of the bounding boxes and their quantities indicate that IPR16 features a variety of aspect ratios. Widths and heights of the bounding boxes for instances in each category. Most of the bounding boxes have relatively similar aspect ratios, whereas a few have significantly different aspect ratios. This variation is due to interclass similarities and considerable differences in appearance and duration across different lifecycle stages. During the bounding box regression process, the shape and scale factors of the regression samples significantly affect the regression results. Therefore, the diverse bounding boxes in IPR16 present a substantial challenge for the model’s bounding box regression capabilities. Rice-YOLO Fast detection is a key feature of the YOLO series, making these models widely applicable across various domains. Over time, through the efforts of different research teams, the YOLO family has undergone multiple iterations, such as YOLOv325, YOLOv426, YOLOv527, YOLOv628, YOLOv729, YOLOv830, YOLOv931 and YOLOv1032. YOLOv8, which was developed by Ultralytics (the creators of YOLOv5), has not only excellent inference speed but also outstanding object localization and identification capabilities. The architecture and size are illustrated in Fig. 5, which was created by GitHub user RangeKing33. Considering the requirements for lightweight and real-time pest detection, this study selects the smallest model, YOLOv8-N, as the baseline model. Structural diagram of YOLOv8. Owing to the high similarity between different pest categories, significant appearance differences in appearance at various life stages, and high similarity between pests and their backgrounds, the YOLOv8-N model performs inadequately for this detection task. To address these issues, this paper presents an improved algorithm, Rice-YOLO, whose structure is illustrated in Fig. 6. Structure diagram of Rice-YOLO. Compared with YOLOv8, Rice-YOLO integrates a newly proposed detection head, DBG, which enhances the model’s ability to perceive complex pest-related information. This enhancement leads to improved detection performance while simultaneously reducing the number of parameters and computational load. Additionally, Rice-YOLO implements intermediate layer supervision with Aux-DBG, which incurs no additional hardware overhead during model inference; furthermore, it incorporates an improved point-based sampling method to replace the original upsampling method, thereby enhancing the model’s upsampling capabilities. These enhancements enable Rice-YOLO to outperform YOLOv8 in terms of detection performance. Diverse branch grouped Head As shown in Fig. 7, based on the YOLOv8 detection head, we introduce the diverse branch block and group convolution to propose an efficient detection head, which is referred to as the diverse branch grouped head (DBG) in this paper. In the figure, , and denote the kernel size, stride and number of groups, respectively. Structural comparison of the YOLOv8 head and DBG head. During model training, the diverse branch block, with its branches of varying scales and complexities, enriches the diversity of the feature space. During model inference, the complex structure of the diverse branch block can be equivalently transformed into a single convolution, ensuring that the model incurs no additional hardware overhead while delivering better performance. Rich feature maps can enhance network performance; however, an excess of feature information may also increase redundancy, potentially leading to model overfitting. To mitigate the negative effect of redundant convolutional kernels, group convolution is employed to replace standard convolution. Each group in group convolution has different inputs, resulting in lower overlap among the features extracted by each group. This effectively reduces redundant information and improves model performance. In Rice-YOLO, the DBG detection head is used to replace the original YOLOv8 detection head. This enhancement improves the model’s ability to perceive complex information related to pests, thereby improving its detection performance while reducing the number of parameters and computational load. Intermediate layer supervision To achieve better training results, we add intermediate-layer supervision to the model. This supervision enables gradients to flow more effectively through the network during backpropagation, which helps prevent gradient vanishing and improves convergence. Therefore, we further introduce the concept of the auxiliary head [29] and apply the DBG head as an intermediate supervisory layer, which we call the auxiliary DBG head (Aux-DBG). As shown in Fig. 8, the auxiliary DBG head is added during the training phase as an intermediate supervisory layer and is removed during the prediction phase, ensuring that there is no additional hardware overhead for model inference. Detailed information on the auxiliary DBG head in the model. During the training phase, the intermediate supervisory detection head can reflect the learning performance of the hidden layers. Providing additional gradients helps the network learn better representations. In Rice-YOLO, the auxiliary DBG head is added as a supervisory layer to the intermediate layers of the network; thisenables the intermediate layers to receive more comprehensive training, effectively mitigating issues such as gradient vanishing and slow convergence that often occur during the training of deep neural networks. DySample–hardtanh DySample + is an efficient upsampler constructed from a point sampling perspective, which optimizes the scope constraint of the offset range based on DySample (DS). We base our method on DySample+ (DS+) and introduce the hardtanh function to replace the original dynamic range factor distribution function, namely, the sigmoid function, thereby improving the offset range suppression strategy. We refer to this improved method as DySample–hardtanh (DSHT). Compared with the sigmoid function, hardtanh further increases the flexibility of the offsets and is easier to compute. The structure of DySample–hardtanh is shown in Fig. 9. Architecture of DySample–hardtanh. Given an upsampling scale factor of and a feature map of size , where , and denote the height, width and number of channels, respectively, DySample–hardtanh generates sampling offsets based on . These are combined with the initial sampling positions to create the sampling set, and the final upsampling result is obtained through bilinear interpolation. During the creation of the sampling set, DySample–hardtanh generates sampling offsets and scaling factors via different linear mappings of the input features. These are then combined with the initial sampling grid after pixel shuffling to produce the final offset. Importantly, the initial offset generation positions are uniformly distributed. The offset amounts must be constrained by scaling factors to reduce overlap in the offset regions. In Rice-YOLO, we employ the efficient upsampling module DySample–hardtanh to enhance the model’s upsampling capability; this enables more valuable rice pest feature information to be output through feature fusion. Performance evaluation method In this study, we selected the mean average precision (mAP), F1 score, detection speed, and floating-point operations per second (FLOPs) as evaluation metrics for model performance assessment. The number of FLOPs represents the computational complexity and is used to measure the model complexity. Precision represents the proportion of objects predicted by the model, where TP denotes the correct positive prediction rate and FP denotes the rate at which the model incorrectly identifies negative instances as positive. Recall represents the proportion of instances correctly detected by the model. FN denotes the rate at which the model incorrectly predicts positive instances as negatives. The mean average precision (mAP) represents the average precision across all classes and is used to evaluate the overall detection accuracy of the model. Here, C represents the number of classes of pests, and i denotes the ith class of pests. The F1-score represents a combined evaluation of precision and recall for the model. Speed represents the average time taken by the model to detect each image and is used to measure the model’s detection speed. Preprocess, inference, and postprocess represent the times taken by the model during the preprocessing, inference, and postprocessing stages, respectively. Experiments and discussion Data processing In this study, we employed a fivefold cross-validation method, where IPR16 was divided into five subsets, as shown in Table 2. Table 2Fivefold division of the IPR16 dataset.Class IDPest speciesImagesInstancesFold 01Fold 02Fold 03Fold 04Fold 05Fold 01Fold 02Fold 03Fold 04Fold 051rice leaf roller333333333234343435342pink rice borer333232323333343232333asiatic rice borer282930292729303132284yellow rice borer292827272930302827305rice leaf caterpillar232424252524252925256small brown plant hopper262525242426252524247white backed plant hopper202019202021211920208brown plant hopper171819191823192120249rice leaf hopper4141414141474246435110rice gall midge3333333335334243343611paddy stem maggot2626272625272727282512rice stem fly7574737474868277819113grain spreader thrips2930302929485041465014rice weevil4242414241494847494215rice shell pest3232323233333340343516rice horned caterpillar25252525242625252524Total512512511511510569567565555572 Fivefold division of the IPR16 dataset. The dataset was divided into five folds for cross-validation, as illustrated in Fig. 10. During model training, three folds were chosen for training, one fold was chosen for validation, and one fold was chosen for testing. The final experimental results represent the average of the fivefold cross-validation results. Fivefold cross-validation of IPR16. The hardware specifications and environmental configuration for the experiments are shown in Table 3, and the model hyperparameter settings are detailed in Table 4. Table 3Hardware specifications and Environmental Configuration.ParametersConfigurationCPUi3-10105 FGPUNVIDIA GeForce RTX 3070GPU memory size8GOperating systemsWindows 10Deep learning architecturePytorch2.0.1 + Cuda 11.8 + cudnn 8.7 Hardware specifications and Environmental Configuration. Table 4Training configuration.ParametersSetupEpoch300Batch size32Image size640 × 640OptimizerAdamWInitial learning rate0.01Final learning rate0.01Momentum0.937Weight decay0.0005 Training configuration. Rice-YOLO detection results Based on the IPR16 dataset, we analysed the detection results of Rice-YOLO, as shown in Fig. 11; Table 5. Different colours represent different categories of pests, with the horizontal axis representing the recall and the vertical axis representing the precision. The area under the curve indicates the average precision, meaning that the larger the area is, the better the performance. A comparison of the PR curves reveals that Rice-YOLO achieved excellent detection performance for most types of pests, with an mAP50 of 78.1% and the highest AP of 90.6%. However, owing to the high interclass similarity of pests and the significant appearance changes across different life stages, the model still faces challenges in detecting and identifying certain types of pests. This highlights potential directions for future improvements. P–R curves and AP values for various pests. Table 5Detection performance of Rice-YOLO on different pests in the IPR16 dataset.Class id P R mAP 50mAP 50:95F1177.92%73.12%80.44%64.32%75.4%272.86%76.90%82.72%63.38%74.8%363.34%49.90%58.64%47.80%55.8%470.54%65.08%67.44%55.28%67.7%573.30%52.34%62.66%45.52%61.1%666.22%67.80%72.72%64.30%67.0%760.48%67.22%67.52%57.04%63.7%864.16%62.24%68.50%58.82%63.2%987.14%73.68%83.68%64.22%79.8%1086.96%78.74%86.78%64.94%82.6%1180.80%78.62%87.10% 76.04% 79.7%12 93.54% 82.28% 90.60% 72.20% 87.5% 1387.46%68.78%78.92%57.04%77.0%1487.60%79.84%87.64% 73.88% 83.5%15 89.36% 77.26%85.50%72.74%82.9%1687.94% 81.12% 89.06% 68.70% 84.4% Significant values are in bold and italics. Detection performance of Rice-YOLO on different pests in the IPR16 dataset. Significant values are in bold and italics. Comparison of different detection models On the IPR16 dataset, we compared Rice-YOLO with mainstream models in the field of object detection, such as YOLOv3, YOLOv4, YOLOv5, YOLOv6, and YOLOv7. The comparison results are shown in Table 6. Rice-YOLO has 2.8 million parameters and 7.2 billion floating-point operations (FLOPs). On the IPR16 dataset, it achieved an mAP50 of 78.1%, an mAP50:95 of 62.9%, and an F1 score of 74.3%. Detailed comparisons with classic models demonstrate that Rice-YOLO outperformed the vast majority of these traditional detection models. Table 6Performance Comparison of Object Detection Algorithms on the IPR16 dataset.ModelParams (M)Layers P R mAP 50mAP 50:95F1Speed (ms)FLOPs (G)FCOS-Resnet1819.13–33.4%49.8%38.6%25.5%40.0%45.5133SSD-Lite-Mobilenetv23.3–46.2%40.1%40.1%23.9%42.9%24.2 0.704 SSD30025.8–59.9%64.7%66.9%40.2%67.4%20.831.174SSD51226.6–70.3%69.3%73.4%44.0%69.8%32.689.647Faster-Rcnn-Resnet1828.7–56.1%61.0%59.5%34.3%58.4%49.4136YOLOv3-Tiny8.73868.6%61.0%64.6%34.6%64.5% 5.2 12.9YOLOv4-Tiny6.19927.0%59.4%42.0%22.7%37.1% 7.1 16.5YOLOv5-N 1.8 15765.6%62.2%65.3%42.5%63.9%10.2 4.2 YOLOv5-N-BiFPN 1.8 15767.5%61.9%66.5%43.2%64.5%10.94.2YOLOv5-S7.115773.5%65.4%70.4%47.2%69.2%10.715.9YOLOv5-M20.921270.4%61.4%66.4%45.3%70.4%13.648.1YOLOv6-N4.214274.7%63.6%71.2%53.3%68.7%12.711.8Gold-YOLO-N5.6–43.1%49.4%45.8%29.3%46.1%18.912.1YOLOv7-Tiny6.020072.8%64.5%69.5%45.3%68.4%31.813.2YOLOv7-Tiny-Silu6.020071.3%62.4%67.3%43.5%66.6%31.413.2YOLOv8-N3.016871.6%68.7%73.1%57.8%70.1%11.88.2YOLOv8-N-BiFPN2.019373.5%63.9%71.8%55.7%68.4%13.17.1YOLOv8-N-Ghost1.731267.7%60.2%66.3%49.6%63.7%11.55.1YOLOv8-S11.116874.6% 69.5% 74.9% 60.3% 72.0% 12.328.5YOLOv8-M25.8218 75.9% 64.4%72.2%57.1%69.6%13.978.7YOLOv8-X68.126870.6%68.7%72.0%56.4%69.6%34.3257.5YOLOv9-T2.048669.6%59.3%65.7%52.4%64.0%27.17.6YOLOv10-N2.322967.4%61.9%67.7%52.1%64.5%8.96.5Rice-YOLO (ours)2.8172 78.1% 70.9% 78.1% 62.9% 74.3% 11.27.2Significant values are in bold and italics. Performance Comparison of Object Detection Algorithms on the IPR16 dataset. Significant values are in bold and italics. The model comparison reveals that YOLOv3-Tiny, benefiting from its streamlined structure, had the fastest inference speed. In contrast, although YOLOv5-N and YOLOv5-N-BiFPN have fewer parameters and lower computational complexity, their more complex structures resulted in slower inference speeds than that of YOLOv3-Tiny. YOLOv9 exhibits slower inference speeds, while YOLOv10 demonstrates poor detection performance. In contrast, YOLOv8-N strikes a balance between model size and inference speed while achieving higher detection accuracy. A comparison of Rice-YOLO with classic models reveals that it offers the best detection accuracy and relatively fast inference speed. Overall, Rice-YOLO achieves a good balance among speed, accuracy, and computational complexity. We juxtaposed the detection results of select high-performing models with those of Rice-YOLO, as depicted in Fig. 12. Overall, other models exhibited more instances of missed detections and false-negatives. In contrast, Rice-YOLO showed improvements in this area, with fewer instances of missed pest objects and classification errors. Additionally, the predicted bounding boxes of Rice-YOLO more accurately matched the actual objects. Comparison of model detection results. Additionally, we utilized LayerCAM34 to visualize the detection layers (P3, P4, and P5) of different models, as depicted in Fig. 13. The visualizations of various models clearly reveal that some models exhibit severe dispersion of heatmaps, making it challenging to focus on actual objects. A scattered distribution of heatmaps indicates that the model struggles to effectively learn and recognize target features. Consequently, during the prediction phase, the model’s results often deviate significantly from reality. Conversely, concentrated heatmaps reflect the model’s focus on object features and indicate the centre positions of the predicted bounding boxes. In summary, across detection layers of varying scales, some models’ heatmaps deviate from actual targets, whereas Rice-YOLO’s heatmaps align more closely with the actual objects. Visualization of different scale detection layers. Ablation study of each function module within Rice-YOLO To assess the contribution of each improvement to Rice-YOLO, we conducted ablation experiments, and the results are presented in Table 7. The results of the ablation experiments, clearly show that different improvement modules have varying effects on various aspects of the Rice-YOLO model. The metrics obtained in the ablation experiments clearly indicate that each improvement made to the model is necessary, as they all have a positive effect on the final detection results. Table 7Ablation experiments of Rice-YOLO on IPR16.v8DBGAux DBGDSDS+DSHTParams (M)Layers P R mAP 50mAP 50:95F1Speed (ms)FLOPs (G)√3.008816871.6%68.7%73.1%57.8%70.1%11.68.10√√2.819816877.3%66.8%75.7%60.0%71.7% 10.7 7.13 √√√77.9% 69.5% 77.5% 62.4% 73.5%√√√√2.8322170 79.5% 69.4% 77.7% 62.3% 74.1% 11.3 7.15 √√√√2.8445172 79.7% 67.4%76.7%62.1%73.0% 11.2 7.17√√√√78.1% 70.9% 78.1% 62.9% 74.3% Ablation experiments of Rice-YOLO on IPR16. Compared with YOLOv8, in Rice-YOLO, the utilization of the DBG head resulted in a reduction of 6.28% in the number of model parameters and a decrease of 11.98% in the computational complexity, while increasing mAP50 by 2.6%, mAP50:95 by 2.2%, and F1 score by 1.6%. This finding indicates that replacing the original detection head with the DBG head improved the model’s inference capability and reduced its hardware consumption. The addition of Aux-DBG as a supervisory layer in the middle layers of the model network increased the mAP50 by 1.8%, the mAP50:95 by 2.4%, and the F1 score by 1.8% without adding any extra inference burden. Substituting DySample–hardtanh for the original upsampling module improved the model’s upsampling capability, resulting in a 0.6% increase in mAP50, a 0.5% increase in mAP50:95, and a 0.8% increase in the F1 score. Furthermore, to compare the effect of the offset suppression strategy between DySample–hardtanh and DySample+, we visualized different-scale upsampling layers, as shown in Fig. 14. The visualization results indicate that, in the task of rice pest detection, the more flexible DySample–hardtanh outperforms DySample+. Visualization of upsampling layers at different scales. Conclusions In this study, we propose an accurate and fast rice pest detection method called Rice-YOLO to address the complexity of rice pest backgrounds, large interclass variations, and small interclass differences. Rice-YOLO achieves end-to-end efficient detection of rice pests, striking a good balance among speed, accuracy, and computational complexity. This method builds upon YOLOv8 by incorporating an efficient detection head that is tailored to the complex characteristics of pests and integrating deep supervision layers into the network, along with utilizing improved dynamic upsampling modules. Currently, crop pest datasets are scarce. Data augmentation can be employed to expand data samples, and image generation techniques can be utilized to increase data richness. Owing to the inherent similarities among different crop pests, future research will explore training models based on multiple crop pest datasets and subsequently transferring the trained models to specific crop pest datasets for fine-tuning. In the future, Rice-YOLO can be integrated with agricultural smart devices to transform and upgrade intelligent greenhouses and smart farms by combining intelligent sensing systems and detection systems in agricultural greenhouses and crop growing areas. This advancement will contribute to the development of the agricultural economy. Acknowledgements This research was funded by the Natural Science Foundation of Fujian Province, China [Grant number 2021J05259], and the Open Project of Hunan Provincial Key Laboratory of Remote Sensing Monitoring of Ecological Environment in Dongting Lake Area, Grant number DTH Key Lab.2022-15. Author contributions Conceptualization and methodology, Y.Z. and W.Z.; software, formal analysis, investigation, resources, data curation, writing—original draft preparation, writing—review and editing and visualization, Y.Z.; validation and supervision, W.Z. and X.D.; project administration and funding acquisition, W.Z. Data availability The self-built dataset R2000 can be publicly available on https://github.com/awsomespark. Publicly available datasets IP102 were used in this study. IP102 can be found here: https://github.com/xpwu95/IP102. Additional supplements are available on request from zhengyongxmut@163.com. Declarations Competing interests The authors declare no competing interests. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. References Associated Data Data Availability Statement The self-built dataset R2000 can be publicly available on https://github.com/awsomespark. Publicly available datasets IP102 were used in this study. IP102 can be found here: https://github.com/xpwu95/IP102. Additional supplements are available on request from zhengyongxmut@163.com.