A lychee disease and pest detection method and platform based on improved YOLOv6 and a terminal

By improving the YOLOv6 model and deploying it on embedded devices, the problems of pest and disease detection accuracy and resource limitations were solved, achieving efficient and accurate detection of litchi pests and diseases, and improving the level of intelligent production in orchards.

CN119418266BActive Publication Date: 2025-10-17SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411435894.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-10-17
Estimated Expiration
2044-10-15

AI Technical Summary

Technical Problem

Existing pest and disease detection methods have low detection accuracy in complex backgrounds, and the YOLO model has a large computational load, making it difficult to deploy on resource-constrained devices, affecting the accuracy and efficiency of litchi pest and disease detection.

Method used

An improved YOLOv6 model is used to train the model through data enhancement and optimized network structure, combined with specific algorithm parameters. The model is quantized into int8 type and deployed on embedded devices for pest and disease detection.

Benefits of technology

It improves the accuracy of litchi disease and pest detection and the detection precision of multi-scale targets, realizes real-time detection on resource-constrained equipment, and improves the level of intelligence in orchard production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119418266B_ABST
    Figure CN119418266B_ABST
Patent Text Reader

Abstract

The application discloses a lychee disease and pest detection method and platform based on improved YOLOv6 and a terminal, which comprises the following steps: collecting and shooting disease and pest pictures, labeling the pictures to build a lychee disease and pest dataset in a real orchard scene required for training, and performing data enhancement processing on the dataset by using a data enhancement technology; training an improved YOLOV6 model on a pytorch framework by using the processed dataset, obtaining a trained lychee disease and pest detection pt model by adjusting parameters; collecting lychee plant pictures, inputting the lychee plant pictures into the trained lychee disease and pest detection pt model, and obtaining lychee disease and pest detection results; converting the trained pt model into a general onnx model, performing model pruning, converting the onnx model into an rknn model, and performing ptq quantization to quantize the model from a float32 type to an int8 type; calling an API interface of model inference on an embedded device; and deploying the model on a detection platform.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of orchard pest detection and target detection model deployment, and more particularly to a litchi pest detection method, a detection platform and a terminal based on an improved YOLOv6. BACKGROUND

[0002] Litchi is a common fruit, but it is also susceptible to various pests and diseases. Common pests and diseases include stink bugs, measuring moths, felt disease, and anthracnose, which can affect litchi photosynthesis and nutrient absorption, normal growth and function of leaves, cause fruit to rot and deteriorate, and cause damage to litchi tree growth, resulting in reduced litchi yield and quality, and severely affecting the economic benefits of orchards. Due to the large number of litchi pests and diseases and the complexity of the causes, it is difficult to prevent and diagnose litchi pests and diseases. Traditional pest and disease diagnosis methods rely on manual detection and identification, which requires high planting and observation experience for growers. New growers can only hire experts to provide on-site guidance, which is slow, inefficient, expensive, subjective, inaccurate, and not time-sensitive.

[0003] Currently, the typical target detection model YOLO series is suitable for mobile devices and embedded devices due to its fast detection speed and high accuracy.

[0004] However, traditional YOLO pest and disease detection models may not perform well in complex backgrounds, especially in natural environments, where the diversity and unstructured features of the background can affect detection accuracy, and the size of litchi pests and diseases can also affect detection accuracy.

[0005] Moreover, the float32 YOLO model is still computationally intensive for rv1126 chips, making it difficult to deploy a target detection model on resource-constrained devices.

[0006] Therefore, how to improve the accuracy of litchi pest and disease detection and the detection accuracy of multi-scale targets, and how to deploy a target detection model on resource-constrained devices to more accurately and quickly detect litchi pests and diseases and improve the intelligence level of litchi orchard production are problems that need to be solved by those skilled in the art. SUMMARY

[0007] Therefore, the present application provides a litchi pest and disease detection method, a detection platform and a terminal based on an improved YOLOv6 to solve some of the technical problems mentioned in the background art.

