Crop leaf disease identification method and device, electronic equipment and storage medium

Through the random forest model and hyperparameter optimization technology, feature extraction and morphological processing of crop leaf disease images are performed, which solves the inefficiency and inaccuracy problems of crop leaf disease judgment in the existing technology and achieves high-precision disease identification. and timely prevention.

CN118628903APending Publication Date: 2024-09-10BEIJING RES CENT FOR INFORMATION TECH & AGRI +4
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410641356.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the existing technology, the judgment of crop leaf diseases mainly relies on manual methods, which is time-consuming and labor-intensive and the accuracy is difficult to guarantee, resulting in low disease identification accuracy and efficiency, making it difficult to effectively prevent in a timely manner.

Method used

Using the random forest model combined with hyperparameter optimization, through feature extraction and morphological processing of crop leaf disease images, the target random deep forest model is used for disease identification to improve the accuracy and robustness of disease identification.

Benefits of technology

It achieves high-precision identification of crop leaf diseases, improves disease identification efficiency, and timely prevention reduces crop yield and quality reduction caused by diseases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628903A
    Figure CN118628903A
Patent Text Reader

Abstract

The invention provides a crop leaf disease identification method and apparatus, an electronic device and a storage medium. The method comprises the steps of extracting a scab image in an obtained crop leaf disease image; performing feature extraction on the disease spot image to obtain disease spot features of the disease spot image; inputting scab features of the scab image into a target random deep forest model to obtain a disease identification result of the crop leaf disease image output by the target random deep forest model; the target random forest model is obtained by training an optimized random forest model according to the crop leaf disease image sample and the corresponding disease type label, and the optimized random forest model is obtained by performing hyper-parameter optimization on the random forest model. According to the method, the identification accuracy and robustness of the crop leaf diseases can be improved, the identification precision and efficiency of the crop leaf diseases are effectively improved, accurate identification when scabs appear is realized, timely prevention is facilitated, and crop leaf output reduction and quality reduction caused by the diseases are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of agricultural technology, and in particular to a crop leaf disease identification method, device, electronic equipment and storage medium. Background Art

[0002] Timely detection and effective prevention of plant leaf diseases have become one of the important issues in agricultural development. Among these diseases, most occur in the leaves of crops, and leaf diseases will directly affect the quality and yield of crops, resulting in reduced economic benefits of crops.

[0003] At present, in the existing technology, the judgment of the type and severity of leaf diseases mainly relies on manual methods. However, this method is time-consuming and labor-intensive, and the accuracy of the judgment results is difficult to guarantee. Since the leaf manifestations of various diseases are very similar, this also increases the difficulty of disease judgment. There has been no effective means to timely and effectively discover diseases and take preventive measures.

[0004] Therefore, how to effectively improve the accuracy and efficiency of crop leaf disease identification is a technical problem that needs to be urgently solved in crop production and scientific research. Summary of the invention

[0005] The present invention provides a crop leaf disease identification method, device, electronic equipment and storage medium, which are used to effectively improve the crop leaf disease identification accuracy and efficiency.

[0006] The present invention provides a method for identifying crop leaf diseases, comprising:

[0007] Extracting a disease spot image from the acquired crop leaf disease image;

[0008] Performing feature extraction on the lesion image to obtain lesion features of the lesion image;

[0009] The spot features of the spot image are input into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

[0010] According to a crop leaf disease identification method provided by the present invention, the extracting of the diseased spot image in the crop leaf disease image comprises:

[0011] grayscale the crop leaf disease image to obtain a grayscale image corresponding to the crop leaf disease image;

[0012] Segmenting the leaf target area in the grayscale image to obtain a leaf area image;

[0013] The leaf region image is converted from the RGB color space to the LAB color space, and morphological image processing is performed on the leaf region image in the LAB color space to extract the disease spot image in the crop leaf disease image.

[0014] According to a crop leaf disease identification method provided by the present invention, the feature extraction of the lesion image to obtain the lesion feature of the lesion image includes:

[0015] Performing color feature extraction on the lesion image to obtain multiple color features of the lesion image in the RGB color space;

[0016] Extracting shape features of the lesion image to obtain a plurality of shape features of the lesion image;

[0017] Extracting texture features of the lesion image to obtain a plurality of texture features of the lesion image;

[0018] Based on a plurality of color features, a plurality of shape features and a plurality of texture features of the lesion image, lesion features of the lesion image are obtained.

