A rice pest detection method based on YOLOv11n and transfer learning

CN122551185APending Publication Date: 2026-08-11HEILONGJIANG BAYI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-04
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

但现有技术侧重静态图像中成虫的识别与分类且依赖于在受限环境下采集的标准化图像,在真实复杂的大田环境下检测精度较低

Benefits of technology

在本说明书提供的基于YOLOv11n和迁移学习的水稻虫害检测方法中,采用C2f_GhostConv模块替换主干网络中第6层和第8层的C3k2模块,C2f结构保留了丰富梯度流与多分支特征融合能力,相比原C3k2模块,在轻量化的同时不损失特征表达能力,GhostConv能够用廉价操作生成特征图,显著降低模型参数量与计算量,仅对主干第6层和第8层进行替换,实现轻量化与特征提取能力的精准平衡;改进的YOLOv11n模型的损失函数为MPDIoU损失函数,MPDIoU在传统IoU基础上进一步考虑边界框位置、形状、距离及角度差异,能够有效缓解水稻虫害目标小、姿态多变导致的框不准问题,提升检测框定位精度;利用在公开虫害数据集上预训练的YOLOv11n权重进行跨领域参数迁移,对改进型YOLOv11n模型进行初始化;在改进型YOLOv11n模型的前第一预设数量训练轮次中,冻结主干网络第0层至第6层的参数,在改进型YOLOv11n模型的后第一预设数量训练轮次中,解冻改进型YOLOv11n模型的所有参数,并对改进型YOLOv11n模型的参数进行微调,得到训练好的改进型YOLOv11n模型,分步训练策略兼顾特征保留与域适应,进一步挖掘模型在水稻田间场景下的检测潜力;通过训练好的改进型YOLOv11n模型对水稻虫害图像进行检测,得到虫害检测结果。该方法在模型轻量化的同时提升了水稻虫害的检测精度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551185A_ABST
    Figure CN122551185A_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting rice pests based on YOLOv11n and transfer learning, which relates to the field of smart agriculture technology. The method includes: an improvement method for the improved YOLOv11n model, which involves replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module; the loss function of the improved YOLOv11n model is the MPDIoU loss function; cross-domain parameter transfer is performed using YOLOv11n weights pre-trained on a public pest dataset to initialize the improved YOLOv11n model; in the first preset number of training epochs of the improved YOLOv11n model, the parameters of layers 0 to 6 of the backbone network are frozen; in the last preset number of training epochs of the improved YOLOv11n model, all parameters of the improved YOLOv11n model are unfrozen, and the parameters of the improved YOLOv11n model are fine-tuned to obtain a trained improved YOLOv11n model; and the trained improved YOLOv11n model is used to detect rice pest images to obtain pest detection results. This method improves the detection accuracy of rice pests while making the model lightweight.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart agriculture technology, and in particular to a method, apparatus, medium and equipment for detecting rice pests based on YOLOv11n and transfer learning. Background Technology

[0002] Rice pests and diseases are significant factors affecting rice yield. The long-term, extensive use of chemical pesticides for pest control has damaged the ecological environment and led to pesticide resistance in pests, increasing the costs of agricultural production and ecological restoration. Therefore, timely identification and effective control of pests are crucial for improving rice yield and quality. The core value of intelligent rice pest detection methods and systems lies in their ability to quickly and accurately identify various pest species that damage rice plants throughout their growth cycle. This capability is a key support for maintaining crop growth safety and ensuring a stable harvest. Pest infestations not only directly damage rice tissues and disrupt normal physiological processes, but also pose a risk of regional yield decline and even production failure. Therefore, timely and accurate assessment of pest species and their occurrence dynamics is a necessary prerequisite for implementing scientific control, reducing yield losses, and ensuring the quality and safety of agricultural products, and is of great significance for promoting sustainable agricultural development.

[0003] With the rapid development of artificial intelligence technology in the context of smart agriculture, rice pest and disease identification and detection technology based on deep learning algorithms has become a key link in ensuring the healthy growth of crops. However, existing technologies focus on the identification and classification of adult insects in static images and rely on standardized images collected in limited environments, resulting in low detection accuracy in real and complex field environments. Summary of the Invention

[0004] Therefore, it is necessary to provide a rice pest detection method based on YOLOv11n and transfer learning to address the aforementioned technical problems. This method improves the detection accuracy of rice pests while maintaining a lightweight model.

[0005] The following technical solution is adopted in this specification: This manual provides a method for detecting rice pests based on YOLOv11n and transfer learning, including: Multiple images of rice pests were collected in the field, and the pest type and location were labeled for each image to obtain a rice pest and disease dataset. Obtain the improved YOLOv11n model; the traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head; the improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module; the loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss; We initialize the improved YOLOv11n model by performing cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset. In the first preset number of training epochs of the improved YOLOv11n model, the parameters of layers 0 to 6 of the backbone network are frozen. In the last preset number of training epochs of the improved YOLOv11n model, all parameters of the improved YOLOv11n model are unfrozen, and the parameters of the improved YOLOv11n model are fine-tuned to obtain the trained improved YOLOv11n model. The improved YOLOv11n model was trained to detect rice pest images, and the pest detection results were obtained.

[0006] Optionally, the bounding box loss function of the improved YOLOv11n model is: ; ; ; ; in, The bounding box loss value for the improved YOLOv11n model. The bounding box regression loss function is... This represents the square of the Euclidean distance between the top-left and bottom-right vertices of the predicted bounding box. IOU represents the square of the Euclidean distance between the top-left and bottom-right vertices of the ground truth bounding box, and IOU represents the square of the predicted bounding box. pred and real frame gt The ratio of the area of ​​intersection to the area of ​​union. The minimum area of ​​a closed rectangle that covers both the actual and predicted bounding boxes of pests. The coordinates of the top-left corner of the pest prediction bounding box are: The coordinates are the bottom right corner of the pest prediction bounding box. The coordinates are the top-left corner of the actual bounding box of the pest. The coordinates are the lower right corner of the actual bounding box of the pest.

[0007] Optionally, the slide classification loss function of the improved YOLOv11n model is: ; in, The loss value for slide classification. For the first i The binary cross-entropy loss for each sample. For the sample The predicted score, N The total number of samples, For the first i The predicted probability of a sample. f Weighting function for Slide; The formula for calculating the binary cross-entropy loss is: ; in, For the first i Binary cross-entropy loss for each sample.