[0008] To achieve the above purpose, the present application adopts the following technical solutions:

[0009] A litchi pest and disease detection method based on an improved YOLOv6, comprising the following steps:

[0010] S1. Capture and collect pest and disease images, annotate the images, and construct a litchi pest and disease dataset in a real orchard setting required for training. Use data augmentation technology to enhance the dataset.

[0011] S2. Use the processed dataset to train an improved YOLOV6 model on the PyTorch framework and obtain a trained litchi pest and disease detection PT model by adjusting parameters.

[0012] S3. Collect litchi plant images and input them into the trained litchi pest and disease detection pt model to obtain litchi pest and disease detection results.

[0013] Preferably, the specific details of the improved YOLOv6 model training process are as follows:

[0014] S21. Read images of litchi pests and diseases and their corresponding labels, preprocess the images and labels into 640*640*3 images using a letterboxing operation, and then input them into the improved YOLOv6 model.

[0015] S22. After the model receives a 640*640 RGB image as input, it uses the improved YOLOv6 model to obtain many predicted detection boxes. The NMS filter removes redundant detection boxes.

[0016] S23. After obtaining the final predicted detection frame, the classification loss and regression loss are calculated respectively with the actual label category and annotation frame, and the model parameters are updated through the backpropagation algorithm to finally obtain the trained litchi pest and disease detection PT model.

[0017] Preferably, the improved YOLOv6 model includes a backbone network, a neck network, and a detection head;

[0018] The backbone network uses EfficientRep, which includes a RepVGGBlock layer and four ERBlocks. It first goes through a RepVGGBlock layer for downsampling and expands the number of channels. Then it goes through four ERBlocks for downsampling four times. After each downsampling, the feature map is saved. Finally, the backbone network outputs four feature maps of different sizes as the input of the neck network. The four feature maps are x3, x2, x1, and x0 in descending order.

[0019] The neck network uses RepBiFPANNeck, which includes convolutional layers, upsampling modules, downsampling modules, bidirectional fusion layers, RepBlock, and HALF high- and low-order fusion modules. The neck network outputs three feature maps of different sizes to the detection head for parsing;

[0020] The detection head uses an Efficient decoupled head, which is composed of multiple convolutional layers, adopts a mixed channel strategy, and predicts the final detection result according to multi-level features input from the neck. Classification and positioning are decoupled into two branches.

[0021] Preferably, the first three ERBlocks of the backbone network include an improved down-sampling module SPBlock and a RepBlock, and the last ERBlock includes an improved down-sampling module SPBlock, a RepBlock, and a CSPSPPF module.

[0022] The SPBlock is used for down-sampling, splits the input features into two parts in the channel dimension, the Representative part performs convolution to extract important information, and the Uncertain part performs convolution to supplement implicit detailed information.

[0023] The RepBlock includes multiple RepVGGBlocks for deep feature extraction.

[0024] The CSPSPPF module is improved for SPPF, which improves the speed while keeping the receptive field unchanged.

[0025] Preferably, the neck network outputs three feature maps of different sizes to the detection head for analysis, and the specific content is as follows:

[0026] (1) 1x1 convolution is performed on x0 to reduce the channel number to 1 / 4 of the original, denoted as fpn_out0, which is input into the bidirectional fusion layer together with x1 and x2 for multi-scale feature fusion. After multiple RepBlocks extract the fused features, they are used as low-order features, denoted as f_out0.

[0027] (2) 1x1 convolution is performed on f_out0 to reduce the channel number to 1 / 2 of the original, denoted as fpn_out1, which is input into the bidirectional fusion layer together with x2 and x3 for multi-scale fusion. After multiple RepBlocks, the feature layer used for detecting small targets is obtained as the first output feature map of the neck network, denoted as pan_out2.

[0028] (3) pan_out2 is down-sampled and concatenated with fpn_out1 in the channel dimension. After multiple RepBlocks extract the fused features, they are used as middle-order features, denoted as pan_out1_tmp.