[0019] According to a crop leaf disease identification method provided by the present invention, the multiple color features include first-order moments, second-order moments and third-order moments; the multiple shape features include area, eccentricity, major axis, minor axis and geometric invariant moments; the multiple texture features include energy, entropy, contrast and correlation.

[0020] According to a crop leaf disease identification method provided by the present invention, before inputting the disease spot features of the disease spot image into a target random deep forest model to obtain a disease identification result of the crop leaf disease image output by the target random deep forest model, the method further includes:

[0021] The target hyperparameters of the random forest model are optimized to obtain the optimized random forest model; the target hyperparameters include the number of decision trees and the number of screening features.

[0022] According to a crop leaf disease identification method provided by the present invention, the target hyperparameters of the random forest model are optimized to obtain the optimized random forest model, including:

[0023] Initializing a gray wolf optimization algorithm based on target hyperparameters of a random forest model to obtain a plurality of initial gray wolf populations; each of the initial gray wolf populations includes a plurality of gray wolf individuals;

[0024] Based on the fitness function, the gray wolf optimization algorithm is performed on each gray wolf individual in each of the initial gray wolf populations, and when a preset iteration termination condition is met, an optimal gray wolf individual with the minimum fitness value is obtained;

[0025] Based on the optimal gray wolf individual, the optimal value of the target hyperparameter is determined, and the optimal value of the target hyperparameter is substituted into the random forest model to obtain the optimized random deep forest model.

[0026] The present invention also provides a crop leaf disease identification device, comprising:

[0027] A first extraction module is used to extract a disease spot image from the acquired crop leaf disease image;

[0028] A second extraction module is used to extract features from the lesion image to obtain lesion features of the lesion image;

[0029] The first recognition module is used to input the spot features of the spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

[0030] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned methods for identifying crop leaf diseases is implemented.

[0031] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the crop leaf disease identification method as described in any one of the above is implemented.

[0032] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the crop leaf disease identification method as described above is implemented.

[0033] The crop leaf disease identification method, device, electronic device and storage medium provided by the present invention optimize the hyperparameters of the random forest model, and use the crop leaf disease image samples and their corresponding disease type labels to train the optimized random forest model to obtain a trained target random forest model, thereby improving the classification accuracy of the random forest model. Furthermore, by obtaining partial images of crop leaf disease spots and extracting the disease spot features, the images are input into the target random forest model to identify the type of disease, thereby judging whether the crop leaves are infected with the disease and the type of the disease, thereby improving the recognition accuracy and robustness of crop leaf diseases, effectively improving the recognition accuracy and efficiency of crop leaf diseases, and realizing accurate recognition of disease spots when they appear, so as to facilitate timely prevention and reduce crop leaf yield reduction and quality reduction caused by diseases. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 This is one of the flow charts of the crop leaf disease identification method provided by the present invention;

[0036] Figure 2 This is the second flow chart of the crop leaf disease identification method provided by the present invention;

[0037] Figure 3 It is a structural schematic diagram of the crop leaf disease identification device provided by the present invention;

[0038] Figure 4 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0039] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] In the description of the invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0041] Combine the following Figure 1-Figure 4 The invention describes a crop leaf disease identification method, device, electronic device and storage medium.

[0042] Figure 1 FIG. 1 is one of the flow charts of the crop leaf disease identification method provided by the present invention, such as Figure 1 As shown, including:

[0043] Step 110, extracting a disease spot image from the acquired crop leaf disease image;

[0044] Step 120, extracting features from the lesion image to obtain lesion features of the lesion image;

[0045] Step 130, input the spot features of the spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training the optimized random forest model based on the crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by optimizing the hyperparameters of the random forest model.

[0046] Specifically, the crop leaf disease image described in the embodiment of the present invention refers to an RGB image of crop leaves used for identifying the type of leaf disease, which can be obtained by photographing crops with leaf diseases using a pre-prepared image acquisition device such as a mobile phone, camera, etc.

[0047] The diseased spot image described in the embodiment of the present invention refers to an image containing only diseased pixel areas extracted from a crop leaf disease image by using image segmentation and processing technology.

[0048] The lesion feature described in the embodiment of the present invention refers to an image feature obtained by performing multi-dimensional image feature extraction on the lesion image, which can characterize the intrinsic relationship between the lesion image and the corresponding disease type.