[0008] Optionally, the Slide weighting function is: ; in, Weighting function for Slide, The threshold parameter is for dynamic learning.

[0009] Optionally, the pest categories include rice stem borer, rice stem borer, rice leaf roller, rice green bug, and rice bark bug; The life stages of the rice stem borer include adult, larva, and pupa; the life stages of the rice stem borer include egg, larva, adult, and pupa; the life stages of the rice stem borer include larva, adult, and pupa; the life stages of the rice stem borer include larva, adult, and pupa; the life stages of the rice green bug include adult; and the life stages of the mottled bug include nymph.

[0010] Optionally, the C2f_GhostConv module includes an input layer, a first convolutional layer, a second convolutional layer, a concatenation layer, and an output layer.

[0011] Optionally, the method further includes: After collecting multiple images of rice pests in a field environment, the open-source computer vision library OpenCV was used to perform data augmentation on the multiple rice pest images to obtain an augmented dataset. The data augmentation included rotation, cropping, hue, saturation, and brightness HSV data augmentation, and Mosaic data augmentation. Each image in the augmented dataset is resized to a preset size using the LetterBox method.

[0012] This specification provides a rice pest detection device based on YOLOv11n and transfer learning, comprising: The data acquisition module is used to acquire multiple images of rice pests in the field environment, and to label the pest type and location of each image to obtain a rice pest and disease dataset. The acquisition module is used to acquire the improved YOLOv11n model. The traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head. The improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module. The loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss. The initialization module is used to perform cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset, and to initialize the improved YOLOv11n model. The training module is used to freeze the parameters of layers 0 to 6 of the backbone network in the first preset number of training epochs of the improved YOLOv11n model, unfreeze all the parameters of the improved YOLOv11n model in the last preset number of training epochs of the improved YOLOv11n model, and fine-tune the parameters of the improved YOLOv11n model to obtain the trained improved YOLOv11n model. The detection module is used to detect rice pest images using a trained improved YOLOv11n model and obtain pest detection results.

[0013] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described rice pest detection method based on YOLOv11n and transfer learning.

[0014] This specification provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the above-described method for detecting rice pests based on YOLOv11n and transfer learning.

[0015] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects: In the rice pest detection method based on YOLOv11n and transfer learning provided in this specification, the C2f_GhostConv module replaces the C3k2 modules in layers 6 and 8 of the backbone network. The C2f structure retains rich gradient flow and multi-branch feature fusion capabilities. Compared with the original C3k2 module, it achieves lightweighting without sacrificing feature representation capabilities. GhostConv can generate feature maps with inexpensive operations, significantly reducing the number of model parameters and computational cost. Only layers 6 and 8 of the backbone are replaced, achieving a precise balance between lightweighting and feature extraction capabilities. The improved YOLOv11n model uses the MPDIoU loss function. MPDIoU further considers the differences in bounding box position, shape, distance, and angle on the basis of traditional IoU, which can effectively alleviate the problem of inaccurate bounding boxes caused by the small size and varied poses of rice pest targets. This method improves the accuracy of detection bounding box localization by using YOLOv11n weights pre-trained on a public pest dataset for cross-domain parameter transfer to initialize an improved YOLOv11n model. In the first predetermined number of training epochs of the improved YOLOv11n model, the parameters of layers 0 to 6 of the backbone network are frozen. In the subsequent predetermined number of training epochs, all parameters of the improved YOLOv11n model are unfrozen, and the parameters are fine-tuned to obtain a trained improved YOLOv11n model. This step-by-step training strategy balances feature preservation and domain adaptation, further exploring the model's detection potential in rice paddy scenarios. The trained improved YOLOv11n model is then used to detect rice pest images, yielding pest detection results. This method improves the detection accuracy of rice pests while maintaining a lightweight model. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0017] Figure 1 This document provides a schematic flowchart of a rice pest detection method based on YOLOv11n and transfer learning. Figure 2 The rice pest diagram provided by this invention; Figure 3 A schematic diagram of Mosaic data enhancement provided by the present invention; Figure 4 Comparison chart of different LetterBox processing effects provided by the present invention; Figure 5 A statistical chart of the Ricepest15 dataset provided by this invention; Figure 6 A schematic diagram of the improved Ghost-YOLOv11n model provided by this invention; Figure 7 The traditional convolutional and GhostConv network structure diagrams provided by this invention; Figure 8 This is a schematic diagram illustrating the transfer learning of rice pests provided by the present invention. Figure 9 This is a schematic diagram of the slide classification loss provided by the present invention; Figure 10 This is a framework diagram of the pest detection method provided by the present invention; Figure 11 A schematic diagram illustrating the changes in loss, accuracy, and recall during the model training process provided by this invention; Figure 12 A schematic diagram illustrating the identification results of targets at different scales provided by this invention; Figure 13 This is a schematic diagram of the rice pest detection confusion matrix provided by the present invention; Figure 14 This is a schematic diagram illustrating the recognition accuracy provided by the present invention; Figure 15 This is a schematic diagram of the identification recall rate provided by the present invention; Figure 16 A schematic diagram of the intelligent rice pest detection system provided by the present invention; Figure 17 This specification provides a schematic diagram of a rice pest detection device based on YOLOv11n and transfer learning. Figure 18 This document provides a schematic diagram of a computer device for implementing a rice pest detection method based on YOLOv11n and transfer learning. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.

[0019] Devices such as desktop computers, servers, and laptops are capable of executing the solutions described in this manual. For ease of explanation, the following description will focus on servers as the primary execution method.

[0020] Rice pest detection and identification systems have been widely applied in various fields, including real-time farmland monitoring, agricultural pest and disease early warning systems, precision agriculture management platforms, and agricultural consulting services. For example, by integrating high-definition cameras and multispectral sensors, mounted on autonomous inspection robots and fixed poles, 24 / 7 uninterrupted monitoring of the field environment is achieved. By constructing a rice pest and disease early warning platform, combining monitoring point image data, meteorological data, and phenological models, the system can promptly report current pest conditions and predict the occurrence and spread paths of pests and diseases in the next 7-14 days, generating regional risk level maps. Furthermore, agricultural service apps, powered by mobile internet, allow farmers to upload photos of suspicious insect behaviors or damage found in the field using their mobile phones. The system returns identification results, pest behavior descriptions, damage characteristics, and current control suggestions within 3-5 seconds, significantly lowering the barrier to agricultural technology consultation.