[0029] (4) Downsample the mid-level feature pan_out1_tmp and concatenate it with fpn_out0 in the channel dimension. The fused feature after multiple RepBlocks is taken as the third output feature map of the neck network, denoted as pan_out0;

[0030] (5) The HALF high-low level fusion module fuses the mid-level feature pan_out1_tmp and the low-level feature f_out0 as the second output feature map of the neck network, denoted as pan_out1.

[0031] Preferably, in step S23, the classification loss uses VariFocal Loss, which balances the backpropagation learning from positive and negative samples by considering different importance levels of the samples, and specifically:

[0032]

[0033] where p is the model predicted IACS, q is the target IoU score, and α and γ are large hyperparameters for negative samples, α prevents over-suppression, and γ reduces the contribution of negative samples.

[0034] Preferably, in step S23, the regression loss uses GIoU Loss, which adds a term to calculate the minimum bounding rectangle of the predicted box and the real box to represent the distance between the two boxes after IoU, and specifically:

[0035]

[0036] L GIoU = 1 - GIoU.

[0037] Preferably, during the training process, the learning rate adopts a preheating and cosine annealing strategy, and specifically:

[0038] Assuming that the preheating phase lasts for T rounds, the initial preheating learning rate is η_0, and the final initial learning rate to be reached is η_init, then at the t-th round, the learning rate η_t is:

[0039] η_t = η_0 + (η_init - η_0) * (t / T)

[0040] Set the current training round as i, the end round as epoch, and the final learning rate as η_end, and the learning rate is calculated as:

[0041] η = η_end + (η_init - η_end) * (1 + cos(i / epoch*π)) / 2.

[0042] The improved YOLOv6-based litchi disease and pest detection platform comprises a trained litchi disease and pest detection pt model, a model conversion module, a model quantization module and a model deployment module.

[0043] The trained litchi disease and pest detection pt model is the litchi disease and pest detection pt model in the improved YOLOv6-based litchi disease and pest detection method.

[0044] The model conversion module is used for converting the trained pt model into a general onnx model, performing onnx model pruning, and then converting the onnx model into an rknn model.

[0045] The model quantization module is used for performing ptq quantization on the rknn model, and quantizing the model from a float32 type to an int8 type.

[0046] The model deployment module is used for completing the writing of pre-processing and post-processing codes of the model on an embedded device, calling an API interface of model inference, and deploying the model on a detection platform.

[0047] A processing terminal comprises a memory and a processor, and the memory stores a computer program executable on the processor, and the processor implements the improved YOLOv6-based litchi disease and pest detection method when executing the computer program.

[0048] According to the above technical solution, compared with the prior art, the improved YOLOv6-based litchi disease and pest detection method, detection platform and terminal are provided, which solve the deficiencies of the current disease and pest detection method in real-time performance, accuracy and platform deployment, and through the improved YOLOv6 model adopting advanced deep learning technology, the network structure and algorithm parameters are optimized, the detection speed and accuracy of the model are significantly improved, compared with the current disease and pest detection method, the improved YOLOv6 model can realize faster image processing and more accurate disease and pest identification, thereby providing a high-efficiency and convenient disease and pest monitoring tool for litchi growers.

[0049] In addition, the improved YOLOv6 model also has good generalization ability and robustness, and can work stably under different environments and light conditions, and through deployment on a high-performance and low-power detection platform such as RV112, the model can realize edge computing, that is, data processing and analysis near the data source, reducing the delay and bandwidth requirement of data transmission and improving the response speed of the overall system.

[0050] In summary, the present application proposes to improve the YOLOv6 litchi disease and pest detection model, and realize the deployment on the rv1126 platform, realizing real-time and accurate detection of litchi diseases and pests on the low-cost rv1126 platform, improving the accuracy of the model in detecting litchi diseases and pests and the detection precision of multi-scale targets, greatly improving the intelligent level of litchi orchard production, providing strong technical support for early detection and prevention of litchi diseases and pests, improving litchi yield and quality, and promoting the sustainable development of agriculture. BRIEF DESCRIPTION OF DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings in the following description are only a part of the embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the provided drawings.