[0049] The target random forest model described in the embodiment of the present invention refers to a classifier model obtained by training a random forest model optimized by hyperparameters based on crop leaf disease image samples and their corresponding disease type labels. It is mainly used to classify and identify diseases on the input lesion feature images and output the disease type corresponding to the lesion features.

[0050] In an embodiment of the present invention, the target random forest model can specifically optimize the hyperparameters (also described as RFC parameters) of the random forest model in advance through a parameter optimization algorithm, determine the random forest model under the optimal RFC parameters, and improve the classification accuracy of the random forest model; then, using the leaf disease image samples prepared in advance and the disease type label corresponding to each sample, the optimized random forest model is trained, and the network parameters of the random forest model are continuously iterated and optimized to obtain a trained random forest model, and the model is used as the target random forest model.

[0051] Among them, the model training samples are composed of multiple groups of crop leaf disease image samples carrying disease type labels.

[0052] The disease type labels described in the embodiment of the present invention are predetermined based on the crop leaf disease image samples and correspond one-to-one to the crop leaf disease image samples. That is, each crop leaf disease image sample in the training sample is predetermined to carry a corresponding disease type label.

[0053] In the embodiment of the present invention, various crop leaf disease image samples are collected by conducting field surveys in multiple locations, such as tea diseases, including tea white spot disease, tea algae spot disease, and tea anthracnose. Each disease sample is collected using a mobile phone or camera, and there are about 100 RGB images of each disease, thereby obtaining crop leaf disease image samples and their corresponding disease type labels; and about 3 / 4 of the samples are randomly selected as training sets, and the remaining about 1 / 3 of the sample data is used as a test set.

[0054] Among them, each crop leaf disease image sample in the training set and the test set needs to be processed to extract the lesion image and the lesion features of the lesion image. The lesion features corresponding to each crop leaf disease image sample and the corresponding disease type label are used to train the optimized random forest model to obtain a trained target random forest model.

[0055] More specifically, in an embodiment of the present invention, in step 110, a crop leaf disease image is acquired by an image acquisition device, and a disease spot image in the acquired crop leaf disease image can be extracted by an image segmentation processing method.

[0056] Furthermore, in an embodiment of the present invention, in step 120, an image feature extraction method may be used to extract features of the lesion image acquired in step 110 from the perspectives of color, texture, etc., so as to obtain lesion features of the lesion image.

[0057] Furthermore, in an embodiment of the present invention, in step 130, the lesion features of the extracted lesion image are input into the aforementioned pre-trained target random deep forest model. After the target random deep forest model classifies and recognizes the lesion features, a high-quality disease recognition result of the crop leaf disease image can be output.

[0058] The crop leaf disease identification method of the embodiment of the present invention optimizes the hyperparameters of the random forest model, and uses the crop leaf disease image samples and their corresponding disease type labels to train the optimized random forest model to obtain a trained target random forest model, thereby improving the classification accuracy of the random forest model. Furthermore, by obtaining partial images of crop leaf spots and extracting the features of the spots, the features are input into the target random forest model to identify the type of disease, thereby judging whether the crop leaves are diseased and the type of disease, thereby improving the recognition accuracy and robustness of crop leaf diseases, effectively improving the recognition accuracy and efficiency of crop leaf diseases, and realizing accurate recognition of spots when they appear, so as to facilitate timely prevention and reduce crop leaf yield reduction and quality reduction caused by diseases.

[0059] Based on the content of the above embodiment, as an optional embodiment, extracting a disease spot image from the acquired crop leaf disease image includes:

[0060] Grayscale processing is performed on the crop leaf disease image to obtain a grayscale image corresponding to the crop leaf disease image;

[0061] Segment the leaf target area in the grayscale image to obtain a leaf area image;

[0062] The leaf area image is converted from the RGB color space to the LAB color space, and morphological image processing is performed on the leaf area image in the LAB color space to extract the disease spot image from the crop leaf disease image.

[0063] Specifically, in an embodiment of the present invention, after obtaining the crop leaf disease image, the RGB image is processed to extract the diseased spot image. Specifically, the weighted average method can be used to calculate each component according to the importance of the three components of the RGB image according to different weights, and the RGB image can be converted into a grayscale image through the following grayscale processing formula, namely:

[0064] Gray(i,j)=0.299R(i,j)+0.587G(i,j)+0.114B(i,j));

[0065] Where R(i,j), G(i,j), and B(i,j) represent the red, green, and blue components of the pixel respectively; Gray(i,j) represents the grayscale value of the pixel.

