Tomato plant disease and pest detection method and detection system
By improving the pest and disease detection method based on the YOLOv7 model and combining it with the XSepConv module and WeChat mini-program, the problems of accuracy and computational resource limitations of traditional methods have been solved, and lightweight, fast and real-time pest and disease detection has been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2026-03-27
AI Technical Summary
In the detection of diseases and pests in tomato plants, existing technologies have low accuracy and reliability due to traditional image processing methods, while deep learning methods require a large amount of computing resources and are difficult to detect in real time, making them difficult to implement on mobile devices.
Based on the YOLOv7 model, the number of channels was reduced and replaced with the XSepConv module. Combined with various feature extraction techniques, a lightweight pest and disease detection model was constructed and implemented using a WeChat mini program.
It enables fast, real-time, and accurate pest and disease detection on mobile devices, reduces computational load, improves detection accuracy and reliability, is easy to operate, and is suitable for WeChat mini-program applications.
Smart Images

Figure CN116977863B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of target recognition, in particular to a tomato plant disease and pest detection method and a detection system. BACKGROUND
[0002] Agricultural planting often faces serious disease and pest problems. For example, in the process of tomato planting, powdery mildew, early blight, late blight, gray mold, leaf mold, root knot nematode disease, and fruit cracking seriously affect the normal growth and harvesting of crops, and bring great challenges to the planting and management of growers and horticultural enthusiasts. In order to solve this problem, some plant disease and pest detection products have appeared on the market, some of which are based on traditional image processing technology, and others use deep learning technology for image recognition and classification. Traditional image processing methods are usually based on hand-designed feature extractors and classifiers, which have low accuracy and reliability, require a lot of manual intervention and adjustment, and are difficult to adapt to complex and variable actual situations. Methods based on deep learning technology can automatically extract features and classify, with higher accuracy and robustness, but require a large amount of labeled data and computing resources, and have too many model parameters, making it difficult to achieve fast and real-time detection on mobile devices. SUMMARY
[0003] The purpose of the present application is to overcome the shortcomings of the prior art, provide a lightweight and high-performance tomato plant disease and pest detection method, and a tomato plant disease and pest detection system that uses and implements the detection method, to achieve fast detection and accurate identification of tomato plant diseases and pests, and provide convenient and efficient technical support for agricultural production.
[0004] The present application is achieved by the following technical solutions:
[0005] A tomato plant disease and pest detection method, comprising the following steps:
[0006] S1. On the basis of YOLOv7, reduce the number of channels in the YOLOv7 model, and replace the Conv module in the YOLOv7 backbone network with an XSepConv module to obtain a YOLOv7-XSepConv model as a target detection model;
[0007] S2. Collect tomato plant pictures with different types of diseases and pests to form a training data set, set parameters, train the target detection model, and save the model parameters until the model converges;
[0008] S3. After the detection picture is preprocessed, it is input into the trained target detection model to obtain a detection result, achieving identification and classification of diseases and pests.
[0009] Further, the XSepConv module comprises sequentially connected: a 1x1 expansion convolution for expanding the number of input channels to a higher dimension; a batch normalization, an activation function; a 2x2 DW convolution for performing a convolution operation between channels within a group; a batch normalization, an activation function; a 1xK DW convolution, performing a convolution operation in the channel dimension and having a stride in the spatial dimension; a batch normalization, an activation function; a Kx1 DW convolution, performing a convolution operation in the channel dimension and having different convolution kernel sizes in the spatial dimension; a batch normalization; a Squeeze-and-Excitation (SE) module for feature re-labeling in the channel dimension; a 1x1 output convolution for reducing the number of feature mappings to the required output size; a batch normalization.
[0010] Further, K=3 in the XSepConv module, and the backbone network of the YOLOv7-XSepConv model comprises 41 lightweight convolution blocks XSepConv, wherein each convolution block structure is as follows:
[0011] The first lightweight convolution block XSepConv1: the input channel number of the 1x1 expansion convolution is 3, and the output channel number is 16; the input channel number of the DW convolution, the SE module, and the 1x1 output convolution is 16, and the output channel number is 16; the channel number of the batch normalization is 16, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0012] The second lightweight convolution block XSepConv2: the input channel number of the 1x1 expansion convolution is 16, and the output channel number is 32; the input channel number of the DW convolution, the SE module, and the 1x1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0013] The third lightweight convolution block XSepConv3: the input channel number of the 1x1 expansion convolution is 32, and the output channel number is 32; the input channel number of the DW convolution, the SE module, and the 1x1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0014] The fourth lightweight convolution block XSepConv4: the input channel number of the 1x1 expansion convolution is 32, and the output channel number is 64; the input channel number of the DW convolution, the SE module, and the 1x1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0015] The 5th lightweight convolutional block XSepConv5, the 6th lightweight convolutional block XSepConv6 are: the input channel number of the 1*1 expansion convolution is 64, the output channel number is 32; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0016] The 7th lightweight convolutional block XSepConv7, the 8th lightweight convolutional block XSepConv8, the 9th lightweight convolutional block XSepConv9 and the 10th lightweight convolutional block XSepConv10 are: the input channel number of the 1*1 expansion convolution is 32, the output channel number is 32; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0017] The 11th lightweight convolutional block XSepConv11: the input channel number of the 1*1 expansion convolution is 128, the output channel number is 128; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0018] The 12th lightweight convolutional block XSepConv12 and the 13th lightweight convolutional block XSepConv13 are: the input channel number of the 1*1 expansion convolution is 128, the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0019] The 14th lightweight convolutional block XSepConv14: the input channel number of the 1*1 expansion convolution is 64, the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0020] The 15th lightweight convolutional block XSepConv15 and the 16th lightweight convolutional block XSepConv16 are: the input channel number of the 1*1 expansion convolution is 128, the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is LeakyReLU function with a complex slope of 0.1;
[0021] The 17th lightweight convolutional block XSepConv17, the 18th lightweight convolutional block XSepConv18, the 19th lightweight convolutional block XSepConv19, and the 20th lightweight convolutional block XSepConv20 are as follows: the input channel number of the 1*1 expansion convolution is 64, and the output channel number is 64; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0022] The 21st lightweight convolutional block XSepConv21: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 256; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 256, and the output channel number is 256; the channel number of the batch normalization is 256, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0023] The 22nd lightweight convolutional block XSepConv22 and the 23rd lightweight convolutional block XSepConv23 are as follows: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0024] The 24th lightweight convolutional block XSepConv24: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0025] The 25th lightweight convolutional block XSepConv25 and the 26th lightweight convolutional block XSepConv26 are as follows: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0026] The 27th lightweight convolutional block XSepConv27, the 28th lightweight convolutional block XSepConv28, the 29th lightweight convolutional block XSepConv29, and the 30th lightweight convolutional block XSepConv30 are as follows: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0027] The 31st lightweight convolutional block XSepConv31: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 512; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 512, and the output channel number is 512; the channel number of the batch normalization is 512, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0028] The 32nd lightweight convolutional block XSepConv32 and the 33rd lightweight convolutional block XSepConv33 are as follows: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 256; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 256, and the output channel number is 256; the channel number of the batch normalization is 256, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0029] The 34th lightweight convolutional block XSepConv34: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 256; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 256, and the output channel number is 256; the channel number of the batch normalization is 256, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0030] The 35th lightweight convolutional block XSepConv35 and the 36th lightweight convolutional block XSepConv36 are as follows: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1;
[0031] The 37th lightweight convolutional block XSepConv37, the 38th lightweight convolutional block XSepConv38, the 39th lightweight convolutional block XSepConv39, and the 40th lightweight convolutional block XSepConv40 are as follows: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1.
[0032] The 41st lightweight convolutional block XSepConv41: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 512; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is 512, and the output channel number is 512; the channel number of the batch normalization is 512, and the activation function layer is a LeakyReLU function with a complex slope of 0.1.
[0033] Further, the channel number of the backbone network of the YOLOv7-XSepConv model is half of the channel number of the backbone network of the conventional YOLOv7 model.
[0034] Further, the image preprocessing step in the S3 step includes image denoising, image enhancement, image segmentation, image graying, image normalization, and image binarization.
[0035] Further, the image enhancement adopts a histogram equalization or a filtering technique, the image segmentation adopts a color segmentation or a threshold segmentation technique to separate the tomato plants from the background in the image, and the image normalization is used for uniform size processing of the image.
[0036] Further, the to-be-detected image in the S3 step is obtained by cropping and rotating a photographed image; and the types of the diseases and pests in the tomato plant image in the S2 step include cold damage, disease, early blight, split fruit, TY virus, potassium deficiency, and powdery mildew.
[0037] Further, the learning rate during the model training in the S2 step adopts a cosine annealing automatic adjustment learning rate, the initial value learning rate is set to 0.001, and the iteration number is set to 300.
[0038] A tomato plant disease and pest detection system for implementing the above tomato plant disease and pest detection method, comprising:
[0039] A front-end user interface part for photographing, processing, and uploading a to-be-detected image, and displaying and outputting a detection result;
[0040] An image preprocessing part for preprocessing the uploaded to-be-detected image;
[0041] Target detection part: based on the target detection model algorithm, the pre-processed picture to be detected is subjected to target detection, realizing the identification and classification of tomato plant diseases and insect pests;
[0042] Database part: for storing detection result data.
[0043] Further, the front-end user interface part is configured on the application program of the intelligent terminal, the image preprocessing part and the target detection part are configured on the background server of the application program, and the background server is used for data interaction and communication between the front end and the back end, including data interaction with the database.
[0044] Further, the intelligent terminal is a mobile phone, and the application program is a WeChat mini program.
[0045] The use method of the whole detection system is simple, the user only needs to upload the plant photo, the back-end server will automatically perform image preprocessing and disease and pest detection, and the result is fed back to the user, and the user can view the detection result through the front-end interface. The whole system can be developed by using the WeChat mini program, and the user can use it anytime and anywhere, which is convenient and practical. The advantages mainly include:
[0046] Efficient and accurate: the target detection algorithm in deep learning is adopted, combined with various feature extraction techniques and classification algorithms, which can efficiently and accurately detect the diseases and insect pests on the tomato plants, and provide more timely prevention measures for farmers.
[0047] Simple and easy to use: the user only needs to upload the tomato plant photo, the system will automatically perform preprocessing and detection, and the result will be displayed to the user in real time, which is simple and easy to use.
[0048] Data visualization: through the Web server technology, the detection result can be transmitted to the browser end of the user in real time, which is convenient for the user to view and analyze.
[0049] Data management: the relational database technology is adopted, which can efficiently store and manage a large amount of data, and provide support for subsequent query and statistical analysis.
[0050] The improved YOLOv7 model algorithm is adopted, the model parameters are reduced, the Conv module in the YOLOv7 backbone network is replaced by the XSepConv module, the model size is reduced, the calculation load is reduced, which helps to improve the running speed of the model, and the fast and real-time target detection can be realized under limited computing resources, so that the application of target detection in the mini program is more suitable and efficient. This optimization has important significance for the application scene of the WeChat mini program, which can meet the needs of users for fast and real-time target detection, and improve the user experience.
[0051] The present application can further improve the accuracy and reliability of detection by designing a lightweight and high-performance pest detector, combined with technical means such as WeChat applets, while having the advantages of low cost, simple operation, and realizing the intelligentization and convenience of the tomato plant pest detection system. Compared with traditional image processing methods and other deep learning technology-based methods, the present application has advantages in accuracy, reliability, cost, and operation simplicity, and can better meet the needs of users. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 A block diagram of a backbone network Backbone of a target detection model YOLOv7-XSepConv in an embodiment of the present application.
[0053] Figure 2 A structural block diagram of an XSepConv module in a target detection model in an embodiment of the present application.
[0054] Figure 3 Picture examples of plant pests collected during model training in an embodiment of the present application.
[0055] Figure 4 A structural block diagram of a detection system in an embodiment of the present application.
[0056] Figure 5 A detection flowchart of a detection system in an embodiment of the present application.
[0057] Figure 6 A schematic diagram of a front-end user interface part of a detection system in an embodiment of the present application. DETAILED DESCRIPTION
[0058] A tomato plant pest detection method, comprising the following steps:
[0059] S1, constructing a target detection model
[0060] On the basis of YOLOv7, the number of channels in the YOLOv7 model is reduced, as shown in Figure 1 and the Conv module in the YOLOv7 backbone network (Backbone) is replaced with an XSepConv module to obtain a YOLOv7-XSepConv model as a target detection model.
[0061] The purpose of the present application is to realize lightweight and high-performance pest detection. In order to reduce the size of the model, the present application improves the YOLOv7 model. YOLOv7 is a popular target detection model, but when applied on terminals such as mobile devices, the model size and computing resource requirements are limiting factors. Therefore, the present application reduces the number of channels in the YOLOv7 model, thereby reducing the number of model parameters, making it suitable for real-time detection on mobile devices. However, the reduction of the number of channels can cause problems such as insufficient global information acquisition, image redundant information retention, and insufficient attention. In order to solve these problems, the present application replaces the Conv module in the YOLOv7 backbone network with the XSepConv module. The specific method can be as follows: first, write the XSepConv module code into the common.py configuration file of the YOLOv7 model, then self-build a yaml file, and replace the Conv structure in the back bone with the XSepConv structure in the original yolov7.yaml file.
[0062] XSepConv is a lightweight convolution composed of multiple convolution layers, with fewer parameters and computational complexity. As shown in Figure 2 The structure of the XSepConv module specifically includes the following sequentially connected:
[0063] 1×1 expansion convolution, used to expand the number of input channels to a higher dimension;
[0064] Batch Normalization (Batch Normalization), activation function, to enhance the representation ability of features;
[0065] 2×2 DW convolution (Depthwise Convolution), used to perform convolution operations between channels within the group, reducing the computational complexity;
[0066] Batch Normalization, activation function, to further improve the feature expression ability;
[0067] 1×K DW convolution, performing convolution operations in the channel dimension and having a stride in the spatial dimension, reducing the size of the feature map; K is the size of the convolution kernel, which can be set according to specific circumstances, such as 3, which is a 1×3 DW convolution. DW (Depthwise Convolution) convolution refers to convolution in the channel number only, without changing the channel number, commonly used in lightweight models. Compared with ordinary convolution, DW convolution has the advantages of fewer parameters and less computational complexity.
[0068] Batch Normalization, activation function;
[0069] Kx1 DW convolution, performing convolution operation in channel dimension and having different convolution kernel size in spatial dimension;
[0070] Batch normalization;
[0071] Squeeze-and-Excitation (SE) module for feature reparametrization in channel dimension, enhancing the expression of important features;
[0072] 1x1 output convolution for reducing the number of channels of feature mapping to the required output size;
[0073] Batch normalization to improve the accuracy of feature representation.
[0074] Specifically, K=3 in the XSepConv module, and the backbone network of the YOLOv7-XSepConv model includes 41 lightweight convolution blocks XSepConv, wherein each convolution block structure is as follows:
[0075] The first lightweight convolution block XSepConv1 includes:
[0076] The input channel number of the 1x1 expansion convolution is 3, the output channel number is 16, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 16, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0077] The input channel number of the 2x2 DW convolution is 16, the output channel number is 16, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 16, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0078] The input channel number of the 1xK DW convolution is 16, the output channel number is 16, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 16, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0079] The input channel number of the Kx1 DW convolution is 16, the output channel number is 16, the DW convolution kernel size is 3x1, and one batch normalization layer with a channel number of 16;
[0080] The input channel number of the Squeeze-and-Excitation (SE) module is 16, the output channel number of the SE module is 16, and one batch normalization layer with a channel number of 16;
[0081] The input channel number of the 1x1 output convolution is 16, the output channel number is 16, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 16.
[0082] The second lightweight convolutional block XSepConv2 includes:
[0083] The 1*1 expansion convolution has an input channel number of 16, an output channel number of 32, a convolution kernel size of 1*1, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0084] The 2*2 DW convolution has an input channel number of 32, an output channel number of 32, a DW convolution kernel size of 2*2, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0085] The 1*K DW convolution has an input channel number of 32, an output channel number of 32, a DW convolution kernel size of 1*3, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0086] The K*1 DW convolution has an input channel number of 32, an output channel number of 32, a DW convolution kernel size of 3*1, and a batch normalization layer with a channel number of 16;
[0087] The Squeeze-and-Excitation (SE) module has an input channel number of 32, an output channel number of 32, an SE module, and a batch normalization layer with a channel number of 32;
[0088] The 1*1 output convolution has an input channel number of 32, an output channel number of 32, a convolution kernel size of 1*1, and a batch normalization layer with a channel number of 32.
[0089] The third lightweight convolutional block XSepConv3 includes:
[0090] The 1*1 expansion convolution has an input channel number of 32, an output channel number of 32, a convolution kernel size of 1*1, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0091] The 2*2 DW convolution has an input channel number of 32, an output channel number of 32, a DW convolution kernel size of 2*2, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0092] The 1*K DW convolution has an input channel number of 32, an output channel number of 32, a DW convolution kernel size of 1*3, a batch normalization layer with a channel number of 32, and a LeakyReLU activation function layer with a complex slope of 0.1;
[0093] The input channel number of the 3x3 convolution is 32, the output channel number is 32, the convolution kernel size is 3x3, and one batch normalization layer with a channel number of 32;
[0094] The input channel number of the Squeeze-and-Excitation (SE) module is 32, the output channel number is 32, and one batch normalization layer with a channel number of 32;
[0095] The input channel number of the 1x1 output convolution is 32, the output channel number is 32, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 32.
[0096] The fourth lightweight convolution block XSepConv4 includes:
[0097] The input channel number of the 1x1 expansion convolution is 32, the output channel number is 64, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 64, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0098] The input channel number of the 2x2 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 64, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0099] The input channel number of the 1xK DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 64, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0100] The input channel number of the Kx1 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 3x1, one batch normalization layer with a channel number of 16;
[0101] The input channel number of the Squeeze-and-Excitation (SE) module is 64, the output channel number is 64, and one batch normalization layer with a channel number of 64;
[0102] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0103] The structures of the fifth lightweight convolution block XSepConv5 and the sixth lightweight convolution block XSepConv6 both include:
[0104] The input channel number of the 1*1 expansion convolution is 64, the output channel number is 32, the convolution kernel size is 1*1, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0105] The input channel number of the 2*2 DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 2*2, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0106] The input channel number of the 1*K DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 1*3, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0107] The input channel number of the K*1 DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 3*1, and there is a batch normalization layer with a channel number of 16;
[0108] The input channel number of the Squeeze-and-Excitation (SE) module is 32, the output channel number of the SE module is 32, and there is a batch normalization layer with a channel number of 32;
[0109] The input channel number of the 1*1 output convolution is 32, the output channel number is 32, the convolution kernel size is 1*1, and there is a batch normalization layer with a channel number of 32.
[0110] The structure of the 7th lightweight convolution block XSepConv7, the 8th lightweight convolution block XSepConv8, the 9th lightweight convolution block XSepConv9, and the 10th lightweight convolution block XSepConv10 all includes:
[0111] The input channel number of the 1*1 expansion convolution is 32, the output channel number is 32, the convolution kernel size is 1*1, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0112] The input channel number of the 2*2 DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 2*2, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0113] The input channel number of the 1*K DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 1*3, there is a batch normalization layer with a channel number of 32, and there is a LeakyReLU activation function layer with a complex slope of 0.1;
[0114] The input channel number of the 3x1 DW convolution is 32, the output channel number is 32, the DW convolution kernel size is 3x1, and one batch normalization layer with a channel number of 16;
[0115] The input channel number of the Squeeze-and-Excitation (SE) module is 32, the output channel number is 32, and one batch normalization layer with a channel number of 32;
[0116] The input channel number of the 1x1 output convolution is 32, the output channel number is 32, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 32.
[0117] The 11th lightweight convolution block XSepConv11 includes:
[0118] The input channel number of the 1x1 expansion convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0119] The input channel number of the 2x2 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0120] The input channel number of the 1xK DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0121] The input channel number of the Kx1 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 3x1, one batch normalization layer with a channel number of 16;
[0122] The input channel number of the Squeeze-and-Excitation (SE) module is 128, the output channel number is 128, and one batch normalization layer with a channel number of 128;
[0123] The input channel number of the 1x1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 128.
[0124] The structures of the 12th lightweight convolution block XSepConv12 and the 13th lightweight convolution block XSepConv13 both include:
[0125] The input channel number of the 1x1 expansion convolution is 128, the output channel number is 64, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0126] The input channel number of the 2x2 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0127] The input channel number of the 1xK DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0128] The input channel number of the Kx1 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0129] The input channel number of the Squeeze-and-Excitation (SE) module is 64, the output channel number of the SE module is 64, and there is one batch normalization layer with a channel number of 64;
[0130] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and there is one batch normalization layer with a channel number of 64.
[0131] The 14th lightweight convolution block XSepConv14 includes:
[0132] The input channel number of the 1x1 expansion convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0133] The input channel number of the 2x2 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0134] The input channel number of the 1xK DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0135] The input channel number of the Kx1 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0136] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0137] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0138] The structure of the 15th lightweight convolutional block XSepConv15 and the 16th lightweight convolutional block XSepConv16 both includes:
[0139] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0140] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0141] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0142] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0143] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0144] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 64.
[0145] The structure of the 17th lightweight convolutional block XSepConv17, the 18th lightweight convolutional block XSepConv18, the 19th lightweight convolutional block XSepConv19, and the 20th lightweight convolutional block XSepConv20 all includes:
[0146] The input channel number of the 1x1 expansion convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0147] The input channel number of the 2x2 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0148] The input channel number of the 1xK DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 64, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0149] The input channel number of the Kx1 DW convolution is 64, the output channel number is 64, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0150] The input channel number of the Squeeze-and-Excitation (SE) module is 64, the output channel number of the SE module is 64, and there is one batch normalization layer with a channel number of 64;
[0151] The input channel number of the 1x1 output convolution is 64, the output channel number is 64, the convolution kernel size is 1x1, and there is one batch normalization layer with a channel number of 64.
[0152] The 21st lightweight convolution block XSepConv21 includes:
[0153] The input channel number of the 1x1 expansion convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0154] The input channel number of the 2x2 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0155] The input channel number of the 1xK DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0156] The input channel number of the Kx1 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16.
[0157] The input channel number of the 1x1 output convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 256;
[0158] The input channel number of the 1x1 output convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 256;
[0159] The structure of the 22nd lightweight convolutional block XSepConv22 and the 23rd lightweight convolutional block XSepConv23 both include:
[0160] The input channel number of the 1x1 expansion convolution is 256, the output channel number is 128, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0161] The input channel number of the 2x2 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0162] The input channel number of the 1xK DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0163] The input channel number of the Kx1 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 3x1, and one batch normalization layer with a channel number of 16;
[0164] The input channel number of the Squeeze-and-Excitation (SE) module is 128, the output channel number of the SE module is 128, and one batch normalization layer with a channel number of 128;
[0165] The input channel number of the 1x1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 128.
[0166] The 24th lightweight convolutional block XSepConv24 includes:
[0167] The input channel number of the 1x1 expansion convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1;
[0168] 2x2 DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 2x2, one batch normalization layer with channel number 128, one LeakyReLU activation function layer with complex slope 0.1;
[0169] 1xK DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 1x3, one batch normalization layer with channel number 128, one LeakyReLU activation function layer with complex slope 0.1;
[0170] Kx1 DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 3x1, one batch normalization layer with channel number 16;
[0171] Squeeze-and-Excitation (SE) module, input channel number 128, output channel number 128 of SE module, one batch normalization layer with channel number 128;
[0172] 1x1 output convolution, input channel number 128, output channel number 128, convolution kernel size 1x1, one batch normalization layer with channel number 128.
[0173] The structure of the 25th lightweight convolutional block XSepConv25 and the 26th lightweight convolutional block XSepConv26 both includes:
[0174] 1x1 expansion convolution, input channel number 256, output channel number 128, convolution kernel size 1x1, one batch normalization layer with channel number 128, one LeakyReLU activation function layer with complex slope 0.1;
[0175] 2x2 DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 2x2, one batch normalization layer with channel number 128, one LeakyReLU activation function layer with complex slope 0.1;
[0176] 1xK DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 1x3, one batch normalization layer with channel number 128, one LeakyReLU activation function layer with complex slope 0.1;
[0177] Kx1 DW convolution, input channel number 128, output channel number 128, DW convolution kernel size 3x1, one batch normalization layer with channel number 16;
[0178] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0179] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0180] The structure of the 27th lightweight convolutional block XSepConv27, the 28th lightweight convolutional block XSepConv28, the 29th lightweight convolutional block XSepConv29, and the 30th lightweight convolutional block XSepConv30 includes:
[0181] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0182] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0183] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0184] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0185] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0186] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0187] The 31st lightweight convolutional block XSepConv31 includes:
[0188] The input channel number of the 1*1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1*1, and one batch normalization layer with a channel number of 128.
[0189] The input channel number of the 2x2 DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 512, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0190] The input channel number of the 1xK DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 512, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0191] The input channel number of the Kx1 DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0192] The input channel number of the Squeeze-and-Excitation (SE) module is 512, and there is one SE module with an output channel number of 512, one batch normalization layer with a channel number of 512;
[0193] The input channel number of the 1x1 output convolution is 512, the output channel number is 512, the convolution kernel size is 1x1, and there is one batch normalization layer with a channel number of 512.
[0194] The structures of the 32nd lightweight convolution block XSepConv32 and the 33rd lightweight convolution block XSepConv33 both include:
[0195] The input channel number of the 1x1 expansion convolution is 512, the output channel number is 256, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0196] The input channel number of the 2x2 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0197] The input channel number of the 1xK DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 256, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0198] The input channel number of the Kx1 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0199] The input channel number of the 1x1 output convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 256.
[0200] The input channel number of the 1x1 output convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 256.
[0201] The 34th lightweight convolution block XSepConv34 includes:
[0202] The input channel number of the 1x1 expansion convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 256, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0203] The input channel number of the 2x2 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 256, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0204] The input channel number of the 1xK DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 256, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0205] The input channel number of the Kx1 DW convolution is 256, the output channel number is 256, the DW convolution kernel size is 3x1, one batch normalization layer with a channel number of 16.
[0206] The input channel number of the 1x1 expansion convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 256, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0207] The input channel number of the 1x1 output convolution is 256, the output channel number is 256, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 256.
[0208] The structure of the 35th lightweight convolution block XSepConv35 and the 36th lightweight convolution block XSepConv36 includes:
[0209] The input channel number of the 1x1 expansion convolution is 512, the output channel number is 128, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 128, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0210] The input channel number of the 2x2 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 128, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0211] The input channel number of the 1xK DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 128, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0212] The input channel number of the Kx1 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0213] The input channel number of the Squeeze-and-Excitation (SE) module is 128, the output channel number of the SE module is 128, and there is one batch normalization layer with a channel number of 128;
[0214] The input channel number of the 1x1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, and there is one batch normalization layer with a channel number of 128.
[0215] The structure of the 37th lightweight convolution block XSepConv37, the 38th lightweight convolution block XSepConv38, the 39th lightweight convolution block XSepConv39, and the 40th lightweight convolution block XSepConv40 all include:
[0216] The input channel number of the 1x1 expansion convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, there is one batch normalization layer with a channel number of 128, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0217] The input channel number of the 2x2 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 2x2, there is one batch normalization layer with a channel number of 128, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0218] The input channel number of the 1xK DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 1x3, there is one batch normalization layer with a channel number of 128, and there is one LeakyReLU activation function layer with a complex slope of 0.1;
[0219] The input channel number of the Kx1 DW convolution is 128, the output channel number is 128, the DW convolution kernel size is 3x1, and there is one batch normalization layer with a channel number of 16;
[0220] The input channel number of the squeeze-and-excitation (SE) module is 128, the output channel number of the SE module is 128, and one batch normalization layer with a channel number of 128;
[0221] The input channel number of the 1x1 output convolution is 128, the output channel number is 128, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 128.
[0222] The 41st lightweight convolution block XSepConv41 includes:
[0223] The input channel number of the 1x1 expansion convolution is 512, the output channel number is 512, the convolution kernel size is 1x1, one batch normalization layer with a channel number of 512, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0224] The input channel number of the 2x2 DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 2x2, one batch normalization layer with a channel number of 512, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0225] The input channel number of the 1xK DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 1x3, one batch normalization layer with a channel number of 512, and one LeakyReLU activation function layer with a complex slope of 0.1.
[0226] The input channel number of the Kx1 DW convolution is 512, the output channel number is 512, the DW convolution kernel size is 3x1, and one batch normalization layer with a channel number of 16.
[0227] The input channel number of the squeeze-and-excitation (SE) module is 512, the output channel number of the SE module is 512, and one batch normalization layer with a channel number of 512.
[0228] The input channel number of the 1x1 output convolution is 512, the output channel number is 512, the convolution kernel size is 1x1, and one batch normalization layer with a channel number of 512.
[0229] The channel number of the backbone network of the YOLOv7-XSepConv model can be set to half of the channel number of the backbone network in the conventional YOLOv7 model. By reducing the channel number, the complexity and parameter amount of the model can be reduced, and thus the computing resources required when running on the WeChat mini-program are reduced. Such optimization measures help to improve the running speed of the model, making the target detection more efficient in the mini-program.
[0230] The lightweight design of the XSepConv module reduces the number of model parameters and the computational complexity, while maintaining a high feature representation capability, thereby achieving higher performance in pest and disease detection. The XSepConv module replaces the Conv module in the YOLOv7 model, which uses 1x1 extended convolution, 2x2 DW convolution, and 1xK, Kx1 DW convolution operations to extract features and perform convolution operations. This replacement can further reduce the size of the model and reduce the computational load, achieving faster target detection speed; at the same time, the XSepConv module maintains a high feature representation capability, which can also improve the accuracy and reliability of detection, thereby achieving higher performance in pest and disease detection.
[0231] Thus, by reducing the number of model parameters and replacing the Conv module, the accuracy and reliability of detection are further improved, while having the advantages of low cost and simple operation. Compared with traditional image processing methods and other methods based on deep learning technology, the present application has advantages in accuracy, reliability, cost, and ease of operation, and can better meet the needs of users.
[0232] In this embodiment, the YOLOv7-XSepConv model uses the Adam optimizer, and the activation function is the FReLU activation function and the sigmoid function. YOLOv7 is based on anchor based, and its positive and negative sample assignment strategy is a combination of the positive and negative sample assignment strategies in YOLOv5 and YOLOX, and the process is as follows:
[0233] ① YOLOv5: uses the YOLOv5 positive and negative sample assignment strategy to assign positive samples.
[0234] ② YOLOX: calculates the Reg+Cla loss (Loss aware) of each sample for each GT.
[0235] ③ YOLOX: uses the predicted sample of each GT to determine the number of positive samples it needs to assign (Dynamic k)
[0236] ④ YOLOX: takes the first dynamic k samples with the smallest loss for each GT as positive samples
[0237] ⑤ YOLOX: manually removes the case where the same sample is assigned to multiple GT positive samples (global information)
[0238] The first step in simOTA, "use center prior", is replaced by "YOLOv5 strategy". The fusion of YOLOv5 strategy and simOTA strategy in YOLOX, compared with only using YOLOv5 strategy, adds loss aware, which can further refine the model based on the current performance. Compared with only using simOTA in YOLOX, the fusion strategy can provide more accurate prior knowledge.
[0239] S2, model training
[0240] Collect pictures of tomato plants with different types of diseases and pests, including cold damage, insect disease, early blight, leaf mildew, early blight, fruit cracking, TY virus, potassium deficiency, and powdery mildew, etc. Figure 3 As shown in Figure 3 (a) is a plant picture of powdery mildew, Figure 3 (b) is a plant picture of insect damage, Figure 3 (c) is a plant picture of cold damage, Figure 3 (d) is a plant picture of fruit cracking, Figure 3 (e) is a plant picture of potassium deficiency, Figure 3 (f) is a plant picture of early blight, and the rest is not listed one by one. These pictures constitute a training data set. Label the pictures in the data set using tools such as LabelImg. Input the pictures into the model, set the parameters, and train the target detection model until the model converges and save the model parameters.
[0241] The learning rate of model training is automatically adjusted. The initial value of lr can be set to 0.001, and the cosine annealing scheduler is used as the preset learning rate strategy. Cosine annealing scheduler is a common learning rate scheduling strategy that adjusts the learning rate at each training step (or epoch) according to a predetermined learning plan. Change the learning rate during the training period, use a larger learning rate at the beginning of training, and then gradually reduce it. The number of iterations can be set to 300.
[0242] S3, target detection
[0243] After preprocessing, the detected picture is input into the trained target detection model to obtain the detection result, realizing the recognition and classification of diseases and pests.
[0244] The detected picture is a real-time shooting picture, which can also be a picture obtained by other means (such as local files). The detected picture can be cropped, rotated, etc. before uploading according to its acquisition path or picture quality.
[0245] The steps of picture preprocessing mainly include image enhancement, image segmentation and image normalization, and image denoising can also be performed according to actual conditions, so as to convert the input image into a form acceptable by the model.
[0246] a. Image enhancement: histogram equalization, filtering and other techniques are used to enhance the contrast and clarity of the image, improve the image quality, and make the model more accurate in recognition;
[0247] b. Image segmentation: color segmentation, threshold segmentation and other techniques are used to separate the tomato plants from the background in the image, reducing the interference of the background;
[0248] c. Image normalization: the image is uniformly processed in size, such as converting the picture to 640*640, to avoid the influence of pictures of different sizes on target detection.
[0249] S4, store the detection result data for subsequent display, statistical analysis and traceability.
[0250] The data in the test data set is input into the trained model of the application for detection. In this embodiment, there are 182 pictures in the test set, and 544 targets are labeled. The test results are shown in Table 1.
[0251] Table 1 Evaluation table of target detection model
[0252]
[0253]
[0254] As can be seen from Table 1, the target recognition model has good performance, and the detection accuracy rate for various diseases and pests is generally above 0.75, and even some species can reach 0.85, the average accuracy rate of all categories is 0.775, the average precision of all categories mAP@0.5 is 0.713, the average recall rate reaches 0.671, and individual disease and pest species can reach above 0.75. It shows that the recognition rate of the target recognition model of the application is high, which can accurately identify the types of tomato diseases and pests, meet the use requirements, and provide strong technical reference for the growers.
[0255] A tomato plant disease and pest detection system for implementing the above tomato plant disease and pest detection method, such as Figure 3As shown, it includes a front-end user interface part, an image preprocessing part, a target detection part, a database part, and a server part. The front-end user interface part is configured on an application program of a smart terminal, which can be a mobile phone, a tablet, a computer, or an embedded terminal. The application program can be a WeChat mini program. The WeChat mini program usually runs on a mobile device with limited computing resources and processing capabilities. Therefore, in order to ensure the smoothness of the operation of the mini program and the user experience, the model algorithm of the target detection part needs to be as small as possible in size and consume as little computing resources as possible. The image preprocessing part and the target detection part are arranged at the back end of the application program and can be deployed on a local server or a cloud server. The model channel of the target detection part is halved, the parameters are reduced, and the model inference speed is accelerated, which also facilitates the selection of the server. A server with relatively low computing performance can be selected, which can reasonably utilize the resources of the computer and save costs.
[0256] The front-end user interface part is mainly responsible for the shooting, processing, and uploading of the pictures to be detected, as well as the display and output of the detection results. Taking the WeChat mini program as an example, as shown in Figure 6 The front-end user interface part mainly includes page design and function implementation in the WeChat mini program. The user can select a local picture or use the camera to take a picture through the interface, upload the picture of the tomato plant to be detected (such as Figure 6 (c)), and can perform operations such as cropping and rotating on the picture before uploading to improve the accuracy of subsequent detection. Specifically, the front-end interface part is provided with a button for the user to upload pictures and an image preview area, through which the user uploads and previews the pictures. In addition, this part can also realize the display and output of the detection results of the tomato plant diseases and insect pests (such as Figure 6 (d) and Figure 6 (e)).
[0257] After uploading, the system will transmit the picture to the image preprocessing part. The image preprocessing part is mainly used for preprocessing the pictures to be detected uploaded by the user to improve the accuracy of subsequent detection. This part mainly includes image enhancement, image segmentation, and image normalization, etc. preprocessing techniques, which convert the input image into a form that the model can accept.
[0258] The target detection part mainly performs target detection on the preprocessed pictures to be detected based on a target detection model algorithm, realizes the identification and classification of tomato plant diseases and insect pests. The target detection model algorithm adopts the aforementioned YOLOv7-XSepConv model, which performs deep learning on the image through a neural network, combines various feature extraction techniques and classification algorithms, takes the preprocessed image as input, and outputs the detection results of diseases and insect pests.
[0259] The YOLOv7-XSepConv model can achieve fast and real-time target detection under limited computing resources by reducing the size and parameter quantity of the model and using lightweight convolution modules. The use scenario of the WeChat mini-program is usually that users take photos of tomato plants in the field and then perform target detection. Users may need to use the WeChat mini-program in outdoor, greenhouse or other environments for disease and pest detection. In this case, fast target detection can help users quickly understand the health status of tomato plants and take preventive measures in a timely manner. Therefore, the YOLOv7-XSepConv model is particularly suitable for the application scenario of the WeChat mini-program, which can ensure the real-time detection and user convenience.
[0260] The database part is mainly used for storing the result data of tomato plant disease and pest detection. This part can use a relational database such as MySQL, which can efficiently store and manage a large amount of data, and facilitate user query and statistical analysis when needed.
[0261] The background server is mainly used for database management and display functions, stores the detection results into the database, and displays the results to the user in the form of a list or a picture, realizing the data interaction and communication between the front and back ends. This part can use HTTP protocol, which can transmit the detection results to the user's browser end in real time through the network, facilitating user viewing and analysis, and realizing the connection and data interaction between the front-end user interface and the back-end data processing part.
[0262] Figure 4 、 Figure 5 The connection relationship and interaction process between the above-mentioned parts are shown. After the user uploads the tomato plant photo through the front-end interface part, the image preprocessing part preprocesses the image, and then passes the preprocessed image to the target detection part for disease and pest detection. The detection results are stored in the database and displayed to the user through the server part. The entire system realizes functions such as user uploading, image processing, disease and pest detection, result storage and display, and each part works cooperatively to realize a complete tomato plant disease and pest detection process.
[0263] In the entire system, each part transmits and interacts data through API interface. After the user uploads the picture and previews it through the front end, the picture is transmitted to the image preprocessing part through the API interface for processing. After the preprocessing part finishes processing, the processed image is transmitted to the target detection part through the API interface for disease and pest detection. The detection results are transmitted to the server through the API interface and stored in the database, and then returned to the front-end interface part through the API interface for display.
[0264] In summary, the present application realizes rapid detection and accurate identification of tomato plant diseases and insect pests by integrating the front-end interface, image preprocessing, target detection and server part, and provides convenient and efficient technical support for agricultural production.
[0265] It is worth mentioning that the disease and pest detection method and system of the present application is not only suitable for target detection of tomato diseases and insect pests, but also suitable for detection of diseases and insect pests of other crops, such as vegetable crops such as beans, cucumbers, eggplants and other melon and fruit crops.
[0266] The above detailed description is a specific description of the feasible embodiments of the present application, which is not used to limit the patent scope of the present application, and any equivalent implementation or change without departing from the present application shall be included in the patent scope of the present application.
Claims
1. A method for detecting a disease or pest of a tomato plant, characterized by, The method comprises the following steps: S1. On the basis of YOLOv7, the number of channels in the YOLOv7 model is reduced, and the Conv module in the YOLOv7 backbone network is replaced with an XSepConv module to obtain a YOLOv7-XSepConv model as a target detection model; S2. Tomato plant pictures with different types of diseases and pests are collected to form a training data set, parameters are set, the target detection model is trained until the model converges, and the model parameters are saved; S3. After the to-be-detected picture is preprocessed, it is input into the trained target detection model to obtain a detection result, and the recognition and classification of diseases and pests are realized; The XSepConv module comprises, connected in sequence: a 1×1 expansion convolution for expanding the input channel number to a higher dimension; a batch normalization and an activation function; a 2×2 DW convolution for performing convolution operations between channels within a group; a batch normalization and an activation function; a 1×K DW convolution for performing convolution operations in the channel dimension and having a stride in the spatial dimension; a batch normalization and an activation function; a K×1 DW convolution for performing convolution operations in the channel dimension and having different convolution kernel sizes in the spatial dimension; a batch normalization; an SE module for feature re-labeling in the channel dimension; a 1×1 output convolution for reducing the channel number of feature mapping to the required output size; and a batch normalization; K=3 in the XSepConv module, and the backbone network of the YOLOv7-XSepConv model comprises 41 lightweight convolution blocks XSepConv; The number of channels of the backbone network of the YOLOv7-XSepConv model is half of the number of channels of the backbone network of a conventional YOLOv7 model; The to-be-detected picture in the S3 step is obtained by cropping and rotating a photographed picture; The types of diseases and pests in the tomato plant pictures in the S2 step include cold damage, pest disease, early blight, fruit cracking, TY virus, potassium deficiency, and powdery mildew.
2. The method of claim 1, wherein the method is characterized by, Each convolution block XSepConv has the following structure: The first lightweight convolution block XSepConv1: the input channel number of the 1×1 expansion convolution is 3, and the output channel number is 16; the input channel number of the DW convolution, the SE module, and the 1×1 output convolution is 16, and the output channel number is 16; the channel number of the batch normalization is 16, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The second lightweight convolution block XSepConv2: the input channel number of the 1×1 expansion convolution is 16, and the output channel number is 32; the input channel number of the DW convolution, the SE module, and the 1×1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The third lightweight convolutional block XSepConv3: the input channel number of the 1*1 expansion convolution is 32, and the output channel number is 32; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The fourth lightweight convolutional block XSepConv4: the input channel number of the 1*1 expansion convolution is 32, and the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The fifth lightweight convolutional block XSepConv5 and the sixth lightweight convolutional block XSepConv6 are both: the input channel number of the 1*1 expansion convolution is 64, and the output channel number is 32; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The seventh lightweight convolutional block XSepConv7, the eighth lightweight convolutional block XSepConv8, the ninth lightweight convolutional block XSepConv9 and the tenth lightweight convolutional block XSepConv10 are all: the input channel number of the 1*1 expansion convolution is 32, and the output channel number is 32; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 32, and the output channel number is 32; the channel number of the batch normalization is 32, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The eleventh lightweight convolutional block XSepConv11: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The twelfth lightweight convolutional block XSepConv12 and the thirteenth lightweight convolutional block XSepConv13 are both: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The fourteenth lightweight convolutional block XSepConv14: the input channel number of the 1*1 expansion convolution is 64, and the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is a LeakyReLU function with a complex slope of 0.1; The 15th lightweight convolutional block XSepConv15 and the 16th lightweight convolutional block XSepConv16 are as follows: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 17th lightweight convolutional block XSepConv17, the 18th lightweight convolutional block XSepConv18, the 19th lightweight convolutional block XSepConv19 and the 20th lightweight convolutional block XSepConv20 are as follows: the input channel number of the 1*1 expansion convolution is 64, and the output channel number is 64; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 64, and the output channel number is 64; the channel number of the batch normalization is 64, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 21st lightweight convolutional block XSepConv21 is as follows: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 256; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 256, and the output channel number is 256; the channel number of the batch normalization is 256, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 22nd lightweight convolutional block XSepConv22 and the 23rd lightweight convolutional block XSepConv23 are as follows: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 128; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 24th lightweight convolutional block XSepConv24 is as follows: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 25th lightweight convolutional block XSepConv25 and the 26th lightweight convolutional block XSepConv26 are as follows: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 128; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 128, and the output channel number is 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with the complex slope of 0.1; The 27th lightweight convolutional block XSepConv27, the 28th lightweight convolutional block XSepConv28, the 29th lightweight convolutional block XSepConv29, and the 30th lightweight convolutional block XSepConv30 are all: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 128, and the output channel number is all 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 31st lightweight convolutional block XSepConv31: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 512; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 512, and the output channel number is all 512; the channel number of the batch normalization is 512, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 32nd lightweight convolutional block XSepConv32 and the 33rd lightweight convolutional block XSepConv33 are all: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 256; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 256, and the output channel number is all 256; the channel number of the batch normalization is 256, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 34th lightweight convolutional block XSepConv34: the input channel number of the 1*1 expansion convolution is 256, and the output channel number is 256; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 256, and the output channel number is all 256; the channel number of the batch normalization is 256, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 35th lightweight convolutional block XSepConv35 and the 36th lightweight convolutional block XSepConv36 are all: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 128, and the output channel number is all 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 37th lightweight convolutional block XSepConv37, the 38th lightweight convolutional block XSepConv38, the 39th lightweight convolutional block XSepConv39, and the 40th lightweight convolutional block XSepConv40 are all: the input channel number of the 1*1 expansion convolution is 128, and the output channel number is 128; the input channel number of the DW convolution, the SE module, and the 1*1 output convolution is all 128, and the output channel number is all 128; the channel number of the batch normalization is 128, and the activation function layer is the LeakyReLU function with a complex slope of 0.1; The 41st lightweight convolutional block XSepConv41: the input channel number of the 1*1 expansion convolution is 512, and the output channel number is 512; the input channel number of the DW convolution, the SE module and the 1*1 output convolution is 512, and the output channel number is 512; the channel number of the batch normalization is 512, and the activation function layer is a LeakyReLU function with a complex slope of 0.
1.
3. The method of claim 1, wherein the method is characterized by, The image preprocessing in the S3 step includes image denoising, image enhancement, image segmentation, image grayscale, image normalization and image binarization. The image enhancement adopts a histogram equalization or a filtering technology, the image segmentation adopts a color segmentation or a threshold segmentation technology to separate the tomato plants from the background in the image, and the image normalization is used for uniform size processing of the image.
4. The method of claim 1, wherein the method is characterized by, The learning rate during the model training in the S2 step adopts a cosine annealing automatic adjustment learning rate, the initial value learning rate is set to 0.001, and the iteration number is set to 300.
5. A tomato plant disease and pest detection system for implementing the tomato plant disease and pest detection method according to any one of claims 1 to 4, characterized in that, It comprises: a front-end user interface part for photographing, processing and uploading of the to-be-detected image, and display and output of the detection result; an image preprocessing part for preprocessing the uploaded to-be-detected image; a target detection part for target detection of the preprocessed to-be-detected image based on a target detection model algorithm, realizing identification and classification of the tomato plant diseases and insect pests; a database part for storing the detection result data; The front-end user interface part is configured on an application program of the intelligent terminal, and the image preprocessing part and the target detection part are configured on a background server of the application program.
6. The system for detecting diseases and pests of tomato plants according to claim 5, characterized in that, The intelligent terminal is a mobile phone, and the application program is a WeChat mini program.
Citation Information
Patent Citations
Method and system for identifying Citri medica diseases and insect pests based on improved yolov5 network
CN114005029A
Infrared vehicle rapid detection method based on improved YOLOv7 algorithm
CN116189059A