[0052] Figure 1 A litchi disease and pest detection method based on improved YOLOv6 provided by the present application is shown in the figure;

[0053] Figure 2 An improved YOLOV6 model structure provided by the present application is shown in the figure;

[0054] Figure 3 A SPBlock module structure provided by the present application is shown in the figure;

[0055] Figure 4 A CSPSPPF module structure provided by the present application is shown in the figure;

[0056] Figure 5 A HALF high-low order fusion module structure provided by the present application is shown in the figure;

[0057] Figure 6 A litchi disease and pest detection platform deployment method based on improved YOLOv6 provided by the present application is shown in the figure. DETAILED DESCRIPTION

[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0059] The present application discloses a litchi disease and pest detection method based on improved YOLOv6, as shown in Figure 1 , comprising the following steps:

[0060] S1. Take and collect images of pests and diseases, annotate them, and construct a litchi pest and disease dataset in a real orchard setting required for training. Use data augmentation technology to enhance the dataset.

[0061] S2. Use the processed dataset to train an improved YOLOV6 model on the PyTorch framework and obtain a trained litchi pest and disease detection PT model by adjusting parameters.

[0062] S3. Collect litchi plant images and input them into the trained litchi pest and disease detection pt model to obtain litchi pest and disease detection results.

[0063] In this embodiment, pest and disease images are captured using a smartphone, and the images are labeled with the pest and disease types and locations using the Labelme software. Finally, a litchi pest and disease dataset is constructed. The annotation file is a txt file with the same name as the image. Each line of data in the annotation file represents a target in the image with the same name. The data annotation content is (class, x, y, h, w), where class is an integer representing the target type number, x and y represent the normalized pixel position of the annotation box center in the corresponding image, and h and w represent the normalized width and height of the annotation box.

[0064] Furthermore, data enhancement technology is used to perform data enhancement operations on the dataset. Specifically, the number of rare pests and diseases datasets is increased by rotating, flipping, adding noise, and adjusting brightness, contrast, and saturation for pests and diseases with a smaller number of images in proportion, so that the dataset tends to be balanced.

[0065] To further implement the above technical solutions, the specific details of the improved YOLOv6 model training process are as follows:

[0066] S21. Read images of litchi pests and diseases and their corresponding labels, preprocess the images and labels into 640*640*3 images using a letterboxing operation, and then input them into the improved YOLOv6 model.

[0067] The letterbox operation is to adjust the size and fill it according to the height and width;

[0068] S22. After the model receives a 640*640 RGB image as input, it uses the improved YOLOv6 model to obtain many predicted detection boxes. The NMS filter removes redundant detection boxes.

[0069] S23. After obtaining the final predicted detection frame, the classification loss and regression loss are calculated respectively with the actual label category and annotation frame, and the model parameters are updated through the backpropagation algorithm to finally obtain the trained litchi pest and disease detection PT model.

[0070] In the embodiment, the letterbox operation preprocessing specifically comprises: first, according to the size of the length and the width, taking the longer side as the reference, scaling according to the proportion, resizing to 640, and the shorter side is scaled according to the proportion, and if less than 640, pixels are supplemented on both sides, and the supplemented pixel value is (114, 114, 114).

[0071] In order to further implement the above technical solutions, the improved YOLOv6 model comprises a backbone network, a neck network and a detection head. Figure 2 The improved YOLOv6 model comprises a backbone network, a neck network and a detection head.