[0066] Furthermore, in an embodiment of the present invention, the leaf target region in the obtained grayscale image is segmented to obtain a leaf region image. Specifically, by highlighting the target region in the grayscale image and reducing interference from non-target regions (such as equipment shaking during photography, light problems, dust in the air, etc.), the grayscale image is denoised using a median filtering method.

[0067] Then, the maximum between-class variance method (OTSU) is used to segment the leaf target area in the denoised grayscale image to obtain a complete leaf image. Among them, the least squares method can be used to obtain the most appropriate threshold. The background and target (i.e., leaf) areas are represented as X and Y respectively, and mx and my are used to represent the probability of the two areas appearing respectively, hx and hy are used to represent the average grayscale values ​​of the two areas, h represents the total average grayscale value of the entire image, and k represents the size of the threshold. The between-class variance can be expressed as S2(k)=mx(h-hx)2+(h-hy)2. When S2(k) is the maximum value, k is the most appropriate threshold obtained by the OTSU method. The denoised grayscale image is segmented by the threshold, the leaf area is segmented, and the RGB image of the leaf area is obtained, that is, the leaf area image is obtained.

[0068] Furthermore, in an embodiment of the present invention, the leaf area image is converted from the RGB color space to the LAB color space, wherein L represents brightness, and its value range is [0, 100]; A represents the component from red to green, and its value range is [127, -128]; and B represents the component from yellow to blue, and its value range is [127, -128].

[0069] Morphological image processing is performed on the leaf area image in the LAB color space. By extracting the LAB color space, removing the border pixels, erasing the part with an area less than 200, filling the holes, and setting the pixels that are not the target objects in the original image to 0, the color area of ​​the segmented binary image part is retained, and the image information except the diseased part is ignored in the RGB three color channels. The three channels are merged to extract the complete diseased spots in the crop leaf disease image and obtain the diseased spot image.

[0070] The method of the embodiment of the present invention performs grayscale processing on the crop leaf disease image to highlight the image brightness information, thereby facilitating better segmentation to obtain the leaf area image, and utilizes the chlorosis phenomenon of the crop diseased area to convert the leaf area image from the RGB color space to the LAB color space, and performs morphological image processing on the leaf area image in the LAB color space, so as to effectively and accurately extract the disease spot image in the crop leaf disease image, which is beneficial to improving the accuracy of subsequent crop leaf disease identification.

[0071] Based on the content of the above embodiment, as an optional embodiment, feature extraction is performed on the lesion image to obtain the lesion features of the lesion image, including:

[0072] Extract color features of the lesion image to obtain multiple color features of the lesion image in the RGB color space;

[0073] Extracting shape features of the lesion image to obtain multiple shape features of the lesion image;

[0074] Extracting texture features of the lesion image to obtain multiple texture features of the lesion image;

[0075] Based on multiple color features, multiple shape features and multiple texture features of the lesion image, lesion features of the lesion image are obtained.

[0076] Specifically, the multiple color features described in the embodiment of the present invention refer to color features of the lesion image in the RGB color space.

[0077] The multiple shape features described in the embodiments of the present invention refer to the geometric features that distinguish the lesion from the surrounding objects.

[0078] The multiple texture features described in the embodiment of the present invention refer to features used to reflect the surface texture of the lesion part in the lesion image, such as the thickness, size, direction, roughness, smoothness, etc. of the texture.

[0079] Based on the contents of the above embodiments, as an optional embodiment, multiple color features include first-order moments, second-order moments and third-order moments; multiple shape features include area, eccentricity, major axis, minor axis and geometric invariant moments; multiple texture features include energy, entropy, contrast and correlation.

[0080] Specifically, in an embodiment of the present invention, considering that color features are rarely affected by operations such as image size, direction, translation and rotation, and color distribution information is mainly concentrated in low-order moments, multiple color features can adopt the first-order moment (Mean), second-order moment (Variance) and third-order moment (Skewness) on R, G, and B color components, for a total of 9 color features (3 color components, each with 3 low-order moments).

[0081] Among them, the first-order moment is the expected value of the random variable, which indicates the mean or center position of the random variable; the second-order moment is the expected value of the square of the random variable's deviation from its expected value, which indicates the degree of discreteness of the random variable; the third-order moment is the expected value of the cube of the random variable's deviation from its expected value, which indicates the degree of skewness of the random variable distribution.