[0021] For a long time, rice pest monitoring has mainly relied on manual field inspections and experience-based judgment by agricultural personnel. This approach is time-consuming, labor-intensive, inefficient, and highly subjective, making it difficult to adapt to large-scale, real-time early warning systems. Especially during outbreaks, the lag in manual inspections often leads to delayed control measures, exacerbating economic losses and pesticide overuse. Currently, image recognition and machine learning methods are widely used in pest identification, such as K-means clustering, mean-shift algorithm, Support Vector Machine (SVM) classifiers, and Otsu's method, all of which are widely applied in crop disease image recognition and detection. Existing machine learning-based pest identification methods mainly rely on pattern classification of static images. These methods generally face an inherent contradiction in algorithm design: the model's ability to discriminate target features and its actual recognition efficiency are often difficult to achieve simultaneously. Many algorithms extract features with limited discriminative power and convergent representation methods, resulting in limited comprehensive recognition performance and generalization ability of the same model when facing pests and diseases with significant differences in visual attributes such as morphology, color, and texture.

[0022] Current technologies focus on the identification and classification of adult insects in static images, typically relying on standardized images collected under constrained environments. However, in the complex real-world field environment, challenges arise such as uneven lighting, cluttered backgrounds, significant variations in insect size and morphology, and substantial differences in insect life stages (e.g., eggs, larvae, adults). This results in insufficient generalization ability, robustness, and detection accuracy for most deep learning algorithms in real-world scenarios, particularly in identifying critical pest life stages like young larvae. Furthermore, in agricultural image analysis, various target detection architectures are applied to pest and disease identification. Typical two-stage models (such as Faster R-CNN) excel in localization accuracy but suffer from high computational complexity, making them unsuitable for real-time field processing. Among single-stage models, the Single Shot MultiBox Detector (SSD) achieves a good balance between speed and accuracy but has limited sensitivity to small targets. While the Transformer-based DETR avoids manually designing anchor boxes, it relies heavily on computational resources, resulting in a high deployment threshold. Currently, the YOLO series, which balances efficiency and accuracy, has become the mainstream choice for real-time field monitoring due to its end-to-end lightweight design. However, in specific rice pest and disease scenarios, existing YOLO models still suffer from high rates of missed detection and false detection for targets such as early lesions with indistinct features and morphologically variable young larvae. Therefore, a new solution is needed to address these issues.

[0023] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0024] Figure 1 This is a flowchart illustrating a rice pest detection method based on YOLOv11n and transfer learning, as described in this specification. The method includes the following steps: S101: Collect multiple images of rice pests in a field environment, label the pest type and location for each image, and obtain a rice pest and disease dataset.

[0025] Images of rice pests in the field were collected, a pest dataset was constructed, and data augmentation and preprocessing were performed. The processed image dataset and label data were then divided into training set, validation set and test set according to a preset ratio (8:1:1).

[0026] In an exemplary embodiment, the pest categories include rice stem borers, rice stem borers, rice bark borers, rice green stink bugs, and rice burr bugs; the life stages of rice stem borers include adults, larvae, and pupae; the life stages of rice stem borers include eggs, larvae, adults, and pupae; the life stages of rice bark borers include larvae, adults, and pupae; the life stages of rice bark borers include larvae, adults, and pupae; the life stages of rice green stink bugs include adults; and the life stages of rice burr bugs include nymphs.

[0027] Specifically, this invention uses color images of healthy and insect-infested rice as research objects, employing a combination of field photography and online acquisition to collect images of rice pests. During field photography, the camera was positioned 10cm-18cm from the target to ensure the rice plants were centered in the frame. Camera focus, aperture, and white balance were all set automatically. Rice pest images were collected daily from 15:00 to 16:00, with a resolution of 2,000×1,325 pixels. A total of 1712 original images of rice pests and diseases were collected, covering both healthy and insect-infested plants, and the collection area included various lighting conditions and complex backgrounds. Furthermore, based on the primary color atlas of "Diagnosis and Control of Rice Diseases, Pests, and Weeds," the image data were labeled and corrected to construct an original rice pest and disease dataset. This dataset contains detailed disease categories and location annotations, covering 15 target pests, including rice stem borer (adults, larvae, and pupae), rice stem borer (eggs, larvae, adults, and pupae), rice stem borer (larvae, adults, and pupae), rice green stink bug (adults), and rice bark stink bug (nymphs).

[0028] In an exemplary embodiment, the method further includes: after acquiring multiple images of rice pests in a field environment, performing data augmentation on the multiple images of rice pests using the open-source computer vision library OpenCV to obtain an augmented dataset; the data augmentation includes rotation, cropping, hue / saturation / brightness (HSV) and Mosaic data augmentation; and adjusting each image in the augmented dataset to a preset size using the LetterBox method.

[0029] Specifically, in the intelligent detection system for rice pests, this invention constructs a high-quality image dataset focusing on 6 major pests and 15 life stages. Pests are categorized based on their preferred parts of the rice plant. One category is common pests, primarily feeding on leaves, such as the rice leaf roller. These pests typically damage rice throughout the year, with larvae spinning silk to string leaves together into a husk, feeding on the upper epidermis or the inner sheath of young leaves within the husk. This results in incomplete leaves, sometimes leaving only the midrib, negatively impacting crop growth. In addition, there are other leaf-eating pests that do not form husks, such as the rice stem borer, which mainly appears on the rice stem. These are mostly boring pests, such as the rice stem borer, rice caltrop, and rice bark borer, damaging the tillering stage, causing dead heart, dead panicles, and insect-induced diseases. They typically increase their appetite during the third and fourth instars to adult stages, consuming leaves and exhibiting a certain degree of aggregation. A rice pest dataset, Ricepest15, was constructed through on-site photography and online data collection. The image data was labeled and corrected according to the original color atlas of "Diagnosis and Control of Rice Diseases, Pests and Weeds". Figure 2 The rice pest diagram provided by this invention.

[0030] Data augmentation is an effective method to increase the size of a dataset, which helps improve the versatility of the trained model. Based on the number of images of different types of pests, OpenCV was used to perform data augmentation operations such as rotation (120°), cropping, and HSV to construct a rice pest identification dataset.