[0072] The backbone network uses EfficientRep and comprises a RepVGGBlock layer and four ERBlock layers in sequence. The size of an input feature map is 640*640, and the number of channels is 3. The feature map is first down-sampled by the RepVGGBlock layer, and the number of channels is expanded from 3 to 32. The height and width of the feature map are changed to 320. Then, the feature map is sequentially subjected to four times of down-sampling by the four ERBlock layers. The feature map is saved after each down-sampling. Finally, the backbone network outputs four feature maps of different sizes as inputs of the neck network. The four feature maps are x3, x2, x1 and x0 in descending order of size.

[0073] The neck network uses RepBiFPANNeck and comprises a convolution layer, an up-sampling module, a down-sampling module, a bidirectional fusion layer, a RepBlock and a HALF high-low order fusion module. The neck network outputs three feature maps of different sizes to the detection head for analysis.

[0074] The detection head uses Efficient decoupled head and is composed of multiple convolution layers. The Efficient decoupled head adopts a mixed channel strategy and predicts the final detection result according to the multi-level features input by the neck. Classification and positioning are decoupled as two branches.

[0075] In order to further implement the above technical solutions, the first three ERBlock layers of the backbone network comprise an improved down-sampling module SPBlock and a RepBlock. The last ERBlock comprises an improved down-sampling module SPBlock, a RepBlock and a CSPSPPF module.

[0076] In order to further implement the above technical solutions, the first three ERBlock layers of the backbone network comprise an improved down-sampling module SPBlock and a RepBlock. The last ERBlock comprises an improved down-sampling module SPBlock, a RepBlock and a CSPSPPF module. Figure 3, SPBlock is used for downsampling, splitting the input feature into two parts in the channel dimension, the Representative part performs convolution to extract important information, specifically, the first part output feature is obtained by adding the convolution results after Group wise grouping convolution and Pointwise point convolution, the Redundant part performs convolution to supplement the implicit detailed information, specifically, the second part output feature is obtained after Point wise point convolution, GAP global average pooling operation is performed on the two part output features respectively, then Stack operation is performed, and the corresponding weight is obtained through softmax, which is used to weight the two part output features respectively, and finally the output is obtained by adding them;

[0077] RepBlock contains multiple RepVGGBlock, which extracts features in depth;

[0078] CSPSPPF module improves SPPF and improves speed while keeping the receptive field unchanged, such as Figure 4 ;

[0079] Specifically: first, the input feature is passed through three convolutions, then divided into two branches, one branch does 1x1 convolution, the other branch does three Maxpool maximum pooling and concatenates them again after two convolutions, then concatenates the results of the first branch convolution, and finally performs 1x1 convolution to obtain the final result.

[0080] To further implement the above technical solutions, the specific content of the neck network outputting three feature maps of different sizes to the detection head for analysis is:

[0081] (1) 1x1 convolution is performed on x0 to reduce the channel number to 1 / 4 of the original, denoted as fpn_out0, and then input into the bidirectional fusion layer together with x1 and x2 for multi-scale feature fusion, and the fused feature after multiple RepBlock extraction is used as a low-order feature, denoted as f_out0;

[0082] (2) 1x1 convolution is performed on f_out0 to reduce the channel number to 1 / 2 of the original, denoted as fpn_out1, and then input into the bidirectional fusion layer together with x2 and x3 for multi-scale fusion again, and then multiple RepBlock is used to obtain a feature layer for detecting small targets as the first output feature map of the neck network, denoted as pan_out2;

[0083] (3) pan_out2 is downsampled and concatenated with fpn_out1 in the channel dimension, and the fused feature after multiple RepBlock extraction is used as a middle-order feature, denoted as pan_out1_tmp;

[0084] (4) Down-sampling the mid-level feature pan_out1_tmp and concatenating it with fpn_out1 in the channel dimension, and the fused feature after multiple RepBlocks is taken as the third output feature map of the neck network, denoted as pan_out0;