[0082] It can be understood that, in the embodiment of the present invention, the random variables are the pixel values ​​of the R, G, and B color components.

[0083] In an embodiment of the present invention, taking into account that the spots covering the surfaces of most leaves are numerous and dispersed, multiple shape features can specifically adopt area, eccentricity, major axis, minor axis and geometric invariant moments (Hu matrix), among which the Hu matrix includes 7 invariant moments, which can be expressed as H1 to H7, a total of 11 shape features.

[0084] In the embodiment of the present invention, the gray level co-occurrence matrix is ​​selected to calculate the texture features of the lesions, and the multiple texture features specifically use energy, entropy, contrast and correlation, a total of 4 texture features.

[0085] The method of the embodiment of the present invention selects a few color features, shape features and texture features by considering the distribution characteristics of the spots covering the leaf surface, as well as the color, shape and texture features presented. By using fewer features, it is possible to well characterize the intrinsic relationship between the spots and the disease type to which they belong, so that the subsequent disease classifier can quickly and effectively classify different disease types, which is conducive to further improving the accuracy and efficiency of crop leaf disease identification.

[0086] Furthermore, in an embodiment of the present invention, multiple color features, multiple shape features and multiple texture features of the lesion image are combined to constitute the lesion features of the lesion image, forming a feature parameter combination as input data for the next model to perform leaf disease identification operations.

[0087] The method of the embodiment of the present invention extracts image features of the disease spot image from the three aspects of color, shape and texture, thereby forming a rich and beneficial combination of feature parameters, providing reliable identification source data for the subsequent target random deep forest model to perform disease identification, which is beneficial to improving the accuracy of crop leaf disease identification.

[0088] Based on the content of the above embodiment, as an optional embodiment, before inputting the disease spot features of the disease spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model, the method further includes:

[0089] The target hyperparameters of the random forest model are optimized to obtain an optimized random deep forest model; the target hyperparameters include the number of decision trees and the number of screening features.

[0090] Specifically, in an embodiment of the present invention, before inputting the spot features of the spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model, it is necessary to perform model training on the target random deep forest model.

[0091] In an embodiment of the present invention, before model training, it is necessary to optimize the target hyperparameters of the random forest model, including optimizing the number of decision trees (T) and the number of screening features (M) in the hyperparameters of the random forest model, and finding the optimal number of decision trees and the number of screening features to facilitate better results in subsequent random forest model training.

[0092] Furthermore, after finding the optimal number of decision trees and the number of screening features, the optimal parameter values ​​can be used to update the corresponding hyperparameters in the random forest model, thereby obtaining a random forest model with updated hyperparameters, that is, an optimized random deep forest model.

[0093] The method of the embodiment of the present invention can better improve the training effect of the random forest model by optimizing the two hyperparameters of the number of decision trees and the number of screening features in the hyperparameters of the random forest model, which is beneficial to improving the accuracy of the model in identifying diseases.

[0094] Based on the content of the above embodiment, as an optional embodiment, the target hyperparameters of the random forest model are optimized to obtain an optimized random forest model, including:

[0095] Initialize the gray wolf optimization algorithm based on the target hyperparameters of the random forest model to obtain multiple initial gray wolf populations; each initial gray wolf population includes multiple gray wolf individuals;

[0096] Based on the fitness function, the gray wolf optimization algorithm is operated on each gray wolf individual in each initial gray wolf population, and the optimal gray wolf individual with the smallest fitness value is obtained when the preset iteration termination condition is met;

[0097] Based on the optimal gray wolf individual, the optimal value of the target hyperparameter is determined, and the optimal value of the target hyperparameter is substituted into the random forest model to obtain an optimized random deep forest model.

[0098] Specifically, in an embodiment of the present invention, the target hyperparameters of the random forest model are optimized using the Grey Wolf Optimizer (GWO).

[0099] It should be noted that the GWO algorithm can be compared to a pyramid mechanism. The top layer is responsible for managing everything. The upper layer has management authority over the lower layer. From top to bottom, they are α layer, β layer, δ layer and ω layer. Among them, the α layer is responsible for the decision-making mechanism, the β layer is used to help the α layer make decisions, when the α layer replaces, the β layer can become a candidate layer, the δ layer can manage the ω layer, and the ω layer is used to do the basic work of the entire pyramid.

