Methods, devices, equipment and media for detecting pests and diseases in litchi orchards
By improving the convolutional layer of the YOLOv8 network model, introducing the CCFM module and DySample dynamic upsampling, the problems of illumination influence and edge device applicability of YOLOv8 in litchi orchard pest and disease detection were solved, achieving higher precision and lower parameter detection effects.
Patent Information
- Application Number
- CN202510015886.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-01-06
AI Technical Summary
The existing YOLOv8 network model has the problem of false detection or missed detection due to the influence of light intensity in litchi orchard pest and disease detection, and the YOLOv8n model is not suitable for deployment on edge devices.
By updating the convolutional layer of the backbone network to the receptive field attention convolutional layer, introducing the CCFM module and DySample dynamic upsampling, and improving the loss function to MPDIoU and Inner-IoU loss functions, a second litchi pest and disease detection model is constructed to enhance feature fusion and detection accuracy.
The detection accuracy and adaptability of the model in the natural environment of litchi orchards are improved, the number of model parameters is reduced, and it is suitable for edge device deployment.
Smart Images

Figure CN119963991B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of agricultural production, and in particular to a method for detecting pests and diseases in a litchi orchard, a corresponding device, an electronic device, and a computer-readable storage medium. Background Art
[0002] As an important commercial fruit crop in tropical and subtropical regions, the health of litchi orchards is directly related to the economic benefits of fruit farmers. However, litchi trees in orchards face a variety of pests and diseases during their growth, such as the litchi stink bug, sooty mold, and anthracnose. If these pests and diseases are not detected and controlled in a timely manner, they can lead to a significant decrease in litchi yield and quality, resulting in serious economic losses.
[0003] Traditional pest and disease detection methods rely primarily on manual inspections. These inspections consume significant manpower, time, and effort, and are inefficient. Due to the large size of orchards, comprehensive, real-time, and accurate monitoring is difficult to achieve manually. Furthermore, manual inspections are highly subjective, and the experience and judgment criteria vary among inspectors, making missed and false positives a common occurrence.
[0004] With the advancement of computer vision technology, deep learning-based object detection algorithms have provided a new approach for pest and disease detection in litchi orchards. The YOLO (You Only Look Once) algorithm family, known for its speed and efficiency, has been widely used in the field of object detection. YOLOv8, as a newer version of this family, has further improved detection accuracy and speed, but it still has certain challenges. First, regarding object recognition, the YOLOv8 pre-trained model is pre-trained using the Coco or ImageNet dataset. These datasets do not contain litchi images, meaning that the YOLOv8 pre-trained model has limitations in recognizing litchi image features. Second, the complex environment of litchi orchards, such as varying lighting conditions and the size of pests and diseases, poses limitations to the original YOLOv8 network model. For example, in natural environments, light intensity can affect litchi pest and disease detection, leading to false or missed detections. Again, in terms of model size, although the yolov8n model is smaller than s, m, l, and x and has the smallest size among the yolov8 models, it cannot be applied to deployment conditions with a smaller size than yolov8n, such as edge programming of smart devices.
[0005] To sum up, the original YOLOv8 network model in the existing technology has limitations. For example, the light intensity in the natural environment will affect the detection of litchi diseases and pests, resulting in false detection or missed detection, and the yolov8n model method is suitable for deployment conditions with a smaller scale than yolov8n, such as edge programming of smart devices. In order to solve this problem, the applicant has made corresponding explorations. Summary of the Invention
[0006] The purpose of this application is to solve the above problems and provide a litchi orchard pest and disease detection method, corresponding device, electronic device and computer-readable storage medium.
[0007] In order to meet the various objectives of this application, this application adopts the following technical solutions:
[0008] A method for detecting pests and diseases in a litchi orchard, which is proposed to meet one of the purposes of this application, comprises:
[0009] In response to an instruction to detect pests and diseases in a litchi orchard, an image of the litchi orchard to be detected containing the pests and diseases of the litchi orchard is obtained;
[0010] The second litchi pest and disease detection model was constructed by updating some Conv convolutional layers of the backbone network in the preset first litchi pest and disease detection model to receptive field attention convolutional layers, introducing a CCFM module in the neck network, updating the UpSample upsampling in the neck network to DySample dynamic upsampling, and updating the original loss function to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function.
[0011] Inputting the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, introducing a receptive field attention mechanism into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different locations;
[0012] In the CCFM module, a fusion block composed of convolutional layers is used to adjust the number of channels, and multiple RepBlock modules are used to fuse image features from different paths by element-wise addition. The DySample dynamic upsampling is used to resample the litchi orchard image to be detected by introducing content-aware sampling points;
[0013] The feature map after dynamic upsampling of DySample is transmitted to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of various litchi pests and diseases in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
[0014] Optionally, the step of inputting the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, introducing a receptive field attention mechanism in the receptive field attention convolution layer to dynamically adjust the convolution kernel parameter size according to different receptive field spatial features to capture information differences at different locations includes:
[0015] In the receptive field of each convolution kernel, the receptive field attention mechanism is used to calculate the attention weight of each position, global feature information is extracted through global average pooling, and 1x1 group convolution is used for information interaction to determine the attention characteristics of the receptive field;
[0016] The attention weight of each position is normalized through the Softmax operation to emphasize the importance of each local area in the receptive field;
[0017] In the convolution operation, the receptive field attention convolution layer multiplies the calculated attention weight with the dynamically adjusted convolution kernel parameters to generate a new dynamic convolution kernel, where different receptive field areas have different convolution kernels to capture information differences at different locations in the image.
[0018] Optionally, the step of resampling the litchi orchard image to be detected by using the DySample dynamic upsampling and introducing content-aware sampling points includes:
[0019] Determine an upsampling scale factor s and a feature map X of size C×H×W, using an input channel with C channels and an output channel with 2s channels. 2 Linear layer to generate a size of 2s 2 ×H×W offset O, then reshape the offset O into 2×sH×sW by pixel shuffling, and finally superimpose the offset O with the original sampling network G to obtain the sampling set δ, where the expression of the offset O is:
[0020] O = linear(X);
[0021] The expression of the sampling set δ is:
[0022] δ=G+O;
[0023] Where s represents the upsampling scale factor, H and W are the height and width of the feature map X, O is the offset, G represents the original sampling network, and linear() represents the fully connected layer;
[0024] Get a feature map X of size C×H1×W1 and a sampling set δ of size 2×H2×W2, and use the grid_sample function to resample the feature map X based on the coordinates of the sampling set δ by applying a bilinear interpolation method to generate a new feature map X of size C×H2×W2 ′ , whose expressions include:
[0025] X ′ =grid_sample(X,δ),
[0026] Among them, C represents the number of input channels, H1 and W1 are the height and width of the feature map X, H2 and W2 are the new feature map X. ′ The height and width, X ′ is the new feature map, X is the feature map, and δ is the sampling set.
[0027] Optionally, the expression of the MPDIoU loss function includes:
[0028] L MPDIoU =1-MPDIoU,
[0029]
[0030] Among them, IoU represents the original intersection-over-union ratio, which represents the ratio of the intersection area of two bounding boxes A and B to the union area. Its value is between 0 and 1. The closer the value is to 1, the higher the degree of overlap between the two bounding boxes, and the closer the predicted box is to the real box. w and h represent the height and width of the input image. represents the coordinates of the predicted bounding box, Represents the coordinates of the true bounding box, d1 represents the distance between the predicted bounding box and the upper left corner of the true bounding box, and d2 represents the distance between the predicted bounding box and the lower right corner of the true bounding box.
[0031] Optionally, the expression of the Inner-IoU loss function includes:
[0032]
[0033]
[0034] union=(w gt *b gt )*(ratio) 2 +(w*b)*(ratio) 2 -inter,
[0035]
[0036] Among them, let the real box be Bgt , whose center point is The width and height of the ground truth box are w gt and b gt ; The anchor box is B, and its center point is (x c ,y c ), the width and height of the anchor box are w and b respectively; ratio represents the scale factor, which is used to control the scale of the auxiliary bounding box, and its value range is [0.5, 1.5]; Respectively represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the real box, and b l , b r , b t , b b They represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the anchor box, respectively. Inter represents the intersection area of the auxiliary bounding box of the real box and the anchor box, and union represents the union area of the auxiliary bounding box of the real box and the anchor box.
[0037] An improved loss function of the second litchi pest and disease detection model is constructed according to the MPDIoU loss function and the Inner-IoU loss function. The expression of the improved loss function is:
[0038] L Inner-MPDIoU =L MPDIoU +IoU-IoU inner ,
[0039] Among them, L Inner-MPDIoU represents the improved loss function.
[0040] Optionally, the fusion block includes two 1×1 convolutional layers, and the RepBlock module includes multiple RepConv layers.
[0041] Optionally, the basic network architecture of the first litchi disease and pest detection model is the original YOLOv8n network model, and the basic network architecture of the second litchi disease and pest detection model is the improved YOLOv8n network model; the litchi diseases and pests include litchi diseases and litchi pests, the litchi pests include one or any multiple of leaf gall midge, litchi stink bug, and felt disease, and the litchi diseases include one or any multiple of soot mold, anthrax, and algal spot disease.
[0042] A litchi orchard pest and disease detection device provided for another purpose of the present application includes:
[0043] An orchard image acquisition module is configured to respond to an instruction to perform pest and disease detection on a litchi orchard and acquire an image of the litchi orchard to be detected containing litchi pests and diseases;
[0044] A detection model construction module is configured to update some Conv convolution layers of the backbone network in the preset first litchi pest and disease detection model to receptive field attention convolution layers, introduce a CCFM module into the neck network and update the UpSample upsampling in the neck network to DySample dynamic upsampling, and update the original loss function to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct a second litchi pest and disease detection model;
[0045] a feature extraction module configured to input the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, and introduce a receptive field attention mechanism into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different locations;
[0046] a feature fusion module configured to use a fusion block composed of convolutional layers in the CCFM module to adjust the number of channels and use multiple RepBlock modules to fuse image features from different paths by element-wise addition, and use the DySample dynamic upsampling to resample the litchi orchard image to be detected by introducing content-aware sampling points;
[0047] The pest and disease detection module is configured to transmit the feature map after dynamic upsampling of DySample to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of each litchi pest and disease in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
[0048] An electronic device provided to meet another purpose of the present application includes a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to execute the steps of the litchi orchard pest and disease detection method described in the present application.
[0049] A computer-readable storage medium is provided to meet another purpose of the present application, which stores a computer program implemented according to the litchi orchard pest and disease detection method in the form of computer-readable instructions. When the computer program is called and executed by a computer, the steps included in the corresponding method are executed.
[0050] Compared with the existing technology, this application addresses the limitations of the original YOLOv8 network model in the existing technology, such as the fact that light intensity in natural environments can affect the detection of litchi pests and diseases, resulting in false detection or missed detection, and the yolov8n model method is suitable for deployment conditions with smaller volumes than yolov8n, such as edge programming of smart devices. This application includes but is not limited to the following beneficial effects:
[0051] First, the improved YOLOv8n network model of this application uses CCFM to improve the neck network of the original YOLOv8n network model, specifically including:
[0052] (1) Efficient feature fusion structure design: CCFM achieves cross-scale feature fusion by inserting a fusion block composed of convolutional layers into the fusion path. The fusion block contains two 1×1 convolutions to adjust the number of channels, N RepBlocks composed of RepConvs for feature fusion, and finally the two outputs are fused by element-wise addition. This structure can effectively fuse features of adjacent scales into new features, allowing the model to simultaneously utilize feature information at different scales and enrich the feature expression.
[0053] (2) Enhanced feature fusion effectiveness: Compared with some traditional cross-scale feature fusion methods, CCFM can more accurately fuse features of different scales. Traditional methods may lose some information or introduce noise during the fusion process. However, CCFM reduces information loss and enhances the quality of fused features through a carefully designed fusion block structure, providing stronger support for subsequent predictions and thus improving the accuracy of the model.
[0054] Secondly, the improved YOLOv8n network model of this application updates the UpSample upsampling in the neck network of the original YOLOv8n network model to dynamic upsampling DySample, specifically including:
[0055] (1) Efficient Sampling: DySample redefines the upsampling process from the perspective of point sampling. It assumes that the input features are interpolated into a continuous feature map through bilinear interpolation, and then generates content-aware sampling points to resample this continuous map. This point sampling-based approach avoids complex dynamic convolution and additional subnetworks, improves resource utilization, and enables faster model training and inference, thereby improving performance.
[0056] (2) Reduce information loss: DySample can supplement the information that may be missing in the original data to a certain extent by reasonably generating new sampling points, enabling the model to learn richer features, thereby improving the model's performance and prediction accuracy.
[0057] Third, the improved YOLOv8n network model in this application uses receptive field attention convolution (RFAConv) to replace the original Conv convolution in the backbone network, specifically including:
[0058] (1) Multi-scale feature fusion: RFAConv promotes the fusion of features of different scales. In both the frequency and spatial domains, features of different scales are of great value for the completion of tasks. Through the operation of RFAConv, the features of different frequency ranges after Fourier transformation are fused with the original spatial domain features, which enables the model to utilize both macroscopic and microscopic feature information. In the task of detecting pests and diseases in litchi orchards, this multi-scale feature fusion can better locate targets of different sizes, and can effectively utilize everything from the overall scene information to the local details of the target, thereby improving detection accuracy;
[0059] (2) Feature interaction enhancement: RFAConv can enhance the interaction between features. During the convolution process, the mechanism introduced by RFAConv enables features from different channels and features in the frequency and spatial domains to interact more effectively. This interaction can uncover the potential relationships between features.
[0060] (3) Enhance the generalization ability of the model: The random sampling operation in RFAConv helps increase the diversity of the model. During the training process, by randomly sampling Fourier coefficients and other methods, the model is exposed to different representations of the data. This is similar to data augmentation technology, which prevents the model from being overly dependent on specific data patterns, allowing it to better adapt to different test data and improve the model's generalization ability.
[0061] Third, the improved YOLOv8n network model in this application updates the original YOLOv8n model's loss function to the Inner-MPDIoU loss function. Inner-MPDIoU calculates the Intersection over Union (IoU) by minimizing the point-wise distance between the predicted bounding box and the true bounding box. This approach makes the loss function calculation more consistent with the actual requirements of bounding box regression. During training, the model can more directly optimize towards reducing the difference between the predicted and true bounding boxes, resulting in more accurate bounding box predictions.
[0062] Fourthly, this application has made lightweight improvements to the original YOLOv8n network model, reducing the number of model parameters, model weights, and model calculations, while improving the detection efficiency of the model; this application has improved the YOLOv8n network model structure and loss function, improving the model convergence speed, feature extraction and fusion capabilities, thereby improving the detection accuracy of the model in the natural environment of the litchi orchard. The improved YOLOv8n network model of this application can solve the problems of the original network model being applied to edge devices for litchi pest and disease detection, such as large model parameters, difficulty in deploying to edge devices, and interference with pest and disease detection caused by the natural environment of the litchi orchard. It can improve the accuracy of litchi pest and disease detection in the natural environment of the litchi orchard while reducing the original YOLOv8 parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0064] Figure 1 Schematic diagram of the process of detecting pests and diseases in litchi orchards in the embodiment of the present application;
[0065] Figure 2 This is a schematic diagram of annotating the expanded data set in an embodiment of the present application;
[0066] Figure 3 This is a schematic diagram of dividing the data set into a training set, a test set, and a validation set in a ratio of 8:1:1 in an embodiment of the present application;
[0067] Figure 4 Schematic diagram of the training results of the YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l and YOLOv8x network models in the embodiments of the present application;
[0068] Figure 5 This is an exemplary network architecture used by the improved YOLOv8n network model in the embodiments of the present application;
[0069] Figure 6 Schematic diagram of the structure of the receptive field attention convolution (RFAConv) in the embodiment of this application;
[0070] Figure 7 This is a schematic diagram of the structure of the Fusion module in the CCFM module in the embodiment of the present application;
[0071] Figure 8 Schematic diagram of the structure of DySample dynamic upsampling based on sampling in an embodiment of the present application;
[0072] Figure 9 This is a schematic diagram of the structure of the sampling point generator in the DySample dynamic upsampling embodiment of the present application;
[0073] Figure 10 Schematic diagram of training results of different improvement strategies in the embodiments of the present application;
[0074] Figure 11 This is a functional block diagram of the litchi orchard pest and disease detection device in the embodiment of the present application;
[0075] Figure 12 Schematic diagram of the structure of the computer device in the embodiment of the present application. DETAILED DESCRIPTION
[0076] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and are not to be construed as limiting the present application.
[0077] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.
[0078] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0079] It will be understood by those skilled in the art that the terms "client," "terminal," and "terminal device" as used herein include both devices that are wireless signal receivers, i.e., devices that only have wireless signal receivers without transmission capabilities, and devices that have receiving and transmitting hardware capable of two-way communication over a two-way communication link. Such devices may include: cellular or other communication devices such as personal computers and tablet computers, which have single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service), which may combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant), which may include a radio frequency receiver, a pager, Internet / Intranet access, a web browser, a notepad, a calendar, and / or a GPS (Global Positioning System) receiver; and conventional laptop and / or palmtop computers or other devices, which have and / or include a radio frequency receiver. As used herein, the terms "client," "terminal," or "terminal device" may be portable, transportable, or installed in a vehicle (air, sea, and / or land), or may be adapted and / or configured to operate locally and / or in a distributed manner at any other location on Earth and / or in space. As used herein, the terms "client," "terminal," or "terminal device" may also refer to a communication terminal, an Internet terminal, or a music / video playback terminal, such as a PDA, an MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or may include a smart TV, a set-top box, or other device.
[0080] The hardware referred to by names such as "server", "client", and "service node" in this application is essentially an electronic device with capabilities equivalent to those of a personal computer. It is a hardware device that has the necessary components revealed by the von Neumann principle, such as a central processing unit (including an arithmetic unit and a controller), a memory, an input device, and an output device. Computer programs are stored in its memory, and the central processing unit loads the program stored in the external memory into the internal memory for execution, executes the instructions in the program, and interacts with the input and output devices to complete specific functions.
[0081] It should be noted that the concept of "server" referred to in this application can also be extended to server clusters. Based on the network deployment principles understood by those skilled in the art, the servers described should be logically divided. In physical space, these servers can be independent of each other but callable through interfaces, or integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method of this application.
[0082] Unless expressly specified, one or more technical features of the present application can be deployed on a server for implementation and accessed by a client through a remote call to obtain an online service interface provided by the server, or can be directly deployed and run on a client for implementation.
[0083] Unless expressly specified otherwise, the neural network models referenced or may be referenced in this application may be deployed on a remote server and remotely called on the client, or may be deployed and directly called on a client with sufficient device capabilities. In some embodiments, when it runs on the client, its corresponding intelligence may be obtained through transfer learning to reduce the requirements for the client's hardware operating resources and avoid excessive occupation of the client's hardware operating resources.
[0084] Unless explicitly specified, the various data involved in this application can be stored remotely on a server or on a local terminal device, as long as they are suitable for being called by the technical solution of this application.
[0085] Those skilled in the art should be aware that although the various methods of this application are described based on the same concept and thus exhibit commonality, unless otherwise specified, these methods can be independently executed. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept. Therefore, concepts with the same expression, as well as concepts that are appropriately transformed for convenience despite different expression, should be understood as equivalent.
[0086] Unless expressly stated to be mutually exclusive, the various embodiments disclosed in this application may be cross-combined with the relevant technical features of the various embodiments to flexibly construct new embodiments, as long as such combination does not deviate from the creative spirit of this application and can meet the needs of the prior art or resolve certain deficiencies in the prior art. Those skilled in the art should be aware of such flexibility.
[0087] See also Figure 1 In one embodiment, the litchi orchard pest detection method of the present application comprises:
[0088] Step S10: responding to an instruction to perform pest and disease detection on a litchi orchard, obtaining an image of the litchi orchard to be detected containing litchi pests and diseases;
[0089] The litchi orchard pest and disease detection system in the terminal device can respond to the instruction to detect the litchi orchard for pests and diseases, and obtain the litchi orchard image to be detected containing litchi pests and diseases; specifically, a mobile phone or camera can be used to collect litchi orchard images containing litchi pests and diseases, wherein the litchi pests and diseases include litchi diseases and litchi pests, wherein the litchi pests include one or more of leaf gall midge, litchi stink bug, and felt disease, and wherein the litchi diseases include one or more of soot disease, anthrax, and algal spot disease; a time period with sufficient light is selected to ensure that the captured image is clear enough. Then use Labelimg annotation software to annotate the image, such as Figure 2 As shown in the figure, after the labeling is completed, a txt file containing classification label information and coordinate information is generated. Then, the dataset is expanded using image augmentation methods such as random cropping, rotation, and random color to obtain the litchi pest and disease dataset. Finally, the expanded dataset is labeled to obtain the corresponding txt file. Figure 3 The dataset is divided into training set, test set and validation set in a ratio of 8:1:1.
[0090] In a further embodiment, five network structures of YOLOv8 are trained on the litchi orchard pest and disease dataset. The detection accuracy, detection speed and model size are compared to select n as the improved basic network. Based on n, improvement measures such as addition and replacement are performed on the network. The specific process is as follows:
[0091] We selected 640×640 pixels as the input image size, SGD as the optimizer, set the initial optimizer learning rate to 0.01, weight decay to 0.0005, model training times to 200, and batch size to 32. We trained five YOLOv8 networks of different depths and widths: YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x. The training results are shown in the figure below. Figure 4 As shown, YOLOv8n was selected as the basic network architecture of the first litchi pest and disease detection model of this application by evaluating the detection accuracy, detection speed, and model size of the training results.
[0092] Specifically, the accuracy of the model is evaluated using precision (P), recall (R), and mean average precision (mAP@0.5), and the lightweight effect of the model is evaluated using model parameters, model computational load (FLOPs), model size, and frame rate (frame per second, FPS). The specific calculation formulas for precision and recall are as follows:
[0093]
[0094] TP: Correct positive, indicating that the prediction is positive, and if the prediction is correct, then the actual case is also a positive example;
[0095] TN: True negative, indicating that the prediction is negative, and if the prediction is correct, then the actual example is also a negative example;
[0096] FP: False positive, which means the prediction is positive, but the prediction is wrong, so it is actually a negative example;
[0097] FN: False negative, indicating that the prediction is negative, the prediction is wrong, so it is actually a positive example;
[0098] The mean average precision (mAP@0.5) reflects the comprehensive performance of the model's accuracy-recall rate on different categories. The number of model parameters refers to the total number of learnable parameters in the model. These parameters are the values that the model learns and adjusts through data during training, and they determine the complexity and expressiveness of the model. The amount of model computation refers to the number of arithmetic operations (such as addition, multiplication, etc.) required by the model during a forward propagation (from input data through the model to obtain output results). It is mainly used to measure the computational cost of the model in the inference phase. The size of the model weight refers to the scale or number of learnable parameters in the model. The expression of the frame rate is:
[0099] FPS = 1000 / (image preprocessing time + inference time + post-processing time).
[0100] Step S20: Update some Conv convolution layers of the backbone network in the preset first litchi pest and disease detection model to receptive field attention convolution layers, introduce a CCFM module into the neck network, update the UpSample upsampling in the neck network to DySample dynamic upsampling, and update the original loss function to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct a second litchi pest and disease detection model;
[0101] See also Figure 5After obtaining a litchi orchard image to be detected containing litchi pests and diseases, some Conv convolutional layers of the backbone network in the preset first litchi pest and disease detection model are updated to receptive field attention convolutional layers, a CCFM module is introduced into the neck network, and the UpSample upsampling in the neck network is updated to DySample dynamic upsampling, and the original loss function is updated to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct a second litchi pest and disease detection model; wherein the basic network architecture of the first litchi pest and disease detection model is the original YOLOv8n network model, and the basic network architecture of the second litchi pest and disease detection model is the improved YOLOv8n network model.
[0102] In some embodiments, some Conv convolutions in the backbone network of the original YOLOv8n network model are updated to receptive field attention convolution (RFAConv). The structure of RFAConv is as follows: Figure 6 As shown in the figure. RFAConv introduces the Receptive Field Attention (RFA) mechanism, combining the attention mechanism with the convolution operation, so that the convolution kernel parameters are no longer shared across different receptive field sliders. At the same time, by multiplying the attention weights with the convolution kernel parameters to obtain new convolution kernel parameters, the parameter sharing problem in the feature extraction process is solved, thereby better capturing information differences at different locations and improving the network's ability to express image features. RFA places special emphasis on receptive field spatial features. The designed receptive field spatial features are dynamically generated according to the convolution kernel size and consist of non-overlapping sliding windows.
[0103] In this way, the receptive field attention convolution (RFAConv) can more effectively utilize the spatial information within the receptive field, highlight the importance of different features within the receptive field slider, and thus improve the network's ability to extract target object features. When calculating RFA, a series of operations such as global average pooling (AvgPool) are used to aggregate the global information of the receptive field features, and then 1×1 group convolution (GroupConv) is used for information interaction. Finally, softmax is used to emphasize the importance of each feature within the receptive field features. The attention map obtained in this way can focus on key features more accurately, allowing the network to pay more attention to features that are important for target recognition during the learning process, reducing the interference of irrelevant information, and thus improving accuracy.
[0104] In a further embodiment, a CCFM module is introduced to improve the neck network of the original YOLOv8n network model. The Fusion module in the CCFM module is as follows: Figure 7As shown in the figure, the CCFM module cleverly introduces a fusion block consisting of convolutional layers into the fusion path. Two 1×1 convolutions are crucial for adjusting the number of channels, ensuring efficient data flow during the fusion process. N RepBlocks, comprised of RepConv layers, focus on feature fusion, fusing the two outputs through element-wise addition. This structural design significantly reduces computational effort without sacrificing critical information, laying a solid foundation for lightweighting. Secondly, the CCFM module thoroughly analyzes the computational redundancy problem in the multi-scale Transformer encoder. It precisely avoids unnecessary intra-scale interaction computations on low-level features, instead focusing computational resources on intra-scale feature interactions of high-level features (such as S5). This strategy not only reduces computational overhead but also enables the module to better capture semantic information in high-level features, thereby improving object localization and recognition capabilities and ultimately enhancing accuracy. Ultimately, the CCFM module achieves both lightweighting and improved accuracy.
[0105] In a further embodiment, the UpSample upsampling in the neck network of the original YOLOv8n network model is updated to the dynamic upsampling DySample, the partial Conv convolution in the backbone network of the original YOLOv8n network model is updated to the receptive field attention convolution (RFAConv), and the loss function of the original YOLOv8n model is updated to the Inner-MPDIoU loss function. The process is as follows:
[0106] See also Figure 8 and Figure 9 ,in, Figure 8 This is a structural diagram of the DySample dynamic upsampling based on sampling. Figure 9 It is the sampling point generator in DySample dynamic upsampling; the UpSample upsampling in the neck network of the original YOLOv8n network model is updated to DySample dynamic upsampling. DySample dynamic upsampling redesigns the upsampling process from the perspective of point sampling, and resamples the input feature map by generating content-aware sampling points, avoiding the above problems. It can better retain the semantic information of the features, so that the upsampled features can provide more accurate information in subsequent prediction tasks, thereby improving accuracy.
[0107] In a further embodiment, the loss function of the original YOLOv8n model is updated to the Inner-MPDIoU loss function, that is, an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function. When the shape difference between the predicted box and the real box is large or the position deviation is large, the IoU-related loss function alone cannot accurately measure the difference between them, resulting in inaccurate bounding box regression. In order to solve this difficulty, the present application introduces the MPDIoU loss function to improve regression efficiency and accuracy, and introduces the Inner-IoU loss function to further improve the detection performance of the model. The MPDIoU loss function calculates IoU by minimizing the point distance between the predicted bounding box and the real bounding box. This method makes the calculation of the loss function more in line with the actual needs of bounding box regression. During the training process, the model can be optimized more directly in the direction of reducing the difference between the predicted box and the real box, thereby obtaining a more accurate bounding box prediction result. Among them, the expression of the MPDIoU loss function includes:
[0108] L MPDIoU =1-MPDIoU,
[0109]
[0110] Among them, IoU represents the original intersection-over-union ratio, which represents the ratio of the intersection area of two bounding boxes A and B to the union area. Its value is between 0 and 1. The closer the value is to 1, the higher the degree of overlap between the two bounding boxes, and the closer the predicted box is to the real box. w and h represent the height and width of the input image. represents the coordinates of the predicted bounding box, Represents the coordinates of the true bounding box, d1 represents the distance between the predicted bounding box and the upper left corner of the true bounding box, and d2 represents the distance between the predicted bounding box and the lower right corner of the true bounding box.
[0111] The expression of the Inner-IoU loss function includes:
[0112]
[0113] union=(w gt *b gt )*(ratio) 2 +(w*b)*(ratio) 2 -inter,
[0114]
[0115] Among them, let the real box be B gt , whose center point is The width and height of the ground truth box are wgt and b gt ; The anchor box is B, and its center point is (x c ,y c ), the width and height of the anchor box are w and b respectively; ratio represents the scale factor, which is used to control the scale of the auxiliary bounding box, and its value range is [0.5, 1.5]; Respectively represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the real box, and b l , b r , b t , b b They represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the anchor box, respectively. Inter represents the intersection area of the auxiliary bounding box of the real box and the anchor box, and union represents the union area of the auxiliary bounding box of the real box and the anchor box.
[0116] In a further embodiment, an improved loss function of the second litchi pest and disease detection model is constructed based on the MPDIoU loss function and the Inner-IoU loss function, and the expression of the improved loss function is:
[0117] L Inner-MPDIoU =L MPDIoU +IoU-IoU inner ,
[0118] Among them, L Inner-MPDIoU represents the improved loss function.
[0119] The training results of different improvement strategies are as follows Figure 10 The final improved YOLOv8n network model is named CRDM-YOLOv8. The results show that the improved YOLOv8n network model reduces the number of model parameters while improving the detection accuracy of pests and diseases in litchi orchards based on the original YOLOv8n network model.
[0120] Step S30: inputting the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, introducing a receptive field attention mechanism into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different locations;
[0121] The part of the Conv convolution layer of the backbone network in the preset first litchi pest and disease detection model is updated to the receptive field attention convolution layer, the CCFM module is introduced into the neck network, and the UpSample upsampling in the neck network is updated to the DySample dynamic upsampling, and the original loss function is updated to the improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct the second litchi pest and disease detection model. After that, the litchi orchard image to be detected is input into the second litchi pest and disease detection model that has been trained to a convergence state. The receptive field attention mechanism is introduced into the receptive field attention convolution layer to dynamically adjust the convolution kernel parameter size according to different receptive field spatial features to capture information differences at different positions;
[0122] In some embodiments, the litchi orchard image to be detected is input into a second litchi pest and disease detection model that has been trained to a convergent state, and a receptive field attention mechanism is introduced into the receptive field attention convolution layer to dynamically adjust the convolution kernel parameter size according to different receptive field spatial features to capture information differences at different locations. The steps include:
[0123] Step S301: In the receptive field of each convolution kernel, the receptive field attention mechanism is used to calculate the attention weight of each position, global feature information is extracted through global average pooling, and 1x1 group convolution is used for information interaction to determine the attention feature of the receptive field;
[0124] Step S302: normalize the attention weight of each position through the Softmax operation to emphasize the importance of each local area in the receptive field;
[0125] Step S303: In the convolution operation, the receptive field attention convolution layer multiplies the calculated attention weight with the dynamically adjusted convolution kernel parameters to generate a new dynamic convolution kernel, where different receptive field areas have different convolution kernels to capture information differences at different locations in the image.
[0126] Step S40: In the CCFM module, a fusion block composed of convolutional layers is used to adjust the number of channels, and multiple RepBlock modules are used to fuse image features from different paths by element-wise addition. The DySample dynamic upsampling is used to resample the litchi orchard image to be detected by introducing content-aware sampling points.
[0127] The litchi orchard image to be detected is input into a second litchi pest and disease detection model that has been trained to a convergent state. A receptive field attention mechanism is introduced into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different positions. In the CCFM module, a fusion block composed of convolution layers is used to adjust the number of channels, and multiple RepBlock modules are used to fuse image features from different paths by element-wise addition. The DySample dynamic upsampling is used to resample the litchi orchard image to be detected by introducing content-aware sampling points.
[0128] In some embodiments, the fusion block includes two 1×1 convolutional layers, and the RepBlock module includes multiple RepConv layers.
[0129] In some embodiments, the step of resampling the litchi orchard image to be detected by introducing content-aware sampling points using the DySample dynamic upsampling comprises:
[0130] Step S401: Determine an upsampling scale factor s and a feature map X of size C×H×W, using an input channel with C channels and an output channel with 2s channels. 2 Linear layer to generate a size of 2s 2 ×H×W offset O, then reshape the offset O into 2×sH×sW by pixel shuffling, and finally superimpose the offset O with the original sampling network G to obtain the sampling set δ, where the expression of the offset O is:
[0131] O = linear(X);
[0132] The expression of the sampling set δ is:
[0133] δ=G+O;
[0134] Where s represents the upsampling scale factor, H and W are the height and width of the feature map X, O is the offset, G represents the original sampling network, and linear() represents the fully connected layer;
[0135] Step S402: Obtain a feature map X of size C×H1×W1 and a sampling set δ of size 2×H2×W2, and use the grid_sample function to resample the feature map X based on the coordinates of the sampling set δ by applying a bilinear interpolation method to generate a new feature map X of size C×H2×W2. ′ , whose expressions include:
[0136] X ′=grid_sample(X,δ),
[0137] Among them, C represents the number of input channels, H1 and W1 are the height and width of the feature map X, H2 and W2 are the new feature map X. ′ The height and width, X ′ is the new feature map, X is the feature map, and δ is the sampling set.
[0138] Step S50: transmit the feature map after dynamic upsampling of DySample to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of each litchi pest and disease in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
[0139] In the CCFM module, a fusion block composed of convolutional layers is used to adjust the number of channels, and multiple RepBlock modules are used to fuse image features from different paths by element-wise addition. After the DySample dynamic upsampling is used to resample the litchi orchard image to be detected by introducing content-aware sampling points, the feature map after DySample dynamic upsampling is transmitted to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of various litchi pests and diseases in the litchi orchard image to be detected, so as to complete the detection of pests and diseases in the litchi orchard.
[0140] As can be seen from the above embodiments, compared with the prior art, this application addresses the limitations of the original YOLOv8 network model in the prior art, such as the fact that light intensity in a natural environment may affect the detection of litchi pests and diseases, resulting in false detection or missed detection, and the yolov8n model method is suitable for deployment conditions with a smaller volume than yolov8n, such as edge programming of smart devices. This application includes but is not limited to the following beneficial effects:
[0141] First, the improved YOLOv8n network model of this application uses CCFM to improve the neck network of the original YOLOv8n network model, specifically including:
[0142] (1) Efficient feature fusion structure design: CCFM achieves cross-scale feature fusion by inserting a fusion block composed of convolutional layers into the fusion path. The fusion block contains two 1×1 convolutions to adjust the number of channels, N RepBlocks composed of RepConvs for feature fusion, and finally the two outputs are fused by element-wise addition. This structure can effectively fuse features of adjacent scales into new features, allowing the model to simultaneously utilize feature information at different scales and enrich the feature expression.
[0143] (2) Enhanced feature fusion effectiveness: Compared with some traditional cross-scale feature fusion methods, CCFM can more accurately fuse features of different scales. Traditional methods may lose some information or introduce noise during the fusion process. However, CCFM reduces information loss and enhances the quality of fused features through a carefully designed fusion block structure, providing stronger support for subsequent predictions and thus improving the accuracy of the model.
[0144] Secondly, the improved YOLOv8n network model of this application updates the UpSample upsampling in the neck network of the original YOLOv8n network model to dynamic upsampling DySample, specifically including:
[0145] (1) Efficient Sampling: DySample redefines the upsampling process from the perspective of point sampling. It assumes that the input features are interpolated into a continuous feature map through bilinear interpolation, and then generates content-aware sampling points to resample this continuous map. This point sampling-based approach avoids complex dynamic convolution and additional subnetworks, improves resource utilization, and enables faster model training and inference, thereby improving performance.
[0146] (2) Reduce information loss: DySample can supplement the information that may be missing in the original data to a certain extent by reasonably generating new sampling points, enabling the model to learn richer features, thereby improving the model's performance and prediction accuracy.
[0147] Third, the improved YOLOv8n network model in this application uses receptive field attention convolution (RFAConv) to replace the original Conv convolution in the backbone network, specifically including:
[0148] (3) Multi-scale feature fusion: RFAConv promotes the fusion of features of different scales. In both the frequency and spatial domains, features of different scales are of great value for the completion of tasks. Through the operation of RFAConv, the features of different frequency ranges after Fourier transformation are fused with the original spatial domain features, which enables the model to utilize both macroscopic and microscopic feature information. In the task of detecting pests and diseases in litchi orchards, this multi-scale feature fusion can better locate targets of different sizes, and can effectively utilize everything from the overall scene information to the local details of the target, thereby improving detection accuracy;
[0149] (4) Feature interaction enhancement: RFAConv can enhance the interaction between features. During the convolution process, the mechanism introduced by RFAConv enables features from different channels and features in the frequency and spatial domains to interact more effectively. This interaction can uncover the potential relationships between features.
[0150] (5) Enhance the generalization ability of the model: The random sampling operation in RFAConv helps increase the diversity of the model. During the training process, by randomly sampling Fourier coefficients and other methods, the model is exposed to different representations of the data. This is similar to data augmentation technology, which prevents the model from being overly dependent on specific data patterns, allowing it to better adapt to different test data and improve the generalization ability of the model.
[0151] Third, the improved YOLOv8n network model in this application updates the original YOLOv8n model's loss function to the Inner-MPDIoU loss function. Inner-MPDIoU calculates the Intersection over Union (IoU) by minimizing the point-wise distance between the predicted bounding box and the true bounding box. This approach makes the loss function calculation more consistent with the actual requirements of bounding box regression. During training, the model can more directly optimize towards reducing the difference between the predicted and true bounding boxes, resulting in more accurate bounding box predictions.
[0152] Fourthly, this application has made lightweight improvements to the original YOLOv8n network model, reducing the number of model parameters, model weights, and model calculations, while improving the detection efficiency of the model; this application has improved the YOLOv8n network model structure and loss function, improving the model convergence speed, feature extraction and fusion capabilities, thereby improving the detection accuracy of the model in the natural environment of the litchi orchard. The improved YOLOv8n network model of this application can solve the problems of the original network model being applied to edge devices for litchi pest and disease detection, such as large model parameters, difficulty in deploying to edge devices, and interference with pest and disease detection caused by the natural environment of the litchi orchard. It can improve the accuracy of litchi pest and disease detection in the natural environment of the litchi orchard while reducing the original YOLOv8 parameters.
[0153] See also Figure 11A litchi orchard pest and disease detection device provided to meet one of the purposes of this application includes an orchard image acquisition module 1100, a detection model construction module 1200, a feature extraction module 1300, a feature fusion module 1400 and a pest and disease detection module 1500. Among them, the orchard image acquisition module 1100 is configured to respond to an instruction to detect pests and diseases in a litchi orchard, and obtain a litchi orchard image to be detected containing litchi pests and diseases; the detection model construction module 1200 is configured to update part of the Conv convolution layer of the backbone network in the preset first litchi pest and disease detection model to a receptive field attention convolution layer, introduce a CCFM module in the neck network, and update the UpSample upsampling in the neck network to DySample dynamic upsampling, and update the original loss function to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct a second litchi pest and disease detection model; the feature extraction module 1300 is configured to input the litchi orchard image to be detected into the second litchi pest and disease detection model that has been trained to a convergence state, and in the A receptive field attention mechanism is introduced into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different positions; a feature fusion module 1400 is configured to use a fusion block composed of a convolution layer in the CCFM module to adjust the number of channels and use multiple RepBlock modules to fuse image features from different paths by element-wise addition, and use the DySample dynamic upsampling to resample the litchi orchard image to be detected by introducing content-aware sampling points; a pest and disease detection module 1500 is configured to transmit the feature map after the DySample dynamic upsampling to the detection head network in the second litchi pest and disease detection model to obtain the categories and positions of each litchi pest and disease in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
[0154] Based on any embodiment of this application, please refer to Figure 12 Another embodiment of the present application further provides an electronic device, which can be implemented by a computer device, such as Figure 12As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor may implement a method for detecting pests and diseases in a litchi orchard. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor may execute the method for detecting pests and diseases in a litchi orchard of the present application. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art will understand that Figure 12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0155] In this embodiment, the processor is used to execute Figure 11 The memory stores the program code and various data required to execute the specific functions of each module in the lychee orchard pest and disease detection device. The network interface is used to transmit data between user terminals or servers. The memory in this embodiment stores the program code and data required to execute all modules in the lychee orchard pest and disease detection device of this application. The server can call the server's program code and data to execute the functions of all modules.
[0156] The present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the litchi orchard pest and disease detection method described in any embodiment of the present application.
[0157] The present application also provides a computer program product, including a computer program / instruction, which, when executed by one or more processors, implements the steps of the litchi orchard pest and disease detection method described in any embodiment of the present application.
[0158] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments of the present application can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments of the method. The aforementioned storage medium can be a computer-readable storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0159] The above description is only part of the implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
[0160] In summary, the present application has made lightweight improvements to the original YOLOv8n network model, reducing the number of model parameters, model weights, and model calculations, while improving the detection efficiency of the model; the present application has improved the YOLOv8n network model structure and loss function, improving the model convergence speed, feature extraction and fusion capabilities, thereby improving the detection accuracy of the model in the natural environment of the litchi orchard. The improved YOLOv8n network model of the present application can solve the problems of the original network model being applied to edge devices for detection of litchi pests and diseases, such as large model parameters, difficulty in deployment to edge devices, and interference with pest and disease detection caused by the natural environment of the litchi orchard. It can improve the accuracy of litchi pest and disease detection in the natural environment of the litchi orchard while reducing the original YOLOv8 parameters.
Claims
1. A method for detecting pests and diseases in a litchi orchard, characterized in that: include: In response to an instruction to perform pest and disease detection on a litchi orchard, an image of a litchi orchard to be detected containing litchi pests and diseases is obtained, wherein the litchi pests and diseases include litchi diseases and litchi insect pests, the litchi insect pests include one or any multiple of leaf gall midge, litchi stink bug, and felt disease, and the litchi diseases include one or any multiple of sooty mold, anthracnose, and algal spot disease; The first litchi pest and disease detection model is configured as a first litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The first litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The second litchi pest and disease detection model is configured as a second litchi pest and disease detection model. The second litchi pest and disease detection model is configured as a second litchi pest and disease detection model. Inputting the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, introducing a receptive field attention mechanism into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different locations; In the CCFM module, a fusion block composed of convolutional layers is used to adjust the number of channels, and multiple RepBlock modules are used to fuse image features from different paths by element-wise addition. The DySample dynamic upsampling is used to resample the litchi orchard image to be detected by introducing content-aware sampling points; The feature map after dynamic upsampling of DySample is transmitted to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of various litchi pests and diseases in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
2. The method for detecting diseases and insect pests in litchi orchards according to claim 1, wherein: The steps of inputting the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, introducing a receptive field attention mechanism in the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different positions include: In the receptive field of each convolution kernel, the receptive field attention mechanism is used to calculate the attention weight of each position, global feature information is extracted through global average pooling, and 1x1 group convolution is used for information interaction to determine the attention characteristics of the receptive field; The attention weight of each position is normalized through the Softmax operation to emphasize the importance of each local area in the receptive field; In the convolution operation, the receptive field attention convolution layer multiplies the calculated attention weight with the dynamically adjusted convolution kernel parameters to generate a new dynamic convolution kernel, where different receptive field areas have different convolution kernels to capture information differences at different locations in the image.
3. The method for detecting diseases and insect pests in litchi orchards according to claim 1, wherein: The step of resampling the litchi orchard image to be detected by using the DySample dynamic upsampling and introducing content-aware sampling points comprises: Determine an upsampling scale factor s and a feature map X of size C×H×W, using an input channel with C channels and an output channel with 2s channels. 2 Linear layer to generate a size of 2s 2 ×H×W offset O, then reshape the offset O into 2×sH×sW by pixel shuffling, and finally superimpose the offset O with the original sampling network G to obtain the sampling set δ, where the expression of the offset O is: O = linear(X); The expression of the sampling set δ is: δ=G+O; Where s represents the upsampling scale factor, H and W are the height and width of the feature map X, O is the offset, G represents the original sampling network, and linear() represents the fully connected layer; Get a feature map X of size C×H1×W1 and a sampling set δ of size 2×H2×W2, and use the grid_sample function to resample the feature map X based on the coordinates of the sampling set δ by applying a bilinear interpolation method to generate a new feature map X of size C×H2×W2 ′ , whose expressions include: X'=grid_sample(X,δ), Where C represents the number of input channels, H1 and W1 are the height and width of the feature map X, H2 and W2 are the height and width of the new feature map X′, X′ is the new feature map, X is the feature map, and δ is the sampling set.
4. The method for detecting diseases and insect pests in litchi orchards according to claim 1, wherein: The expression of the MPDIoU loss function includes: L MPDIoU =1-MPDIoU, Among them, IoU represents the original intersection-over-union ratio, which represents the ratio of the intersection area of two bounding boxes A and B to the union area. Its value is between 0 and 1. The closer the value is to 1, the higher the degree of overlap between the two bounding boxes, and the closer the predicted box is to the real box. w and h represent the height and width of the input image. represents the coordinates of the predicted bounding box, Represents the coordinates of the true bounding box, d1 represents the distance between the predicted bounding box and the upper left corner of the true bounding box, and d2 represents the distance between the predicted bounding box and the lower right corner of the true bounding box.
5. The method for detecting diseases and insect pests in litchi orchards according to claim 4, characterized in that: The expression of the Inner-IoU loss function includes: union=(w gt *b gt )*(ratio) 2 +(w*b)*(ratio) 2 -inter, Among them, let the real box be B gt , whose center point is The width and height of the ground truth box are w gt and b gt ; The anchor box is B, and its center point is (x c ,y c ), the width and height of the anchor box are w and b respectively; ratio represents the scale factor, which is used to control the scale of the auxiliary bounding box, and its value range is [0.5, 1.5]; Respectively represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the real box, and b l , b r , b t , b b They represent the left boundary coordinates, right boundary coordinates, upper boundary coordinates, and lower boundary coordinates of the auxiliary bounding box of the anchor box, respectively. Inter represents the intersection area of the auxiliary bounding box of the real box and the anchor box, and union represents the union area of the auxiliary bounding box of the real box and the anchor box. An improved loss function of the second litchi pest and disease detection model is constructed according to the MPDIoU loss function and the Inner-IoU loss function. The expression of the improved loss function is: L Inner-MPDIoU =L MPDIoU +IoU-IoU inner , Among them, L Inner-MPDIoU represents the improved loss function.
6. The method for detecting diseases and insect pests in litchi orchards according to claim 1, wherein: The fusion block includes two 1×1 convolutional layers, and the RepBlock module includes multiple RepConv layers.
7. A litchi orchard pest and disease detection device, characterized in that: include: an orchard image acquisition module configured to respond to an instruction to perform pest and disease detection on a litchi orchard, and acquire an image of a litchi orchard to be detected containing litchi pests and diseases, wherein the litchi pests and diseases include litchi diseases and litchi insect pests, the litchi insect pests include one or any multiple of leaf gall midge, litchi stink bug, and felt disease, and the litchi diseases include one or any multiple of sooty mold, anthracnose, and algal spot disease; A detection model construction module is configured to update part of the Conv convolutional layers of the backbone network in the preset first litchi pest and disease detection model to receptive field attention convolutional layers, introduce a CCFM module into the neck network, update the UpSample upsampling in the neck network to DySample dynamic upsampling, and update the original loss function to an improved loss function constructed by the MPDIoU loss function and the Inner-IoU loss function to construct a second litchi pest and disease detection model, wherein the basic network architecture of the first litchi pest and disease detection model is the original YOLOv8n network model, and the basic network architecture of the second litchi pest and disease detection model is the improved YOLOv8n network model; a feature extraction module configured to input the litchi orchard image to be detected into a second litchi pest and disease detection model that has been trained to a convergent state, and introduce a receptive field attention mechanism into the receptive field attention convolution layer to dynamically adjust the size of the convolution kernel parameters according to different receptive field spatial features to capture information differences at different locations; a feature fusion module configured to use a fusion block composed of convolutional layers in the CCFM module to adjust the number of channels and use multiple RepBlock modules to fuse image features from different paths by element-wise addition, and use the DySample dynamic upsampling to resample the litchi orchard image to be detected by introducing content-aware sampling points; The pest and disease detection module is configured to transmit the feature map after dynamic upsampling of DySample to the detection head network in the second litchi pest and disease detection model to obtain the categories and locations of each litchi pest and disease in the litchi orchard image to be detected, so as to complete the pest and disease detection in the litchi orchard.
8. An electronic device comprising a central processing unit and a memory, characterized in that: The central processing unit is configured to call and run a computer program stored in the memory to execute the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that It stores a computer program implemented according to the method described in any one of claims 1 to 6 in the form of computer-readable instructions, and when the computer program is called and executed by a computer, the steps included in the corresponding method are executed.
Citation Information
Patent Citations
Disease and insect pest target detection method, device and equipment based on improved YOLOv8
CN117115640A
Lightweight remote sensing image target detection method fusing dynamic upsampling
CN119027817A