[0085] (5) As Figure 5 , the HALF high-low level fusion module fuses the mid-level feature pan_out1_tmp and the low-level feature f_out0 as the second output feature map of the neck network, enhancing the utilization rate of the feature, denoted as pan_out1; Specifically: the pan_out1_tmp and f_out0 are spliced and GAP global average pooling is performed, and then two PWConv point convolutions are performed, and then the activation function Sigmoid is used to obtain the weight corresponding to the original input to obtain two corresponding outputs, and the two outputs are spliced and then processed by PWConv, and then two PWConv processing is performed, and the results are multiplied and activated by the Sigmoid function as weight information, and the original two corresponding outputs are multiplied and added to obtain the final output as the second output feature map pan_out1 of the neck network.

[0086] The label assignment method uses AnchorFree, which determines the position of the target by an anchor-based paradigm, and the regression branch actually predicts the distance from the anchor to the four sides of the box; after obtaining the final predicted detection box, the loss is calculated with the real label, and the model parameters are updated through the back propagation algorithm to make the model prediction more accurate.

[0087] To further implement the above technical solutions, in step S23, the classification loss uses VariFocal Loss, which balances the back propagation learning from two kinds of samples by considering positive and negative samples of different importance, specifically:

[0088]

[0089] Where p is the model predicted IACS, q is the target IoU score, and alpha and gamma are large hyperparameters for negative samples, alpha prevents over-suppression, and gamma reduces the contribution of negative samples.

[0090] To further implement the above technical solutions, in step S23, the regression loss uses GIoULoss, which adds a term to calculate the minimum circumscribed rectangle of the predicted box and the real box after IoU, which is used to represent the distance between the two boxes, specifically:

[0091]

[0092] L GIoU= 1 - GIoU.

[0093] In order to further implement the above technical scheme, in the training process, the learning rate adopts the preheating and cosine annealing strategy, specifically:

[0094] Suppose the preheating phase lasts T rounds, the initial preheating learning rate is η_0, and the final initial learning rate to be reached is η_init, then at the tth round, the learning rate η_t is:

[0095] η_t = η_0 + (η_init - η_0) * (t / T)

[0096] Set the current training round as i, the end round as epoch, and the final learning rate as η_end, and the learning rate calculation is:

[0097] η = η_end + (η_init - η_end) * (1 + cos(i / epoch * π)) / 2.

[0098] The saved result pt model after training is compared with the original model, and the verification result is shown in Table 1 as follows:

[0099] Table 1 shows the comparison of results before and after model improvement:

[0100] mAP@0.5 / % mAP@.5:0.95 / % YOLOv6 81.7 57.4 Improved YOLOv6 83.3 58.7

[0101] A litchi disease and pest detection platform based on an improved YOLOv6, like Figure 6 , comprises a trained litchi disease and pest detection pt model, a model conversion module, a model quantization module and a model deployment module.

[0102] The trained litchi disease and pest detection pt model is a litchi disease and pest detection pt model in a litchi disease and pest detection method based on an improved YOLOv6;

[0103] The model conversion module is used to convert the trained pt model into a general onnx model, and perform onnx model pruning, and then convert it into an rknn model;

[0104] The model quantization module is used to perform ptq quantization on the rknn model, and quantize the model from float32 type to int8 type;

[0105] The model deployment module is used to complete the writing of pre-processing and post-processing codes of the model on the embedded device, call the API interface of model inference, and deploy the model on the detection platform.

[0106] In this embodiment, the detection platform is taken as an rv1126 platform as an example:

[0107] Convert the pt model to onnx model using the appropriate version of the onnx library. In order to adapt to the rv1126 platform, the onnx model needs to be trimmed to retain the six decoupled heads required for classification and regression, and the nodes in the latter part need to be deleted.

[0108] Configure the environment for converting the rknn model, install the rknn-toolkit tool, put about 50 preprocessed image paths in dataset.txt as the calibration dataset, and convert the onnx model to the rknn model.

[0109] The ptq quantization uses the minimum maximum scaling, and the specific formula is as follows:

[0110] scale = (int_max - int_min) / (fp_max - fp_min)