[0100] In the optimization process, we first need to reconstruct the hierarchical structure of the wolf pack, and construct multiple gray wolf individuals with different values ​​based on the two hyperparameters of the random forest model, the number of decision trees and the number of screening features, to form multiple initial gray wolf populations. Then, based on the preset fitness function, by calculating the fitness of each gray wolf individual, sorting them from high to low according to the fitness, initialize the fitness function value of the α wolf, the fitness function value of the β wolf, and the fitness function value of the δ wolf, so as to complete the initialization of the gray wolf population.

[0101] In an embodiment of the present invention, the gray wolf optimization algorithm is further operated on each gray wolf individual in each initial gray wolf population. If the position of the gray wolf individual is between the maximum value and the minimum value, the position does not need to be adjusted. If it exceeds the maximum value, it returns to the maximum value boundary; if it exceeds the minimum value, it returns to the minimum value boundary. If the fitness function value is less than the fitness function value of the α wolf, the fitness function value of the α wolf is updated to the optimal fitness function value, and the position of the α wolf is updated to the optimal position; if the fitness function value is between the fitness function values ​​of the α wolf and the β wolf, the fitness function value of the β wolf is updated to the optimal fitness function value, and the position of the β wolf is updated; if the fitness function value is between the fitness function values ​​of the β wolf and the δ wolf, the fitness function value of the δ wolf is updated to the optimal fitness function value, and the position of the δ wolf is updated. At this time, the update of the individual positions of gray wolves at all levels is completed. After the wolf pack structure is updated, the "prey encirclement" operation needs to be performed, and the formula is as follows:

[0102] D=C*X P (txt);

[0103] X(t+1)=X P (t)-A*D;

[0104] A = 2a*r1-a;

[0105] C = 2r2;

[0106] Where t represents the current iteration number, * represents the Hadamard product operation; A and C represent the synergy coefficient vector; X P(t) represents the position vector of the prey; X(t) represents the position vector of the current gray wolf individual; during the entire iteration process, a decreases linearly from 2 to 0; r1 and r2 are random vectors in [0, 1].

[0107] Next, we need to find the optimal solution. In this process, we use α wolf, β wolf, and δ wolf to simulate the iterative behavior of finding the optimal solution. In each iteration, we retain the α wolf, β wolf, and δ wolf with the best results, and search for other optimal solutions based on this result. The specific formula is as follows:

[0108] D α =C1*X α -X,D β =C2*X β -X,D δ =C3*X δ -X;

[0109] x1=X a -A1*D α , X2=X β -A2*D β , X3=X δ -A3*D δ ;

[0110]

[0111] In the formula, X α , X β , X δ Respectively represent the position vectors of α wolf, β wolf, and δ wolf in the current population; X represents the position vector of the individual gray wolf; D α , D β , D δ They respectively represent the distance between the current candidate gray wolf individual and the best three gray wolf individuals; C1, C2, and C3 can be calculated by the formula of the above-mentioned synergy coefficient vector C; A1, A2, and A3 can be calculated by the formula of the above-mentioned synergy coefficient vector A.

[0112] Among them, when |A|>1, it means that the gray wolf individuals try to disperse in various areas and search for prey; when |A|<1, it means that the gray wolf individuals will concentrate on searching for prey in one or some areas. Finally, when the preset iteration termination conditions are met, the optimal solution can be obtained, and the optimal gray wolf individual with the smallest corresponding fitness value can be determined. Based on the optimal gray wolf individual, the optimal value of the target hyperparameter can be known, that is, the optimal RFC parameter can be obtained. The RFC parameters of the random forest model are updated to the optimal RFC parameters to obtain the optimized random deep forest model.

[0113] The method of the embodiment of the present invention, by using the gray wolf optimization algorithm to optimize the hyperparameters of the random forest model, finds the optimal RFC parameters of the random forest model, can further improve the convergence speed of the random forest model training, and improve the robustness of the model algorithm, and at the same time can improve the disease recognition accuracy of the trained target random forest model.

[0114] Figure 2 FIG. 2 is a flow chart of the crop leaf disease identification method provided by the present invention. Figure 2 As shown, in an embodiment of the present invention, taking tea as an example, whose diseases include tea algae spot disease, tea white star disease, and tea anthracnose, crop leaf disease images are obtained, and leaf disease images of different types of tea diseases are collected as image samples for subsequent model training.

