A plant leaf disease detection method based on convolutional neural network
Through the plant leaf disease detection method based on convolutional neural network, and combining virtual boundary and light reflection technology to determine the sampling point, the problem of difficulty in ensuring randomness in manual sampling is solved, and efficient and accurate disease diagnosis is achieved.
Patent Information
- Application Number
- CN202510052568.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-01-14
AI Technical Summary
When the plant planting area is large, it is difficult to ensure the randomness of the sampling through manual sampling, which affects the accuracy of the statistical results.
The plant leaf disease detection method based on convolutional neural network is adopted, and the plant planting area map is obtained, the pest and disease database and convolutional neural network model is constructed, and the sampling point location is determined in combination with virtual boundary and light reflection technology, the images are collected, and the images are pre-screened and invalid pixel replacement are finally sent to the pest and disease recognition model for identification.
By simulating the flight path of the drone, the randomness of the sampling points is ensured, the data transmission volume is reduced, the data transmission efficiency is improved, and the efficiency and accuracy of disease diagnosis are improved.
Smart Images

Figure CN119478706B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of plant disease detection, and in particular relates to a plant leaf disease detection method based on convolutional neural network. Background Art
[0002] Plant leaf disease detection is a process that uses modern technology to identify and evaluate whether there is disease on plant leaves. These technologies include but are not limited to image processing, machine learning, and artificial intelligence, which can help agricultural experts or farmers quickly and accurately diagnose the health of crops, so as to take timely and effective management measures to control the spread of diseases, reduce economic losses, and ensure food safety and ecological balance. After collecting leaf images through smartphone applications or special equipment, the system can automatically analyze the color changes, spot morphology, edge damage and other characteristics of the leaves, compare them with the known pest and disease database, and finally output the evaluation results of the disease type and its severity. This method not only improves the efficiency and accuracy of disease diagnosis, but also provides strong support for the realization of precision agriculture.
[0003] In the current plant leaf detection process, manual sampling is generally used. When the plant planting area is large, it is difficult to ensure the randomness of sampling through manual sampling, which affects the accuracy of the statistical results. Summary of the invention
[0004] The purpose of the present invention is to provide a plant leaf disease detection method based on convolutional neural network, aiming to solve the problem that when the plant planting area is large, it is difficult to ensure the randomness of sampling through manual sampling, which affects the accuracy of statistical results.
[0005] The present invention is implemented in this way: a plant leaf disease detection method based on convolutional neural network, the method comprising:
[0006] Obtaining a plant planting area map and constructing a pest and disease database, wherein the pest and disease database is used to store pictures of leaves with different types of diseases;
[0007] Based on the pest and disease database, a training data set is constructed, and a convolutional neural network is constructed. The convolutional neural network is trained and tested using the training data set to obtain a pest and disease recognition model.
[0008] Construct a virtual boundary in a plane coordinate system, perform mutation processing on the edge of the virtual boundary, perform virtual reflection of light based on the mutated virtual boundary, determine the position of the sampling point, and collect the image to be detected at the sampling point;
[0009] The collected image to be detected is pre-screened to obtain a pre-screened image, invalid pixels in the pre-screened image are replaced, and the image is sent to the pest and disease recognition model for recognition to generate a recognition result.
[0010] Preferably, the steps of constructing a training data set based on a pest and disease database, constructing a convolutional neural network, training and testing the convolutional neural network through the training data set, and obtaining a pest and disease recognition model specifically include:
[0011] Retrieve images from the pest and disease database and organize them into training data sets and test data sets;
[0012] Construct a convolutional neural network and train it using a training data set;
[0013] The convolutional neural network is tested using a test data set until the recognition success rate reaches a preset value, and a pest and disease recognition model is obtained.
[0014] Preferably, the steps of constructing a virtual boundary in a plane coordinate system, performing a mutation process on the edge of the virtual boundary, performing a virtual reflection of light based on the mutated virtual boundary, determining the position of a sampling point, and collecting the image to be detected at the sampling point specifically include:
[0015] Constructing a plane coordinate system, and constructing a virtual boundary of equal proportion in the plane coordinate system according to the boundary of the plant planting area in the plant planting area map;
[0016] The virtual boundary is processed as a polyline edge, and the preset mutation random function is called, multiple mutation points are selected on the smoothed virtual boundary, and mutation values are generated according to the coordinates of the mutation points and the mutation random function;
[0017] The edge of the polyline is adjusted by the variation value, a virtual light is emitted in the virtual boundary, the virtual light is reflected on the edge of the polyline, and a sampling point is selected on the path of the virtual light to collect the image to be detected.
[0018] Preferably, the step of pre-screening the collected image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, sending the image to the pest and disease recognition model for recognition, and generating a recognition result specifically includes:
[0019] Count the images corresponding to various pests and diseases in the pest and disease database, extract the pest and disease areas and leaf areas in the images, perform color information statistics on the pest and disease areas and leaf areas, and determine the detection color range;
[0020] Pre-screening the images to be detected according to the detection color range, eliminating the images to be detected that do not include the detection color range, obtaining a pre-screened image, and identifying invalid pixels based on the detection color range, wherein the invalid pixels are pixels that do not belong to the detection color range;
[0021] The invalid pixels in the pre-screening image are replaced with preset pixels, and the replaced pre-screening image is sent to the pest and disease recognition model for recognition to generate a recognition result.
[0022] Preferably, when transmitting the replaced pre-screened image, only the coordinates and color values of the pixels that have not been replaced are transmitted, and invalid pixels are represented by preset symbols.
[0023] The present invention provides a plant leaf disease detection method based on a convolutional neural network. The method constructs a virtual boundary, simulates the light propagation process within the virtual boundary, simulates the flight path of a drone, extracts sampling points from the flight path, and ensures the randomness of the sampling points. The method also greatly reduces the amount of data transmission and improves the data transmission efficiency by performing graded screening and transmission of images. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A flow chart of a plant leaf disease detection method based on a convolutional neural network provided in an embodiment of the present invention;
[0025] Figure 2 A flowchart of the steps of constructing a training data set based on a pest and disease database, constructing a convolutional neural network, training and testing the convolutional neural network through the training data set, and obtaining a pest and disease recognition model provided by an embodiment of the present invention;
[0026] Figure 3 A flowchart of the steps of constructing a virtual boundary in a plane coordinate system, performing a mutation process on the edge of the virtual boundary, performing a virtual reflection of light based on the mutated virtual boundary, determining the position of a sampling point, and collecting an image to be detected at the sampling point provided by an embodiment of the present invention;
[0027] Figure 4 A flowchart of the steps of pre-screening the collected image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, sending the image to a pest and disease recognition model for recognition, and generating a recognition result provided by an embodiment of the present invention;
[0028] Figure 5 An architecture diagram of a plant leaf disease detection system based on a convolutional neural network provided in an embodiment of the present invention;
[0029] Figure 6 An architecture diagram of a recognition model building module provided by an embodiment of the present invention;
[0030] Figure 7 The architecture diagram of the sampling point random module provided by the embodiment of the present invention;
[0031] Figure 8 This is a diagram of the architecture of the pest identification module provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0033] like Figure 1 FIG. 1 is a flow chart of a method for detecting plant leaf diseases based on a convolutional neural network according to an embodiment of the present invention, wherein the method comprises:
[0034] S100, obtaining a plant planting area map and constructing a pest and disease database, wherein the pest and disease database is used to store pictures of leaves with different types of diseases.
[0035] In this step, a plant planting area map is obtained, in which the location of each point in the plant planting area and the overall range are recorded, and a pest and disease database is constructed. The pest and disease database records pictures of damaged plant leaves under the influence of different types of pests and diseases. The above pictures of damaged plant leaves are classified according to the types of pests and diseases. The sources may be public data sets (such as PlantVillage, EuroSAT, etc.), research institutions, agricultural departments or manually taken images. The above images are marked and corresponding labels are set to indicate which disease the image belongs to or whether it is healthy. The labels may be classification labels.
[0036] S200, constructing a training data set based on the pest and disease database, constructing a convolutional neural network, training and testing the convolutional neural network through the training data set, and obtaining a pest and disease recognition model.
[0037] In this step, a training data set is constructed based on the pest and disease database. A convolutional neural network is a deep learning model specially designed to process data with a grid structure (such as images). It extracts and learns multi-level features of the data through a series of convolutional layers, pooling layers, and fully connected layers. The convolutional layer uses filters (convolution kernels) to slide on the input data to extract local features; the pooling layer reduces the spatial dimension of the feature map by downsampling, reduces the computational complexity and retains important features; the fully connected layer maps the extracted features to the output space required for the classification task, and imports the training data set as training data into the convolutional neural network to train the convolutional neural network. In the continuous learning process, the convolutional neural network gradually has a strong feature extraction capability. After testing, it can be guaranteed that the obtained pest and disease recognition model has a high recognition accuracy. At this time, by importing the picture to be detected, the pest and disease recognition model can identify whether the picture to be detected is a picture of a plant leaf with pests and diseases.
[0038] S300, constructing a virtual boundary in a plane coordinate system, performing mutation processing on the edge of the virtual boundary, performing virtual reflection of light based on the mutated virtual boundary, determining the position of a sampling point, and collecting an image to be detected at the sampling point.
[0039] In this step, a virtual boundary is constructed in a plane coordinate system, a two-dimensional coordinate system is constructed, the boundary of the plant planting area map is identified, and the coordinates of each point on the boundary are imported into the two-dimensional coordinate system, thereby mapping the boundary of the plant planting area map to the virtual two-dimensional coordinate system, and the edge of the virtual boundary is modified into a broken line through mutation processing, thereby imagining a virtual light ray inside the virtual boundary, and propagating the virtual light ray within the virtual boundary to generate a random path, and sampling is performed on the randomly obtained path to obtain randomly generated sampling points. According to the position of the sampling point, the drone is controlled to fly to the corresponding sampling point for image acquisition to obtain the image to be detected.
[0040] S400, pre-screening the collected image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, sending it to a pest and disease recognition model for recognition, and generating a recognition result.
[0041] In this step, the collected images to be detected are pre-screened. When performing image acquisition, in order to ensure the acquisition quality, a high-resolution image acquisition device is usually used for image acquisition. If real-time communication is required, a large amount of data will be transmitted, which affects the data transmission efficiency. In fact, many images to be detected do not contain leaves with pests and diseases. If they are also transmitted, it will cause a waste of resources. By counting and analyzing the pictures of pest and disease leaves in the pest and disease database, the color information range contained in the above pictures is determined, and pre-screening is performed according to the color information range to eliminate most of the pictures to be detected that do not contain leaves with pests and diseases, and further screen the invalid areas in the remaining pictures. The invalid area refers to the pixels in the picture other than the plant leaves. Only the pixels in the area where the plant leaves are located are transmitted to reduce the amount of data transmission. The pixels in the invalid area are filled with preset pixels. The above filling process is performed at the receiving end of the data. For example, the drone transmits the data to the receiving end, and the pest and disease recognition model is loaded on the receiving end. Then, before importing the pest and disease recognition model, the invalid area is filled with preset pixels, and the filled image to be detected is imported into the pest and disease recognition model.
[0042] like Figure 2 As shown, as a preferred embodiment of the present invention, the steps of constructing a training data set based on a pest and disease database, constructing a convolutional neural network, training and testing the convolutional neural network through the training data set, and obtaining a pest and disease recognition model specifically include:
[0043] S201, retrieve images from the pest and disease database and organize them into a training data set and a test data set.
[0044] In this step, images in the pest and disease database are retrieved. The training data set is used for routine training of the model, and the test data set is used to verify the results of model training. The ratio of the training data set to the test data set is set to 7:3 or 8:2.
[0045] S202, constructing a convolutional neural network, and training the convolutional neural network using a training data set.
[0046] S203, testing the convolutional neural network using a test data set until the recognition success rate reaches a preset value, thereby obtaining a pest and disease recognition model.
[0047] In this step, a convolutional neural network is constructed. The convolutional neural network includes an input layer for receiving data, a first convolutional layer for extracting low-level features of the image, such as edges and textures, of type Conv2D, which includes 32 filters, each of which has a size of 3x3, an activation function of ReLU, and a padding method of the same; a first maximum pooling layer for reducing the spatial dimension of the feature map, reducing the amount of calculation, and retaining the most important features, of type MaxPooling2D, with a pooling window size of 2x2 and a step size of 2; and a second convolutional layer for extracting more complex low-level features, of type Conv2D, containing 64 Filters, each with a size of 3x3, an activation function of ReLU, and the same padding. The second maximum pooling layer is used to reduce the spatial dimension of the feature map. The pooling window size is 2x2, the step size is 2, and the type is MaxPooling2D. The third convolutional layer is used to extract more advanced features and contains 128 filters. Each filter has a size of 3x3, an activation function of ReLU, and the same padding. The type is Conv2D. The third maximum pooling layer is of type MaxPooling2D, and the pooling window size is 2x2, with a step size of 2. The flattening layer is used to provide a flat feature vector for the fully connected layer, converting the multi-dimensional feature map into a one-dimensional vector for input to the fully connected layer. The fully connected layer is used to perform nonlinear transformations and extract advanced features. It contains 128 neurons, the activation function is ReLU, the Dropout layer increases the generalization ability of the model and avoids overfitting, the dropout ratio is 0.5, the output layer is used to output the probability distribution of each category, and the activation function is softmax; the test data set is used for testing. During this process, the performance of the convolutional neural network is evaluated, adjusted and optimized, and finally the test data set is used to test the obtained pest and disease recognition model. When the test success rate reaches the preset value, the training is judged to be completed and the pest and disease recognition model can be put into use.
[0048] like Figure 3 As shown, as a preferred embodiment of the present invention, the steps of constructing a virtual boundary in a plane coordinate system, performing mutation processing on the edge of the virtual boundary, performing virtual reflection of light based on the mutated virtual boundary, determining the position of the sampling point, and collecting the image to be detected at the sampling point specifically include:
[0049] S301, constructing a plane coordinate system, and constructing a virtual boundary of equal proportion in the plane coordinate system according to the boundary of the plant planting area in the plant planting area map.
[0050] In this step, a plane coordinate system is constructed, the boundary in the plant planting area map is extracted, and points are taken on the boundary. The interval between the points is a preset value, such as taking a boundary point every 1 meter. The coordinates of the boundary point are extracted and synchronously marked in the plane coordinate system, thereby forming a virtual boundary in the plane coordinate system that is proportional to the plant planting area map.
[0051] S302, processing the virtual boundary as a polyline edge, and calling a preset mutation random function, selecting multiple mutation points on the smoothed virtual boundary, and generating mutation values according to the coordinates of the mutation points and the mutation random function.
[0052] In this step, the virtual boundary is processed as a polyline edge, and two adjacent boundary points are connected by line segments, so that the entire virtual boundary is processed as an enclosed polyline composed of multiple line segments, and the preset mutation random function is called. The mutation random function is a function whose independent variable range is a positive real number, such as a direct proportional function, a univariate multi-function, and a power function, which is expressed as f ( x ), select from all the boundary points, select the boundary points with odd or even numbers, use them as mutation points, extract the coordinates of the mutation points, and substitute the horizontal or vertical coordinates of the coordinates into the mutation random function f ( x ) to obtain the mutation value f ( L ),in L is the horizontal or vertical coordinate of the variation point.
[0053] S303, adjusting the edge of the fold line by using the variation value, emitting a virtual light in the virtual boundary, reflecting the virtual light on the edge of the fold line, and selecting a sampling point on the path of the virtual light to collect the image to be detected.
[0054] In this step, the edge of the polyline is adjusted by the mutation value, and the mutation value is decomposed into two parts, namely, a direction character and a proportional character. The first digit of the mutation value is the direction character, and a preset number of digits in the remaining digits are intercepted as proportional characters. For example, the first four digits are intercepted as proportional characters. The mutation value is 2378612784.3, in which the first digit 2 is the direction character and the remaining 3786 is the proportional character. The mutation direction is determined according to the direction character. When the direction character is an odd number, it mutates in the counterclockwise direction. When the direction character is an even number, Mutate in the clockwise direction, calculate the mutation ratio P=3786 / 10000, then the mutation amount is P*θ, where θ is the maximum mutation range. For example, at 45°, the mutation value is 2378612784.3, which means that the line segment on the right side of the current mutation point (i.e., close to the next numbered mutation point) is controlled with the current mutation point as the center of the circle, and rotated in the clockwise direction by P*θ. At this time, the end of the line segment away from the current mutation point is connected to the next numbered mutation point. Based on this, the above operation is performed for each mutation point to complete the mutation process and calculate the average coordinates of all mutation points. , starting from the position of the average coordinate, randomly emit virtual light in one direction. When the virtual light reaches the edge of the virtual boundary, it will be reflected, so that the virtual light is repeatedly reflected in the area enclosed by the virtual boundary. The width of the virtual light is a preset value, such as 1 meter. The path of the virtual light is based on the center line of the virtual light. The enclosed area of the entire virtual boundary is counted. When the area passed by the virtual light (without repeated counting) reaches a preset proportion of the enclosed area, such as 80%, it is determined to stop reflecting. According to the total length of the virtual light at this time and The required number of sampling points is used to generate sampling positions. For example, sampling is performed once every 100 meters. According to the virtual path corresponding to the virtual light, a sampling point is set every 100 meters that the virtual light advances. Based on this, a preset number of sampling points are obtained. When the sampling points coincide, a circle is drawn with the sampling point as the center and the sampling range as the diameter to construct a new sampling point. The edge of the new sampling point is tangent to the constructed circle. After all the sampling points are obtained, path planning is performed according to the plant planting area map, and the drone is controlled to arrive at each sampling point for image acquisition to obtain the image to be detected.
[0055] like Figure 4 As shown, as a preferred embodiment of the present invention, the steps of pre-screening the acquired image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, sending the image to the pest and disease recognition model for recognition, and generating a recognition result specifically include:
[0056] S401, counting images corresponding to various pests and diseases in the pest and disease database, extracting pest and disease areas and leaf areas in the images, performing color information statistics on the pest and disease areas and leaf areas, and determining a detection color range.
[0057] In this step, the images corresponding to various pests and diseases in the pest and disease database are counted, the pest and disease areas and leaf areas marked in the images are counted, the color range of the leaves and the color range corresponding to the pest and disease areas are counted, such as the color range of the leaves is 100-150 for the R channel, 120-160 for the G channel, and 80-120 for the B channel. Similarly, the color range corresponding to the pest and disease area is determined. The pest and disease area is a yellow, black or gray area. The corresponding color range is determined by statistics, and the two parts of the color range are merged to obtain the detection color range.
[0058] S402, pre-screening the images to be detected according to the detection color range, eliminating the images to be detected that do not include the detection color range, obtaining a pre-screened image, and identifying invalid pixels based on the detection color range, wherein the invalid pixels are pixels that do not belong to the detection color range.
[0059] In this step, the image to be detected is pre-screened according to the detection color range. When the number of pixels in the image to be detected that fall within the detection color range exceeds a preset value, it is determined that there may be leaves or pest and disease areas in the image to be detected. The image to be detected is retained to complete the initial screening and obtain a pre-screened image. Furthermore, pixels in the pre-screened image that do not fall within the detection color range are extracted and defined as invalid pixels.
[0060] S403, replacing invalid pixels in the pre-screening image with preset pixels, sending the replaced pre-screening image to the pest and disease recognition model for recognition, and generating a recognition result.
[0061] In this step, invalid pixels in the pre-screening image are replaced with preset pixels, or blank pixel filling can be used, that is, only pixels other than invalid pixels are recorded in the pre-screening image, which will greatly reduce the amount of data transmission. When the pre-screening image reaches the receiving end, it can be filled with preset pixels. When filling, a set of preset images that do not contain leaves can be called, such as images that only contain the ground, and the pre-screening image can be superimposed on the image to achieve the effect of filling blank pixels. The superimposed image is imported into the pest and disease recognition model to obtain the recognition result. The type of pest and disease, as well as the ratio of the pest and disease area to the whole leaf are recorded in the recognition result, and the proportion of pests and diseases in the entire plant planting area is calculated according to the total number of sampling areas.
[0062] like Figure 5 As shown, a plant leaf disease detection system based on a convolutional neural network is provided in an embodiment of the present invention, and the system includes:
[0063] The database construction module 100 is used to obtain a plant planting area map and construct a pest and disease database, wherein the pest and disease database is used to store pictures of leaves with different types of diseases.
[0064] In the present system, the database construction module 100 obtains a plant planting area map, in which the location of each point in the plant planting area and the overall scope are recorded, and a pest and disease database is constructed. The pest and disease database records pictures of damaged plant leaves under the influence of different types of pests and diseases. The pictures of damaged plant leaves are classified according to the types of pests and diseases, and their sources may be public data sets (such as PlantVillage, EuroSAT, etc.), research institutions, agricultural departments or manually taken images. The images are marked and corresponding labels are set to indicate which disease the image belongs to or whether it is healthy. The labels may be classification labels.
[0065] The recognition model construction module 200 is used to construct a training data set based on the pest and disease database, construct a convolutional neural network, train and test the convolutional neural network through the training data set, and obtain a pest and disease recognition model.
[0066] In this system, the recognition model construction module 200 constructs a training data set based on the pest and disease database. The convolutional neural network is a deep learning model specially designed to process data with a grid structure (such as images). It extracts and learns multi-level features of the data through a series of convolutional layers, pooling layers and fully connected layers. The convolutional layer uses a filter (convolution kernel) to slide on the input data to extract local features; the pooling layer reduces the spatial dimension of the feature map by downsampling, reduces the computational complexity and retains important features; the fully connected layer maps the extracted features to the output space required for the classification task, and imports the training data set as training data into the convolutional neural network to train the convolutional neural network. In the continuous learning process, the convolutional neural network gradually has a strong feature extraction capability. After testing, it can be guaranteed that the obtained pest and disease recognition model has a high recognition accuracy. At this time, by importing the picture to be detected, the pest and disease recognition model can identify whether the picture to be detected is a picture of a plant leaf with pests and diseases.
[0067] The sampling point random module 300 is used to construct a virtual boundary in a plane coordinate system, perform mutation processing on the edge of the virtual boundary, perform virtual reflection of light based on the mutated virtual boundary, determine the sampling point position, and collect the image to be detected at the sampling point.
[0068] In this system, the sampling point random module 300 constructs a virtual boundary in a plane coordinate system, constructs a two-dimensional coordinate system, identifies the boundary of the plant planting area map, imports the coordinates of each point on the boundary into the two-dimensional coordinate system, thereby mapping the boundary of the plant planting area map to a virtual two-dimensional coordinate system, and modifies the edge of the virtual boundary into a broken line through mutation processing, thereby imagining a virtual light inside the virtual boundary, and propagating the virtual light within the virtual boundary to generate a random path, and sampling is performed on the randomly obtained path to obtain randomly generated sampling points. According to the position of the sampling point, the drone is controlled to fly to the corresponding sampling point for image acquisition to obtain the image to be detected.
[0069] The pest identification module 400 is used to pre-screen the collected image to be detected to obtain a pre-screened image, replace invalid pixels in the pre-screened image, send it to the pest identification model for identification, and generate an identification result.
[0070] In this system, the pest identification module 400 pre-screens the acquired images to be detected. When collecting images, in order to ensure the quality of collection, a high-resolution image acquisition device is usually used for image collection. If real-time communication is required, a large amount of data will be transmitted, which affects the data transmission efficiency. In fact, many images to be detected do not contain leaves with pests and diseases. If they are also transmitted, it will cause a waste of resources. By counting and analyzing the pictures of pest and disease leaves in the pest and disease database, the color information range contained in the above pictures is determined, and pre-screening is performed according to the color information range to eliminate most of the pictures to be detected that do not contain leaves with pests and diseases, and further screen the invalid areas in the remaining pictures. The invalid area refers to the pixels in the picture other than the plant leaves. Only the pixels in the area where the plant leaves are located are transmitted to reduce the amount of data transmission. The pixels in the invalid area are filled with preset pixels. The above filling process is performed at the receiving end of the data. For example, the drone transmits the data to the receiving end, and the pest and disease recognition model is loaded on the receiving end. Then, before importing the pest and disease recognition model, the invalid area is filled with preset pixels, and the filled image to be detected is imported into the pest and disease recognition model.
[0071] like Figure 6 As shown, as a preferred embodiment of the present invention, the recognition model building module 200 includes:
[0072] The data machine construction unit 201 is used to retrieve images from the pest and disease database and construct them into a training data set and a test data set.
[0073] In this module, the data machine construction unit 201 retrieves images from the pest and disease database, the training data set is used for routine training of the model, and the test data set is used to verify the results of the model training. The ratio of the training data set to the test data set is set to 7:3 or 8:2.
[0074] The model training unit 202 is used to construct a convolutional neural network and train the convolutional neural network using a training data set.
[0075] The model testing unit 203 is used to test the convolutional neural network through a test data set until the recognition success rate reaches a preset value, thereby obtaining a pest and disease recognition model.
[0076] In this module, a convolutional neural network is constructed. The convolutional neural network includes an input layer for receiving data, a first convolutional layer for extracting low-level features of the image, such as edges and textures, of type Conv2D, which contains 32 filters, each of which has a size of 3x3, an activation function of ReLU, and a padding method of the same. The first maximum pooling layer is used to reduce the spatial dimension of the feature map and reduce the amount of calculation while retaining the most important features. The type is MaxPooling2D, the pooling window size is 2x2, and the step size is 2. The second convolutional layer is used to extract more complex low-level features. The type is Conv2D and contains 64 Filters, each with a size of 3x3, an activation function of ReLU, and the same padding. The second maximum pooling layer is used to reduce the spatial dimension of the feature map. The pooling window size is 2x2, the step size is 2, and the type is MaxPooling2D. The third convolutional layer is used to extract more advanced features and contains 128 filters. Each filter has a size of 3x3, an activation function of ReLU, and the same padding. The type is Conv2D. The third maximum pooling layer is of type MaxPooling2D, and the pooling window size is 2x2, with a step size of 2. The flattening layer is used to provide a flat feature vector for the fully connected layer, converting the multi-dimensional feature map into a one-dimensional vector for input to the fully connected layer. The fully connected layer is used to perform nonlinear transformations and extract advanced features. It contains 128 neurons, the activation function is ReLU, the Dropout layer increases the generalization ability of the model and avoids overfitting, the dropout ratio is 0.5, the output layer is used to output the probability distribution of each category, and the activation function is softmax; the test data set is used for testing. During this process, the performance of the convolutional neural network is evaluated, adjusted and optimized, and finally the test data set is used to test the obtained pest and disease recognition model. When the test success rate reaches the preset value, the training is judged to be completed and the pest and disease recognition model can be put into use.
[0077] like Figure 7As shown, as a preferred embodiment of the present invention, the sampling point random module 300 includes:
[0078] The virtual boundary construction unit 301 is used to construct a plane coordinate system, and construct a virtual boundary of equal proportion in the plane coordinate system according to the boundary of the plant planting area in the plant planting area map.
[0079] In this module, the virtual boundary construction unit 301 constructs a plane coordinate system, extracts the boundary in the plant planting area map, takes points on the boundary, and the interval between the points is a preset value, such as taking a boundary point every 1 meter, extracts the coordinates of the boundary point, and synchronously marks it in the plane coordinate system, thereby forming a virtual boundary in the plane coordinate system that is proportional to the plant planting area map.
[0080] The mutation value generating unit 302 is used to process the virtual boundary as a polyline edge, and call a preset mutation random function, select multiple mutation points on the smoothed virtual boundary, and generate mutation values according to the coordinates of the mutation points and the mutation random function.
[0081] In this module, the variation value generation unit 302 processes the virtual boundary as a polyline edge, connects two adjacent boundary points through line segments, and thus processes the entire virtual boundary as an enclosed polyline composed of multiple line segments, and calls a preset variation random function, which is a function whose independent variable range is a positive real number, such as a direct proportional function, a univariate multi-function, and a power function, and is expressed as f ( x ), select from all the boundary points, select the boundary points with odd or even numbers, use them as mutation points, extract the coordinates of the mutation points, and substitute the horizontal or vertical coordinates of the coordinates into the mutation random function f ( x ) to obtain the mutation value f ( L ),in L is the horizontal or vertical coordinate of the variation point.
[0082] The edge variation unit 303 is used to adjust the edge of the polyline by using the variation value, emit virtual light in the virtual boundary, reflect the virtual light on the polyline edge, and select sampling points on the path of the virtual light to collect the image to be detected.
[0083] In this module, the edge mutation unit 303 adjusts the edge of the polyline by the mutation value, and decomposes the mutation value into two parts, namely, a direction character and a proportional character. The first digit of the mutation value is the direction character, and a preset number of digits in the remaining digits are intercepted as proportional characters. For example, the first four digits are intercepted as proportional characters. The mutation value is 2378612784.3, in which the first digit 2 is the direction character and the remaining 3786 is the proportional character. The mutation direction is determined according to the direction character. When the direction character is an odd number, it mutates in the counterclockwise direction. The direction is When the character is an even number, it mutates in the clockwise direction, and the mutation ratio is calculated to be P=3786 / 10000. The mutation amount is P*θ, where θ is the maximum mutation range. For example, at 45°, the mutation value is 2378612784.3, which means that the line segment on the right side of the current mutation point (i.e., the mutation point close to the next number) is controlled with the current mutation point as the center of the circle, and rotated in the clockwise direction by P*θ. At this time, the end of the line segment away from the current mutation point is connected to the next numbered mutation point. The above operation is performed for each mutation point to complete the mutation process and calculate all mutation points. The average coordinates of the virtual light are taken as the starting point, and a virtual light is randomly emitted in one direction. When the virtual light reaches the edge of the virtual boundary, it will be reflected, so that the virtual light is repeatedly reflected in the area enclosed by the virtual boundary. The width of the virtual light is a preset value, such as 1 meter. The path of the virtual light is based on the center line of the virtual light. The enclosed area of the entire virtual boundary is counted. When the area passed by the virtual light (without repeated counting) reaches a preset proportion of the enclosed area, such as 80%, it is determined to stop reflecting. According to the total length of the virtual light at this time And the required number of sampling points, generate sampling positions, such as sampling once every 100 meters, then according to the virtual path corresponding to the virtual light, every time the virtual light advances 100 meters, a sampling point is set, and a preset number of sampling points are obtained. When the sampling points coincide, a circle is drawn with the sampling point as the center and the sampling range as the diameter to construct a new sampling point. The edge of the new sampling point is tangent to the constructed circle. After all the sampling points are obtained, path planning is performed according to the plant planting area map, and the drone is controlled to arrive at each sampling point for image acquisition to obtain the image to be detected.
[0084] like Figure 8 As shown, as a preferred embodiment of the present invention, the pest identification module 400 includes:
[0085] The color range statistics unit 401 is used to count the images corresponding to various pests and diseases in the pest and disease database, extract the pest and disease areas and leaf areas in the images, perform color information statistics on the pest and disease areas and leaf areas, and determine the detection color range.
[0086] In this module, the color range statistics unit 401 counts the images corresponding to various pests and diseases in the pest and disease database, counts the pest and disease areas and leaf areas marked in the images, and counts the color range of the leaves and the color range corresponding to the pest and disease areas. For example, the color range of the leaves is 100-150 for the R channel, 120-160 for the G channel, and 80-120 for the B channel. Similarly, the color range corresponding to the pest and disease area is determined. The pest and disease area is a yellow, black or gray area. The corresponding color range is determined by statistics, and the two parts of the color range are merged to obtain the detection color range.
[0087] The image pre-screening unit 402 is used to pre-screen the image to be detected according to the detection color range, eliminate the image to be detected that does not contain the detection color range, obtain a pre-screened image, and identify invalid pixels based on the detection color range, where the invalid pixels are pixels that do not belong to the detection color range.
[0088] In this module, the image pre-screening unit 402 pre-screens the image to be detected according to the detection color range. When the number of pixels in the image to be detected that fall within the detection color range exceeds a preset value, it is determined that there may be leaves or pest and disease areas in the image to be detected, and the image to be detected is retained to complete the initial screening and obtain a pre-screened image. Further, pixels in the pre-screened image that do not fall within the detection color range are extracted and defined as invalid pixels.
[0089] The data detection unit 403 is used to replace invalid pixels in the pre-screening image with preset pixels, send the replaced pre-screening image to the pest and disease recognition model for recognition, and generate a recognition result.
[0090] In this module, the data detection unit 403 replaces the invalid pixels in the pre-screening image with preset pixels, and may also adopt a blank pixel filling method, that is, only pixels other than invalid pixels are recorded in the pre-screening image, which will greatly reduce the amount of data transmission. When the pre-screening image arrives at the receiving end, it can be filled with preset pixels. When filling, a set of preset images that do not contain leaves can be called, such as an image that only contains the ground, and the pre-screening image can be superimposed on the image to achieve the effect of filling blank pixels. The superimposed image is imported into the pest and disease recognition model to obtain the recognition result. The type of pest and disease, as well as the ratio of the pest and disease area to the whole leaf are recorded in the recognition result, and the proportion of pests and diseases in the entire plant planting area is calculated according to the total number of sampling areas.
[0091] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A plant leaf disease detection method based on convolutional neural network, characterized in that: The method comprises: Obtaining a plant planting area map and constructing a pest and disease database, wherein the pest and disease database is used to store pictures of leaves with different types of diseases; Based on the pest and disease database, a training data set is constructed, and a convolutional neural network is constructed. The convolutional neural network is trained and tested using the training data set to obtain a pest and disease recognition model. Construct a virtual boundary in a plane coordinate system, perform mutation processing on the edge of the virtual boundary, perform virtual reflection of light based on the mutated virtual boundary, determine the position of the sampling point, and collect the image to be detected at the sampling point; Pre-screening the collected image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, and sending it to the pest and disease recognition model for recognition to generate a recognition result; The steps of constructing a virtual boundary in a plane coordinate system, performing a mutation process on the edge of the virtual boundary, performing a virtual reflection of light based on the mutated virtual boundary, determining the position of a sampling point, and collecting an image to be detected at the sampling point specifically include: In this step, a plane coordinate system is constructed, the boundary in the plant planting area map is extracted, points are taken on the boundary, the interval between the points is a preset value, the coordinates of the boundary points are extracted, and they are synchronously marked in the plane coordinate system, forming a virtual boundary in the plane coordinate system that is proportional to the plant planting area map; The virtual boundary is processed as a polyline edge, and the preset mutation random function is called, multiple mutation points are selected on the smoothed virtual boundary, and mutation values are generated according to the coordinates of the mutation points and the mutation random function; In this step, the virtual boundary is processed as a polyline edge, two adjacent boundary points are connected by line segments, and the entire virtual boundary is processed as an enclosed polyline composed of multiple line segments. The preset mutation random function is called, and the mutation random function is a function whose independent variable range is a positive real number. From all boundary points, select the boundary points with odd or even numbers as mutation points, extract the coordinates of the mutation points, and substitute the horizontal or vertical coordinates of the coordinates into the mutation random function. f ( x ) to obtain the mutation value f ( L ),in L is the horizontal or vertical coordinate of the variation point; The edge of the polyline is adjusted by the variation value, a virtual light is emitted in the virtual boundary, the virtual light is reflected on the edge of the polyline, and a sampling point is selected on the path of the virtual light to collect the image to be detected; In this step, the edge of the polyline is adjusted by the mutation value, and the mutation value is decomposed into two parts, namely, a direction character and a ratio character. The first digit of the mutation value is the direction character, and a preset number of digits in the remaining digits are intercepted as ratio characters. The mutation direction is determined according to the direction character. When the direction character is an odd number, it mutates in the counterclockwise direction. When the direction character is an even number, it mutates in the clockwise direction. The mutation ratio and the mutation amount are calculated, and the line segment on the right side of the current mutation point is controlled to rotate in the clockwise direction. At this time, the end of the line segment away from the current mutation point is connected to the next numbered mutation point. The above operation is performed for each mutation point to complete the mutation process, and the average coordinates of all mutation points are calculated. Taking the position of the average coordinate as the starting point, a virtual light is randomly emitted in one direction. When the virtual light reaches When the virtual light reaches the edge of the virtual boundary, reflection will occur, so that the virtual light is repeatedly reflected in the area enclosed by the virtual boundary. The width of the virtual light is a preset value, and the path of the virtual light is based on the center line of the virtual light. The enclosed area of the entire virtual boundary is counted. When the area swept by the virtual light reaches a preset proportion of the enclosed area, it is determined to stop the reflection. According to the total length of the virtual light and the required number of sampling points at this time, the sampling position is generated, and a preset number of sampling points are obtained. When the sampling points coincide, a circle is drawn with the sampling point as the center and the sampling range as the diameter to construct a new sampling point. The edge of the new sampling point is tangent to the constructed circle. After all the sampling points are obtained, the path is planned according to the plant planting area map, and the drone is controlled to arrive at each sampling point for image acquisition to obtain the image to be detected.
2. The plant leaf disease detection method based on convolutional neural network according to claim 1, characterized in that: The steps of constructing a training data set based on the pest and disease database, constructing a convolutional neural network, training and testing the convolutional neural network through the training data set, and obtaining a pest and disease recognition model specifically include: Retrieve images from the pest and disease database and organize them into training data sets and test data sets; Construct a convolutional neural network and train it using a training data set; The convolutional neural network is tested using a test data set until the recognition success rate reaches a preset value, and a pest and disease recognition model is obtained.
3. The plant leaf disease detection method based on convolutional neural network according to claim 1, characterized in that: The step of pre-screening the collected image to be detected to obtain a pre-screened image, replacing invalid pixels in the pre-screened image, sending the image to the pest and disease recognition model for recognition, and generating a recognition result specifically includes: Count the images corresponding to various pests and diseases in the pest and disease database, extract the pest and disease areas and leaf areas in the images, perform color information statistics on the pest and disease areas and leaf areas, and determine the detection color range; Pre-screening the images to be detected according to the detection color range, eliminating the images to be detected that do not include the detection color range, obtaining a pre-screened image, and identifying invalid pixels based on the detection color range, wherein the invalid pixels are pixels that do not belong to the detection color range; The invalid pixels in the pre-screening image are replaced with preset pixels, and the replaced pre-screening image is sent to the pest and disease recognition model for recognition to generate a recognition result.
4. The plant leaf disease detection method based on convolutional neural network according to claim 3, characterized in that: When transmitting the replaced pre-screened image, only the coordinates and color values of the pixels that have not been replaced are transmitted, and invalid pixels are represented by preset symbols.
5. The plant leaf disease detection method based on convolutional neural network according to claim 3, characterized in that: Invalid pixels are filled with blank pixels, and when a pre-screened image is received, they are filled with preset pixels.
6. The plant leaf disease detection method based on convolutional neural network according to claim 1, characterized in that: The identification results include the area proportion of the area where pests and diseases occur.
Citation Information
Patent Citations
Vegetable disease detection method and system
CN112598031A
Defect detection method and related device
WO2024255919A1