[0111] zero_point = round(-fp_min * scale + int_min)

[0112] quantized_value = round((float_value - fp_min) * scale) + zero_point

[0113] Where quantized_value is the quantized fixed-point number, which is int8 type, float_value is the floating-point number to be quantized, fp_min and fp_max are the minimum and maximum values of float32 range, int_max and int_min are the minimum and maximum values of int8 type, scale is the quantization scaling factor, which is used to scale the range of floating-point numbers to the range of fixed-point numbers, zero_point is the zero point value, which is used to determine the position of the zero point after quantization.

[0114] On the embedded device, use C++ to complete the pre-processing and post-processing code of the model, call the API interface of the model inference, and finally deploy the model on the rv1126 platform.

[0115] The converted rknn model only accepts 640*640*3 input, so the collected images need to be processed by letterbox using C++ code to become 640*640 size, and then input into the rknn model. The model performs inference and outputs six decoupled heads. Post-processing is performed on the six decoupled heads to obtain the final prediction result, and the deployment of the litchi pest model on the rv1126 platform is completed.

[0116] A processing terminal comprises a memory and a processor, the memory stores a computer program capable of running on the processor, and the processor implements a litchi disease and pest detection method based on improved YOLOv6 when executing the computer program.

[0117] The various embodiments are described in the present specification in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be mutually referred to. For the device disclosed by the embodiments, since it corresponds to the method disclosed by the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

[0118] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A litchi pest and disease detection method based on improved YOLOv6, characterized in that: The following steps are involved: S1. Take and collect images of pests and diseases, annotate them, and construct a litchi pest and disease dataset in a real orchard setting required for training. Use data augmentation technology to enhance the dataset. S2. Use the processed dataset to train an improved YOLOv6 model on the PyTorch framework and obtain a trained litchi pest and disease detection PT model by adjusting parameters. S3. Collect litchi plant pictures and input the trained litchi pest and disease detection pt model to obtain litchi pest and disease detection results; The improved YOLOv6 model includes a backbone network, a neck network, and a detection head; The backbone network uses EfficientRep, which includes a RepVGGBlock layer and four ERBlocks. It first goes through a RepVGGBlock layer for downsampling and expands the number of channels. Then it goes through four ERBlocks for downsampling four times. After each downsampling, the feature map is saved. Finally, the backbone network outputs four feature maps of different sizes as the input of the neck network. The four feature maps are x3, x2, x1, and x0 in descending order. The neck network uses RepBiFPANNeck, which includes convolutional layers, upsampling modules, downsampling modules, bidirectional fusion layers, RepBlock, and HALF high- and low-order fusion modules. The neck network outputs three feature maps of different sizes to the detection head for parsing; The detection head uses an efficient decoupled head, which consists of multiple convolutional layers and adopts a hybrid channel strategy. It predicts the final detection result based on the multi-level features of the neck input, and separates classification and localization into two branches for decoupling. The first three ERBlocks of the backbone network include an improved downsampling module SPBlock and RepBlock, and the last ERBlock includes an improved downsampling module SPBlock, RepBlock and a CSPSPPF module; SPBlock is used for downsampling, splitting the input features into two parts in the channel dimension. The representative part performs convolution to extract important information, and the uncertain part performs convolution to supplement implicit detail information. RepBlock contains multiple RepVGGBlocks to perform deep feature extraction; The CSPSPPF module improves SPPF and achieves speed improvement while keeping the receptive field unchanged.

2. A litchi pest and disease detection method based on improved YOLOv6 according to claim 1, characterized in that, The specific details of the improved YOLOv6 model training process are as follows: S21. Read images of litchi pests and diseases and their corresponding labels, preprocess the images and labels into 640*640*3 images using a letterboxing operation, and then input them into the improved YOLOv6 model. S22. After the model receives a 640*640 RGB image as input, it uses the improved YOLOv6 model to obtain many predicted detection boxes. The NMS filter removes redundant detection boxes. S23. After obtaining the final predicted detection frame, the classification loss and regression loss are calculated respectively with the actual label category and annotation frame, and the model parameters are updated through the backpropagation algorithm to finally obtain the trained litchi pest and disease detection PT model.