[0115] In this embodiment, the original tea image sample spectral data set is divided into 300 sets of sample sets into training set samples and prediction set samples at a ratio of 4:1 by random sampling method, with 240 sets of training sets and 60 sets of test sets, so as to construct the data set.

[0116] For each leaf disease image sample, in the image preprocessing stage, the leaf disease image is first grayed to retain the characteristics of the RGB image and reduce the complexity of the image. The median filter denoising method is used for image enhancement. After median filter denoising, the small white noise points on the leaves directly grayed out in the original image are significantly weakened.

[0117] OTSU image segmentation is to distinguish the target from the background, and the tea leaf spots from the healthy part. The grayscale image is segmented by the maximum inter-class variance method to obtain the leaf area image, and the leaf area image is converted from the RGB color space to the LAB color space. Morphological image processing is performed on the leaf area image in the LAB color space. After four basic morphological processing operations, namely dilation, erosion, opening operation and closing operation, all pixels connected to the image boundary are cleared, and the holes in the image are filled to finally obtain the diseased spot image.

[0118] Furthermore, the color, shape, and texture features of the sample lesion images were extracted, including the first-order moment, second-order moment, and third-order moment of the R, G, and B color components, a total of 9 color features; including area, eccentricity, major axis, minor axis, and Hu matrix (H1-H7), a total of 11 shape features; including energy, entropy, contrast, and correlation, a total of 4 texture features. The results are shown in Table 1.

[0119] Table 1

[0120]

[0121]

[0122] Furthermore, extreme learning machine (ELM), decision tree (CART), neural network (BP), least squares support vector machine (LSSVM), random forest (RF) and random forest optimized by grey wolf algorithm (GWO-RF), namely target random forest model, were used to establish models for tea disease identification. Based on the feature sets obtained above, the recognition effects of various models were trained. The results are shown in Table 2.

[0123] Table 2

[0124]

[0125] At the same time, the model diagnosis results can be analyzed. From the above analysis results, it can be seen that the optimal model is the recognition model based on GWO-RF, and its recognition accuracy reaches 98.09%. The accuracy of the optimized random forest algorithm is 3.86% higher than that before optimization. Finally, the model is verified by taking the random sampling method, and the results are shown in Table 3.

[0126] Table 3

[0127]

[0128] In an embodiment of the present invention, a data cable is connected to a computer client to receive online detected crop leaf disease image data, and a GWO-RF detection model is established on the computer client using Matlab software. Finally, the detection model is imported into a mobile phone platform through a data transmission medium, and the image data collected by the camera is input into the detection model. The instrument automatically calculates and directly displays the recognition result on the operation interface, so that real-time dynamic online recognition of tea disease types can be achieved on the operation interface of the mobile phone.

[0129] The method of the embodiment of the present invention uses the optimized GWO-RF detection model for modeling and identification, which can effectively improve the model accuracy compared with other classifiers and obtain the highest recognition rate of all disease types. In subsequent practical applications, it can realize rapid and accurate in-situ identification of crop leaf disease types.

[0130] The crop leaf disease identification device provided by the present invention is described below. The crop leaf disease identification device described below and the crop leaf disease identification method described above can be referenced to each other.

[0131] Figure 3 : is a schematic diagram of the structure of the crop leaf disease identification device provided by the present invention, such as Figure 3 As shown, it includes: a first extraction module 310, a second extraction module 320 and a first recognition module 330 connected in sequence.

[0132] The first extraction module 310 is used to extract the diseased spot image from the acquired crop leaf disease image;

[0133] The second extraction module 320 is used to extract features from the lesion image to obtain lesion features of the lesion image;

[0134] The first recognition module 330 is used to input the spot features of the spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training the optimized random forest model based on the crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by optimizing the hyperparameters of the random forest model.

[0135] The crop leaf disease identification device described in this embodiment can be used to execute the above-mentioned crop leaf disease identification method embodiment, and its principles and technical effects are similar, which will not be repeated here.

[0136] The crop leaf disease identification device of the embodiment of the present invention optimizes the hyperparameters of the random forest model, and uses the crop leaf disease image samples and their corresponding disease type labels to train the optimized random forest model to obtain a trained target random forest model, thereby improving the classification accuracy of the random forest model. Furthermore, by obtaining partial images of crop leaf spots and extracting the features of the spots, the features are input into the target random forest model to identify the type of disease, thereby judging whether the crop leaves are diseased and the type of disease, thereby improving the recognition accuracy and robustness of crop leaf diseases, effectively improving the recognition accuracy and efficiency of crop leaf diseases, and realizing accurate recognition of spots when they appear, so as to facilitate timely prevention and reduce crop leaf yield reduction and quality reduction caused by diseases.