[0031] Image rotation is analogous to the rotation of a point in the XOY coordinate plane. Specifically, point P rotates counterclockwise around the origin O along the XOY direction by an angle. Finally, it is located at the new position of point Q. Assume the coordinates of point P in the X, O, Y coordinate system are ( x , y The coordinates of point Q are ( ), If the distance between point P and the origin O is D, then the angle by which point P rotates around the origin is... It can be described by formulas (1) and (2), which are:

[0032] (1); (2); in,( , Let be the rectangular coordinates of point Q after point P is rotated. x , y Let P be the coordinates of point P in the X, O, Y coordinate system. Let P be the initial angle (i.e., the angle between P and P). x (Angle in the positive direction of the axis) The rotation angle is (counterclockwise is positive). Let P be the distance from point P to the origin O.

[0033] Shearing is a geometric transformation involving scaling the directed distance of each point in a graphic to a line parallel to a specific direction according to a predetermined scale. This operation is typically performed in the X or Y direction. A shearing transformation along the Y-axis can be achieved using the following formulas (3)–(4), where formulas (3) and (4) are:

[0034] (3); (4); in, x Let x be the x-coordinate of the point before the transformation. y The ordinate of the point before the transformation. The x-coordinate of the transformed point. , The shear angle, its sine value ( ) and cosine value ( This defines the proportion or intensity of shear.

[0035] HSV (Hue, Saturation, Brightness) is based on a hexagonal pyramid model and is commonly used to generate 8-bit and 16-bit images. In these images, the red (R), green (G), and blue (B) channels are first converted to floating-point format and then scaled to the range of 0 to 1. This transformation is performed using formulas (5) and (6), which are:

[0036] (5); in, Lightness represents the brightness or darkness of a color, and its value is determined by the largest value among the three color channels: red (R), green (G), and blue (B). The '+' operator is an assignment operator, indicating that the value on the right is assigned to the variable on the left. These are the normalized values ​​for the red, green, and blue channels, ranging from 0 to 1.

[0037] Hue H The calculation formula is formula (6): (6); in, Hue represents the basic hue of a color (such as red, yellow, green, etc.), and its value corresponds to an angle on the color wheel, usually ranging from 0° to 360° (sometimes normalized to 0–1).

[0038] Figure 3 This is a schematic diagram of Mosaic data enhancement provided by the present invention, such as... Figure 3 As shown, the Mosaic data augmentation method randomly selects four training images as input and expands the data using a data board of specified dimensions that can hold four images. Augmentation operations are applied to the input images using flipping (left-right and top-bottom flipping), translation, scaling, and shearing. The augmented images and bounding boxes are then resized using the LetterBox method and placed onto the data board sequentially from top left, top right, bottom left, and bottom right corners, forming a new image containing the bounding boxes. This method significantly enriches the background of the detected objects and simultaneously calculates the data from all four images during standardization, effectively improving the model's performance and robustness.

[0039] The LetterBox operation is an image preprocessing method primarily used to adjust the size of an image while maintaining its original aspect ratio. Figure 4 The images show a comparison of different LetterBox processing effects provided by this invention. To reduce information loss and geometric distortion, this invention uses adaptive scaling technology, as shown in the following figures. Figure 4As shown, the specific processing steps are as follows: First, select the smaller value between the target size and the aspect ratio of the original image as the uniform scaling ratio; second, calculate the scaled image size based on this ratio; finally, adopt the minimum fill strategy, and determine the double-sided symmetrical gray fill amount by calculating the fill width modulo 32, so as to minimize the fill area while meeting the requirements of subsequent processing, thereby reducing the introduced noise and improving processing efficiency.

[0040] After data augmentation and preprocessing, this system obtained 6844 insect pest images and constructed the Ricepest15 dataset to analyze the distribution of data volume, category, and target bounding boxes. Figure 5 This is a statistical chart of the Ricepest15 dataset provided by the present invention. Figure 5 Figure (a) shows the distribution of the original data volume, bounding box distribution, bounding box center point distribution, and image size distribution before augmentation; Figure 5 In Figure (b) x shaft and y The axes represent x and y coordinate, y The axes represent the height and width of the target. The targets are mainly concentrated near the center of the image, and the color intensity reflects the correlation between different targets.

[0041] S102: Obtain the improved YOLOv11n model; the traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head; the improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module; the loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss.

[0042] The YOLOv11n model is improved to construct the Ghost-YOLOv11n model. The improvements include: replacing the original C3k2 with the lightweight C2f_GhostConv module, and using the YOLOv11n baseline model to achieve cross-domain parameter transfer and fine-tuning; replacing the original cross-entropy and non-maximum suppression (NMS) loss functions with Slide and MPDIoU.

[0043] Figure 6 A schematic diagram of the improved Ghost-YOLOv11n model provided by this invention is shown below. Figure 6As shown, the entire network adopts an end-to-end detection framework, mainly composed of three parts: the backbone network, the feature fusion network, and the head. Due to the characteristics of rice pests, such as strong feature similarity, large scale variation, varying target aggregation, and the influence of light and shadow in the field environment, the detection accuracy and recognition accuracy are low, and there are problems of missed detections and false detections. To this end, this invention improves upon the original YOLOv11n, mainly by: using YOLO11n.pt as the baseline object detection model in the backbone network for model parameter transfer, freezing the model parameters of the first six layers, and training starting from the seventh layer; replacing the traditional (YOLOv8 and YOLOv5) C3K2 structure with the C2f_GhostConv module, and using a more efficient and parameter-lightweight convolutional computation strategy to achieve feature partitioning, maintaining the efficiency of feature representation and information flow; and introducing a C2PSA module after the SPPF module to further enhance feature extraction capabilities using an attention mechanism; the neck network adopts the PANet bidirectional path to enhance the fusion capability of shallow and deep features; and to further improve classification and localization accuracy, replacing the original cross-entropy and non-maximum suppression loss with Slide and MPDIoU loss functions.

[0044] The YOLOv11n backbone network uses a large number of convolutional modules to extract deeper features, but the numerous 1×1 convolutional layers consume significant amounts of memory and parameters. Furthermore, the intermediate feature maps computed by the Convolutional Neural Network (CNN) contain substantial redundancy. Due to limited memory and computational resources, deploying CNNs on embedded devices is extremely difficult. Therefore, this invention replaces the ordinary convolutional modules in the traditional YOLOv11n backbone network with GhostConv modules, applying a series of low-cost linear transformations to generate numerous ghost feature maps. These feature maps can fully reveal the information behind the intrinsic features, and the Ghost modules are plug-and-play.

[0045] Figure 7 The traditional convolutional and GhostConv network architecture diagrams provided by this invention are as follows: Figure 7 As shown, traditional convolution operations take multi-channel input feature maps as their object and directly calculate and generate output features with a specified number of channels. The number of parameters is determined by the number of input channels, the number of output channels, and the kernel size. All output channels rely on independent kernel parameters for feature extraction, resulting in high computational and storage costs. Ghost Convolution, on the other hand, adopts a lightweight feature generation paradigm: it first generates basic original feature maps using a small number of convolution kernels, and then performs a low-cost linear transformation on each original feature map using depthwise separable convolution to generate "ghost feature maps" (…). Finally, the original features and ghost features are concatenated to obtain output features with the same dimensions as standard convolution. Under the condition of the same number of output channels, if each original feature map can generate s ghost features, then the number of parameters of GhostConv is about 1 / s of that of standard convolution. While maintaining the basic stability of model recognition accuracy, it can significantly compress the number of model parameters and computational complexity, making it more suitable for resource-constrained edge computing and lightweight deployment scenarios.

[0046] To adapt to limited memory and computing resources, YOLOv11n replaces the original C3K2 structure with the C2f_GhostConv module. This module employs a dual-path design to balance feature representation capability and computational efficiency: one path uses conventional 3×3 convolutions to preserve spatial hierarchical information; the other path introduces depthwise separable convolutions, generating additional features through lightweight linear transformations, thereby significantly reducing the number of parameters while maintaining representational power. Its working mechanism can be summarized as follows:

[0047] First, the input data is represented as X ∈ c × h × w ,in, c Input the number of channels. h and w These represent the height and width of the input data, respectively, and generate... n The operation of any convolutional layer of a feature map can be expressed as formula (7): (7); in, Represents convolution operation. For bias terms, For having Output feature map of each channel This represents the convolution filter of this layer. These represent the width and height of the output data, respectively. Convolutional filter The size of the core.

[0048] In YOLOv11n, when Bottleneck is used within the C3K2 network, C3K2 degenerates into a C2f module. Since C2f uses standard convolution, and standard convolutional layers typically contain a large amount of redundant information in the output feature map process, this invention improves the C3K2 modules in layers 6 and 8 by using the more lightweight C2f_GhostConv. The approach is to assume that the output feature map is a mirror image of a small number of intrinsic feature maps after some simple transformations. These intrinsic feature maps are typically small in size and are generated by standard convolutional filters. Standard convolution is used to generate... Each inherent feature map The calculation formula is formula (8):

[0049] (8); in, , In order to simplify the model parameters, the present invention omits the bias term.

[0050] To ensure that the generated feature map is spatially identical to the output of standard convolution, the hyperparameters used—including filter size, stride, and padding strategy—are kept exactly the same as those used in standard convolution. The core of this method lies in the initial acquisition of the essential feature map... For each feature in the equation, apply a set of computationally inexpensive linear transformations to derive the following: One "ghost" characteristic. Its specific calculation process is formula (9):

[0051] (9); in, yes The Middle An inherent feature map, It is used to generate the first Ghost characteristics The Linear operations (except the last one) and (linear kernel), denoted as The last one It is an identity mapping used to preserve the inherent feature map.

[0052] When there exists an identity mapping and For a linear operation, the theoretical speedup of using Ghostconv compared to standard convolution is given by formula (10): (10); in, The magnitude and Their magnitudes are similar, and .

[0053] The compression ratio is calculated using formula (11): (11); Therefore, compared to the traditional standard convolutional module (C3K2), C2f_GhostConv significantly reduces the number of parameters. Firstly, it is easier to configure for mobile devices. Secondly, C2f_GhostConv's inference speed is superior to the C3K2 module built on standard convolutional parallelism, improving speed by approximately [percentage missing]. times.

[0054] S103: Initialize the improved YOLOv11n model by performing cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset.

[0055] To address the challenges of model training and insufficient generalization ability caused by the scarcity of labeled image data for rice pests, this invention introduces a transfer learning strategy to optimize the training process of the Ghost-YOLOv11n model. Transfer learning effectively overcomes the dependence on large-scale labeled data by transferring knowledge learned in one domain (source domain) to another related but data-limited domain (target domain), thus improving the model's convergence speed and performance ceiling on the target task. Its core advantage lies in the fact that, leveraging model weights pre-trained on large general datasets, the network already possesses the basic ability to extract general visual features. Therefore, in small-sample target scenarios, only targeted fine-tuning is needed to obtain robust and discriminative feature representations.

[0056] Specifically, this invention designs a two-stage transfer fine-tuning scheme. First, a YOLOv11n model pre-trained on the large public pest dataset IP102 is selected as the knowledge source. Its weights are then transferred to the structurally improved Ghost-YOLOv11n model to initialize the network parameters. Figure 8 This is a schematic diagram of the transfer learning of rice pests provided by the present invention, such as... Figure 8 As shown, the transfer learning process systematically achieves domain adaptation from general pest features (IP102 dataset) to specific rice pest features (target dataset). Through a freeze-thaw phased training strategy, the stability of the backbone feature extraction network is ensured, while also providing the model with sufficient flexibility to adjust to the target data. This significantly improves model training efficiency and final detection accuracy under limited labeled data conditions.

[0057] S104: In the first preset number of training epochs of the improved YOLOv11n model, freeze the parameters of layers 0 to 6 of the backbone network. In the last preset number of training epochs of the improved YOLOv11n model, unfreeze all the parameters of the improved YOLOv11n model and fine-tune the parameters of the improved YOLOv11n model to obtain the trained improved YOLOv11n model.

[0058] The training set is input into the Ghost-YOLOv11n model for iterative training. The optimal model weights are obtained through fine-tuning, and the trained Ghost-YOLOv11n model is obtained.

[0059] To stabilize the network and preserve transferred general features during the initial training phase, the parameters of the backbone network (layers 0 to 6) are frozen in the early stages of training (e.g., the first 50 epochs), and learning is performed only on subsequent network layers. A high initial learning rate (e.g., 1×10³) is set at this stage to accelerate the network's adaptation to new tasks. In the later stages of training (e.g., the last 50 epochs), all network layers are unfrozen for end-to-end fine-tuning, using a lower learning rate (e.g., 1×10) to smooth optimization and avoid destroying learned effective features. Throughout the training process, the batch size is set to 16, the momentum (0.9) optimizer is used, and the confidence threshold and non-maximum suppression threshold are set to 0.5 and 0.3, respectively. The total number of training epochs is 100.

[0060] In the YOLOv11 object detection model, the bounding box regression task uses a loss function based on the Intersection over Union (IoU), while the classification task uses the Binary Cross-Entropy Loss (BCE Loss). While IoU, as a metric for measuring the overlap between predicted and ground truth bounding boxes, can intuitively reflect detection performance, it has inherent limitations: when two boxes have no intersection, the IoU value is zero, making it impossible to further measure the relative distance between the boxes; furthermore, if the predicted and ground truth bounding boxes have the same size but different relative positional offsets, the IoU may yield the same value, making it difficult for IoUloss to distinguish subtle differences in spatial alignment, thus affecting the model's ability to optimize bounding box localization accuracy. To address the above issues, some methods, such as Generalized Intersection over Union (GIoU), Distance Intersection over Union (DIoU), Complete Intersection over Union (CIoU), Enhanced Intersection over Union (EIoU), and Spatial Intersection over Union (SIoU), continuously update the IoU by adding different constraints to achieve better detection.

[0061] This invention employs the Minimum Point Distance Intersection over Union (MPDIoU) bounding box loss function. By minimizing the distance between the top left and bottom right points of the predicted bounding box and the ground truth bounding box, this design aims to address the limitations of existing IoU-based loss functions (such as IoU Loss, GIoU Loss, etc.) in specific situations: when the predicted box and the target box have the same aspect ratio, but their absolute width and height differ significantly, traditional loss functions may lead to model convergence difficulties or insufficient optimization due to gradient vanishing or insufficient sensitivity. MPDIoU enhances the model's regression ability and convergence stability in such scenarios by explicitly optimizing vertex distances. The MPDIoU calculation formulas are formulas (12) to (15):

[0062] (12); (13); (14); (15); in, The bounding box loss value for the improved YOLOv11n model. The bounding box regression loss function is... This represents the square of the Euclidean distance between the top-left and bottom-right vertices of the predicted bounding box. IOU represents the square of the Euclidean distance between the top-left and bottom-right vertices of the ground truth bounding box, and IOU represents the square of the predicted bounding box. pred and real frame gt The ratio of the area of ​​intersection to the area of ​​union. The minimum area of ​​a closed rectangle that covers both the actual and predicted bounding boxes of pests. The coordinates of the top-left corner of the pest prediction bounding box are: The coordinates are the bottom right corner of the pest prediction bounding box. The coordinates are the top-left corner of the actual bounding box of the pest. The coordinates are the lower right corner of the actual bounding box of the pest.

[0063] The Slide classification loss function of the improved YOLOv11n model is given by formula (16): (16); in, The loss value for slide classification. For the first i The binary cross-entropy loss for each sample. For the sample The predicted score,N The total number of samples, For the first i The predicted probability of a sample. f Weighting function for Slide.

[0064] The formula for calculating the binary cross-entropy loss is formula (17): (17); in, For the first i Binary cross-entropy loss for each sample.

[0065] The Slide weighting function is given by formula (18): (18); in, Weighting function for Slide, The threshold parameter is for dynamic learning.

[0066] The Slide weighting function is used to adjust the loss weights based on the sample location. The positive and negative sample threshold parameters (boundary values) are used for adaptive learning; the model learns these parameters dynamically during training. The predicted score for a sample is usually the classification score output by the model or the probability value after processing by the activation function (such as the confidence score of belonging to the positive class).

[0067] Slide Loss adaptively learns the threshold parameters for positive and negative samples. μ .exist μ Setting higher weights for nearby samples increases the relative loss of hard-to-classify samples, thus drawing more attention to these samples. Figure 9 This is a schematic diagram of the slide classification loss provided by the present invention, such as... Figure 9 As shown, this invention uses the weighting function Slide to emphasize samples at the boundary.

[0068] S105: The rice pest images are detected using a trained improved YOLOv11n model to obtain pest detection results.

[0069] The trained Ghost-YOLOv11n model was used to detect rice pest images to be identified.

[0070] In one exemplary embodiment, Figure 10 A framework diagram of the pest detection method provided by the present invention is shown below. Figure 10As shown, (1) Dataset construction and preprocessing: Rice pest images were collected in natural field environments, manually labeled, and data augmentation was performed. The processed dataset was uniformly scaled using LetterBox and then randomly divided into training, validation, and test sets in a ratio of 8:1:1; (2) Model improvement and transfer learning design: Based on the YOLOv11n architecture, the Ghost-YOLOv11n model was constructed by introducing a lightweight structure. The specific improvement method is: the C3K2 modules in layers 6 and 8 of the original network were replaced with the lightweight C2f_GhostConv feature extraction component. Based on this, cross-domain parameter transfer is performed using YOLOv11n weights pre-trained on the public pest dataset (IP102), and fine-tuning is used to adapt to the pest detection task; (3) Model training and optimization: The training set is input into the Ghost-YOLOv11n model for iterative training, the hyperparameters are dynamically adjusted, and the performance changes are monitored through the validation set until the model converges and the optimal weights are obtained, thus obtaining the final trained detection model; (4) Pest image detection application: The trained Ghost-YOLOv11n model is used to perform forward inference on the rice field images to be tested, so as to realize the automatic identification and localization of pest targets.

[0071] In one exemplary embodiment, the hardware environment of the experiment is shown in Table 1.

[0072] Table 1 Experimental Environment The training parameters of the network model are shown in Table 2.

[0073] Table 2 Network training parameters In the intelligent detection system for rice diseases, evaluating the performance of the Ghost-YOLOv11n model is crucial. To comprehensively measure the model's detection capability under complex field environments and varying light conditions, this invention uses accuracy (p), recall, and mean precision as evaluation indicators to analyze and evaluate the model's performance. Accuracy represents the proportion of correctly predicted detection boxes to the total number of detection boxes. mAP is obtained by calculating the mean average precision (AP) for all categories. The mAP calculation method is formula (19):

[0074] (19); Where mAP is the mean precision. Represents the total number of all categories. Representing the The average accuracy across all categories. When the value is 1. equal .

[0075] Recall is a key indicator for evaluating model performance. It quantitatively reflects the proportion of true defects correctly identified by the model out of all true defects. The recall rate is calculated using formula (20): (20); in, For recall, TP (True Positive) is the number of images that correctly predict pests, FP (False Positive) is the number of negative samples that are predicted as true, and FN (False Negative) is the number of real pests that are missed by the model or misclassified as false samples.

[0076] Compared to other metrics, high recall directly reflects the false negative rate of the detection system. In the scenario of early warning and control of early larval pests in the field, minimizing false negatives and ensuring that potential threats are detected in a timely manner is the core manifestation of the model's practical value.

[0077] The value is obtained by integrating the PR (Precision-Recall) curve. This refers to the calculation when the IoU threshold is 0.5. value, The value is calculated by using 10 IoU thresholds. Values, and for 10 The mean value is obtained. The model's detection capabilities were evaluated more comprehensively.

[0078] The formula for calculating accuracy is formula (21): (twenty one); in, For accuracy.

[0079] No. The formula for calculating the average accuracy of a class is formula (22): (twenty two); in, For the first i Precision of a class. For the first i Class recall Indicates the first i The precision-recall function of a class is known as the PR curve.

[0080] The calculation formula is formula (23): (twenty three); in, The mean accuracy (mAP) is calculated by taking the arithmetic mean of 10 different IoU thresholds from 0.5 to 0.95 (with a step size of 0.05). This metric evaluates the model's overall detection capability based on multiple overlap requirements. This represents the average precision when the IoU threshold is 0.5. This represents the average precision when the IoU threshold is 0.55.

[0081] Figure 11 This is a schematic diagram illustrating the changes in loss, accuracy, and recall during the model training process provided by the present invention. It shows the loss during batch training on rice pest images against a complex field background, as illustrated in the diagram. Figure 11 As shown, as the model is continuously trained, the box_loss (boundary loss), cls_loss (classification loss), and dfl_loss (distribution loss) of the training and validation sets continuously decrease and gradually stabilize. The optimal model's losses are 0.3735, 0.6464, and 1.04158, respectively.

[0082] Based on the Ghost-YOLOv11n detection model, the Ricepest15 dataset was analyzed. The recall rate reached 95.2%, and the accuracy rate was 94.7%. To verify the effectiveness of the proposed method, a comprehensive performance comparison analysis was conducted on the test datasets of three models: YOLOv11, YOLOv8, and Ghost-YOLOv11n. The results are shown in Table 3.

[0083] Table 3 Comparison of performance evaluation indicators for different models The experimental results in Table 3 show that after introducing transfer learning, Ghost-YOLOv11n achieved an F1 score of 93.2%, precision of 91.7%, and recall of 94.7%, representing a 20.3% improvement in F1 score and a 30.8% improvement in recall compared to the original YOLOv11n. Even under the same architecture, the version without transfer learning achieved an F1 score of only 69.8%, indicating that transfer learning brought a performance gain of 23.4 percentage points. Among the benchmark models, YOLOv8 had the highest F1 score (77.7%) and recall (70.6%), while YOLOv6 and YOLOv11n performed similarly, with F1 score differences within 1.7 percentage points. These results demonstrate that the performance improvement effect of transfer learning far outweighs the structural differences between different benchmark models.

[0084] Comparing the parameters of each model yields the results shown in Table 4. The comparative analysis of model complexity metrics listed in Table 4 reveals significant differences in the number of parameters, gradients, and computational cost (GFLOPs) among the various detection models involved in this invention. YOLOv6, as the most structurally complex model among the baseline models, has a parameter count of 4.24 × 10⁻⁶. The computational cost is 8.4 GFLOPs; YOLOv8, through structural optimization, reduces the number of parameters to 3.01 × 10⁻⁶. The computational load was reduced to 7.2 GFLOPs, a decrease of 28.9% and 14.3%, respectively. The further lightweight design of YOLOv11n resulted in a parameter count of 2.59 × 10⁻⁶. The computational cost is 6.4 GFLOPs, which is 14.0% and 11.1% lower than YOLOv8, respectively.

[0085] Table 4 Comparison of different model parameters Figure 12 This is a schematic diagram illustrating the recognition results of targets at different scales provided by the present invention, such as... Figure 12 As shown, compared with YOLOv6 and YOLOv8, Ghost-YOLOv11n has significantly improved accuracy, recall and mean precision, especially in the detection of small targets and occluded pests.

[0086] Figure 13 This is a schematic diagram of the rice pest detection confusion matrix provided by the present invention. Figure 14 This is a schematic diagram illustrating the recognition accuracy provided by the present invention. Figure 15 This diagram illustrates the recognition recall rate provided by the present invention. Analysis of the graph-normalized confusion matrix shows that the recognition accuracy for *Chilo_suppressalis_egg* (Chilo. suppressalis egg) reaches 98%, indicating that the model has a high discriminative ability for this category. Meanwhile, the false positive rate for the background is only 2%, indicating that the model can effectively distinguish between the target and the background. However, other categories in the matrix (such as *Chilo_suppressalis_Walker*, *Sesamia_inferens_adult*, etc.) do not display specific values, suggesting that the model may experience recognition confusion or inconsistent data labeling in these categories, affecting the overall interpretability of the classification.

[0087] Figure 16 This is a schematic diagram of the intelligent rice pest detection system provided by the present invention, as shown below. Figure 16As shown, the system allows users to upload images for testing via a front-end interactive interface and calls a pre-trained model based on Ghost-YOLOv11n to automatically detect and classify pest targets. The detection results are presented in a visual format; the system marks the pest areas in the input image, highlights them with rectangular bounding boxes, and annotates the corresponding pest category and its confidence level. Furthermore, the system provides a result export function, allowing users to save the annotated images and related detection data as PDFs or other common image formats for subsequent recording, analysis, and decision-making reference.

[0088] When applying the rice pest detection method based on YOLOv11n and transfer learning provided in this manual, it is not necessary to... Figure 1 The steps shown are executed in sequence. The specific execution order of each step can be determined as needed, and this manual does not impose any restrictions on it.

[0089] The above are one or more embodiments of the rice pest detection method based on YOLOv11n and transfer learning provided in this specification. Based on the same idea, this specification also provides a corresponding rice pest detection device based on YOLOv11n and transfer learning, such as... Figure 17 As shown.

[0090] Figure 17 A schematic diagram of a rice pest detection device based on YOLOv11n and transfer learning, provided in this specification, includes: The acquisition module 1701 is used to acquire multiple images of rice pests in the field environment, and to label the pest type and location of each image to obtain a rice pest and disease dataset.

[0091] Module 1702 is used to acquire the improved YOLOv11n model. The traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head. The improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module. The loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss.

[0092] Initialization module 1703 is used to perform cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset to initialize the improved YOLOv11n model.

[0093] Training module 1704 is used to freeze the parameters of layers 0 to 6 of the backbone network in the first preset number of training epochs of the improved YOLOv11n model, unfreeze all the parameters of the improved YOLOv11n model in the last preset number of training epochs of the improved YOLOv11n model, and fine-tune the parameters of the improved YOLOv11n model to obtain the trained improved YOLOv11n model.

[0094] The detection module 1705 is used to detect rice pest images using a trained improved YOLOv11n model and obtain pest detection results.

[0095] Specific limitations regarding the YOLOv11n-based and transfer learning-based rice pest detection device can be found in the above description of the limitations of the YOLOv11n-based and transfer learning-based rice pest detection method, and will not be repeated here. Each module in the aforementioned YOLOv11n-based and transfer learning-based rice pest detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.

[0096] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 A method for detecting rice pests based on YOLOv11n and transfer learning is provided.

[0097] This instruction manual also provides Figure 18 The schematic diagram of the computer device shown is as follows: Figure 18 At the hardware level, the computer device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above-mentioned functions. Figure 1 A method for detecting rice pests based on YOLOv11n and transfer learning is provided.

[0098] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0099] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

Claims

1. A method for detecting rice pests based on YOLOv11n and transfer learning, characterized in that, include: Multiple images of rice pests were collected in the field, and the pest type and location were labeled for each image to obtain a rice pest and disease dataset. Obtain the improved YOLOv11n model; the traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head; the improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module; the loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss; We initialize the improved YOLOv11n model by performing cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset. In the first preset number of training epochs of the improved YOLOv11n model, the parameters of layers 0 to 6 of the backbone network are frozen. In the last preset number of training epochs of the improved YOLOv11n model, all parameters of the improved YOLOv11n model are unfrozen, and the parameters of the improved YOLOv11n model are fine-tuned to obtain the trained improved YOLOv11n model. The improved YOLOv11n model was trained to detect rice pest images, and the pest detection results were obtained.

2. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The bounding box loss function of the improved YOLOv11n model is: ; ; ; ; in, The bounding box loss value for the improved YOLOv11n model. The bounding box regression loss function is... This represents the square of the Euclidean distance between the top-left and bottom-right vertices of the predicted bounding box. IOU represents the square of the Euclidean distance between the top-left and bottom-right vertices of the ground truth bounding box, and IOU represents the square of the predicted bounding box. pred and real frame gt The ratio of the area of ​​intersection to the area of ​​union. The minimum area of ​​a closed rectangle that covers both the actual and predicted bounding boxes of pests. The coordinates of the top-left corner of the pest prediction bounding box are: The coordinates are the bottom right corner of the pest prediction bounding box. The coordinates are the top-left corner of the actual bounding box of the pest. The coordinates are the lower right corner of the actual bounding box of the pest.

3. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The slide classification loss function of the improved YOLOv11n model is: ; in, The loss value for slide classification. For the first i The binary cross-entropy loss for each sample. For the sample The predicted score, N The total number of samples, For the first i The predicted probability of a sample. f Weighting function for Slide; The formula for calculating the binary cross-entropy loss is: ; in, For the first i Binary cross-entropy loss for each sample.

4. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The slide weighting function is: ; in, Weighting function for Slide, This is the threshold parameter for dynamic learning.

5. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The pest categories include rice stem borer, rice stem borer, large stem borer, three-stemmed stem borer, green rice stink bug, and mottled stink bug; The life stages of the rice stem borer include adult, larva, and pupa; the life stages of the rice stem borer include egg, larva, adult, and pupa; the life stages of the rice stem borer include larva, adult, and pupa; the life stages of the rice stem borer include larva, adult, and pupa; the life stages of the rice green bug include adult; and the life stages of the mottled bug include nymph.

6. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The C2f_GhostConv module includes an input layer, a first convolutional layer, a second convolutional layer, a splicing layer, and an output layer.

7. The rice pest detection method based on YOLOv11n and transfer learning as described in claim 1, characterized in that, The method further includes: After collecting multiple images of rice pests in a field environment, the OpenCV open-source computer vision library was used to perform data augmentation on the multiple rice pest images to obtain an augmented dataset; the data augmentation included rotation, cropping, hue, saturation, and brightness HSV, and Mosaic data augmentation; Each image in the augmented dataset is resized to a preset size using the LetterBox method.

8. A rice pest detection device based on YOLOv11n and transfer learning, characterized in that, include: The data acquisition module is used to acquire multiple images of rice pests in the field environment, and to label the pest type and location of each image to obtain a rice pest and disease dataset. The acquisition module is used to acquire the improved YOLOv11n model. The traditional YOLOv11n model includes a backbone network, a feature fusion network, and a detection head. The improvement method includes replacing the C3k2 modules in layers 6 and 8 of the backbone network with the C2f_GhostConv module. The loss function of the improved YOLOv11n model includes the intersection-union ratio (MPDIoU) bounding box loss function based on the minimum point distance and the Slide classification loss. The initialization module is used to perform cross-domain parameter transfer using YOLOv11n weights pre-trained on a public pest dataset, and to initialize the improved YOLOv11n model. The training module is used to freeze the parameters of layers 0 to 6 of the backbone network in the first preset number of training epochs of the improved YOLOv11n model, unfreeze all the parameters of the improved YOLOv11n model in the last preset number of training epochs of the improved YOLOv11n model, and fine-tune the parameters of the improved YOLOv11n model to obtain the trained improved YOLOv11n model. The detection module is used to detect rice pest images using a trained improved YOLOv11n model and obtain pest detection results.

9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1 to 7.

10. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in any one of claims 1 to 7.