3. A litchi pest and disease detection method based on improved YOLOv6 according to claim 1, characterized in that, The neck network outputs three feature maps of different sizes to the detection head for analysis: (1) Perform 1x1 convolution on x0 to reduce the number of channels to 1 / 4 of the original, denoted as fpn_out0, and then input it into the bidirectional fusion layer together with x1 and x2 for multi-scale feature fusion. After multiple RepBlocks, the fused features are extracted as low-order features, denoted as f_out0; (2) Perform 1x1 convolution on f_out0 to reduce the number of channels to 1 / 2 of the original number, denoted as fpn_out1, and input it into the bidirectional fusion layer together with x2 and x3 for multi-scale fusion again. After passing through multiple RepBlocks, the feature layer for detecting small targets is obtained as the first output feature map of the neck network, denoted as pan_out2; (3) Downsample pan_out2 and concatenate it with fpn_out1 in the channel dimension. After multiple RepBlocks, the fused features are extracted as mid-order features, recorded as pan_out1_tmp; (4) Downsample the mid-level feature pan_out1_tmp and concatenate it with fpn_out0 in the channel dimension. After multiple RepBlocks, the fused features are extracted as the third output feature map of the neck network, denoted as pan_out0. (5) The HALF high-low order fusion module fuses the mid-order feature pan_out1_tmp and the low-order feature f_out0 as the second output feature map of the neck network, denoted as pan_out1.

4. A litchi pest and disease detection method based on improved YOLOv6 according to claim 2, characterized in that, In step S23, the classification loss uses VariFocal Loss, which balances the back propagation learning from the two samples by considering positive and negative samples of different importance. Specifically: Among them, p is the IACS predicted by the model, q is the target IoU score, α and γ are hyperparameters for large negative samples, α prevents over-suppression, and γ reduces the contribution of negative samples.

5. A litchi pest and disease detection method based on improved YOLOv6 according to claim 2, characterized in that, In step S23, the regression loss uses GIoULoss, and an item is added after IoU to calculate the minimum bounding rectangle of the predicted box and the true box to represent the distance between the two boxes.

6. A litchi pest and disease detection method based on improved YOLOv6 according to claim 2, characterized in that, During the training process, the learning rate adopts the warm-up and cosine annealing strategy, specifically: Assuming the warm-up phase lasts T rounds, the initial warm-up learning rate is η_0, and the final initial learning rate is η_init, then in the tth round, the learning rate η_t is: η_t=η_0+(η_init-η_0)×(t / T) Set the current training round number to i, the end round to epoch, and the final learning rate to η_end. The learning rate is calculated as: η=η_end+(η_init-η_end)*(1+cos(i / epoch*π)) / 2.

7. A litchi pest and disease detection platform based on improved YOLOv6, characterized in that: include: Trained litchi pest and disease detection PT model, model conversion module, model quantification module and model deployment module; The trained litchi pest and disease detection pt model is the litchi pest and disease detection pt model in the litchi pest and disease detection method based on improved YOLOv6 according to any one of claims 1 to 6; The model conversion module is used to convert the trained pt model into a general onnx model, perform onnx model cropping, and then convert it into a rknn model; The model quantization module is used to perform ptq quantization on the rknn model, converting the model from float32 type to int8 type; The model deployment module is used to complete the writing of model pre-processing and post-processing code on embedded devices, call the API interface of model inference, and deploy the model on the detection platform.

8. A processing terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the method for detecting litchi pests and diseases based on the improved YOLOv6 is implemented as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Litchi disease and insect pest detection method based on improved EfficentDet

    CN114898359A

  • Litchi disease real-time detection system and method based on edge calculation and yolov7-tiny

    CN116824369A