[0137] Figure 4 is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the crop leaf disease recognition method provided by the above methods, the method comprising: extracting a disease spot image from the acquired crop leaf disease image; performing feature extraction on the disease spot image to obtain the disease spot feature of the disease spot image; inputting the disease spot feature of the disease spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training the optimized random forest model according to the crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

[0138] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0139] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the crop leaf disease identification method provided by the above-mentioned methods, and the method includes: extracting a lesion image from the acquired crop leaf disease image; performing feature extraction on the lesion image to obtain the lesion features of the lesion image; inputting the lesion features of the lesion image into a target random deep forest model to obtain a disease identification result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

[0140] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the crop leaf disease identification method provided by the above-mentioned methods, the method comprising: extracting a lesion image from an acquired crop leaf disease image; performing feature extraction on the lesion image to obtain lesion features of the lesion image; inputting the lesion features of the lesion image into a target random deep forest model to obtain a disease identification result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

[0141] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0142] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for identifying crop leaf diseases, characterized in that: include: Extracting a disease spot image from the acquired crop leaf disease image; Performing feature extraction on the lesion image to obtain lesion features of the lesion image; The spot features of the spot image are input into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

2. The crop leaf disease identification method according to claim 1, characterized in that: The extracted disease spot image in the crop leaf disease image comprises: grayscale the crop leaf disease image to obtain a grayscale image corresponding to the crop leaf disease image; Segmenting the leaf target area in the grayscale image to obtain a leaf area image; The leaf region image is converted from the RGB color space to the LAB color space, and morphological image processing is performed on the leaf region image in the LAB color space to extract the disease spot image in the crop leaf disease image.

3. The crop leaf disease identification method according to claim 1, characterized in that: The step of extracting features from the lesion image to obtain lesion features of the lesion image includes: Performing color feature extraction on the lesion image to obtain multiple color features of the lesion image in the RGB color space; Extracting shape features of the lesion image to obtain a plurality of shape features of the lesion image; Extracting texture features of the lesion image to obtain a plurality of texture features of the lesion image; Based on a plurality of color features, a plurality of shape features and a plurality of texture features of the lesion image, lesion features of the lesion image are obtained.

4. The crop leaf disease identification method according to claim 3, characterized in that: The multiple color features include first-order moment, second-order moment and third-order moment; the multiple shape features include area, eccentricity, major axis, minor axis and geometric invariant moment; the multiple texture features include energy, entropy, contrast and correlation.

5. The crop leaf disease identification method according to any one of claims 1 to 4, characterized in that: Before inputting the disease spot features of the disease spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model, the method further includes: The target hyperparameters of the random forest model are optimized to obtain the optimized random forest model; the target hyperparameters include the number of decision trees and the number of screening features.

6. The crop leaf disease identification method according to claim 5, characterized in that: The step of optimizing the target hyperparameters of the random forest model to obtain the optimized random forest model includes: Initializing a gray wolf optimization algorithm based on target hyperparameters of a random forest model to obtain a plurality of initial gray wolf populations; each of the initial gray wolf populations includes a plurality of gray wolf individuals; Based on the fitness function, the gray wolf optimization algorithm is performed on each gray wolf individual in each of the initial gray wolf populations, and when a preset iteration termination condition is met, an optimal gray wolf individual with the minimum fitness value is obtained; Based on the optimal gray wolf individual, the optimal value of the target hyperparameter is determined, and the optimal value of the target hyperparameter is substituted into the random forest model to obtain the optimized random deep forest model.

7. A crop leaf disease identification device, characterized in that: include: A first extraction module is used to extract a disease spot image from the acquired crop leaf disease image; A second extraction module is used to extract features from the lesion image to obtain lesion features of the lesion image; The first recognition module is used to input the spot features of the spot image into the target random deep forest model to obtain the disease recognition result of the crop leaf disease image output by the target random deep forest model; the target random deep forest model is obtained by training an optimized random forest model based on crop leaf disease image samples and their corresponding disease type labels, and the optimized random forest model is obtained by performing hyperparameter optimization on the random forest model.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the crop leaf disease identification method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the crop leaf disease identification method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the crop leaf disease identification method according to any one of claims 1 to 6 is implemented.