Crop disease identification method, device and equipment and storage medium
By using a shallow feature extractor and genetic algorithm optimization with a two-branch structure in the crop disease recognition model, combined with the Lab color space characteristics, the problem of degradation of recognition performance under complex lighting background is solved, and accurate identification and real-time identification of crop diseases are achieved. Effect.
Patent Information
- Application Number
- CN202411077799.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-12-06
AI Technical Summary
The existing crop disease image recognition model has deteriorated performance under the background of complex lighting conditions, and the computational complexity is high and it is difficult to run in real time on resource-constrained devices.
The initial crop disease recognition model with shallow feature extractor with multiple double-branch structures is adopted, and the model parameters are adjusted through genetic algorithms to obtain the target crop disease recognition model, and the image features are processed in combination with Lab color space characteristics to enhance the receptive field of the model and Feature level.
The comprehensive analysis ability of crop disease recognition model to analyze image features is improved, accurate identification is achieved in the background of complex lighting, and real-time operation is achieved on resource-constrained devices, improving identification accuracy and efficiency.
Smart Images

Figure CN119091189A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition technology, and in particular to a crop disease recognition method, device, equipment and storage medium. Background Art
[0002] In the process of modern agricultural intelligence, accurate identification of crop diseases is crucial for timely prevention and control and ensuring crop yields. In recent years, the rapid evolution of deep learning technology has promoted the widespread application of image classification technology in the field of automatic identification of plant diseases, especially in the task of diseased leaf image classification.
[0003] However, existing crop disease image recognition models may have performance degradation when dealing with target recognition under complex lighting conditions. In addition, some image recognition models are difficult to run in real time on resource-constrained devices due to their high computational complexity.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a crop disease identification method, device, equipment and storage medium, aiming to solve the technical problem of how to accurately identify crop diseases based on crop images.
[0006] To achieve the above objectives, the present application proposes a method for identifying crop diseases, which comprises:
[0007] Get the preset crop image dataset;
[0008] Based on the preset crop image data set, a preset image recognition model is trained to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor having a plurality of double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions;
[0009] Adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model;
[0010] The target crop image is identified based on the target crop disease identification model to obtain a target crop disease identification result.
[0011] In one embodiment, the step of training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model includes:
[0012] Performing image preprocessing on the preset crop image dataset;
[0013] Converting the RGB color space of the preprocessed crop image dataset into the Lab color space to obtain a target crop image dataset;
[0014] A preset image recognition model is trained based on the target crop image data set to obtain an initial crop disease recognition model.
[0015] In one embodiment, the step of converting the RGB color space of the preprocessed preset crop image dataset into the Lab color space to obtain the target crop image dataset includes:
[0016] Converting the preprocessed RGB color space of the preset crop image data set into an XYZ color space;
[0017] The XYZ color space is converted into the Lab color space to obtain a target crop image dataset.
[0018] In one embodiment, the step of adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model includes:
[0019] Set the initial population size;
[0020] Selecting preset hyperparameters from the initial crop disease recognition model as individual genes;
[0021] Generate an initial population based on the initial population size and the individual genes through a preset genetic algorithm, and iterate the initial population to obtain a target individual;
[0022] Determining a target parameter of the preset hyperparameter based on the individual gene of the target individual;
[0023] The parameters of the initial crop disease identification model are adjusted based on the target parameters to obtain a target crop disease identification model.
[0024] In one embodiment, the step of iterating the initial population to obtain a target individual includes:
[0025] Set the number of iterations;
[0026] Evaluate the individuals of the initial population based on the evaluation index value of the initial crop disease recognition model to obtain an initial fitness calculation result;
[0027] Determining individuals participating in reproduction from the initial population based on the initial fitness calculation result;
[0028] Performing genetic operations on the individuals participating in reproduction based on the number of iterations to obtain a target population;
[0029] The individuals of the target population are evaluated based on the evaluation index value of the initial crop disease recognition model to obtain a target fitness calculation result, and a target individual is determined from the target population based on the target fitness calculation result.
[0030] In one embodiment, the initial crop disease recognition model includes a shallow feature extractor and a deep feature extractor, the shallow feature extractor includes a Lab double-branch filter, the deep feature extractor includes a first module, a second module and a third module connected in sequence, and the step of adjusting the parameters of the initial crop disease recognition model based on the target parameters to obtain the target crop disease recognition model includes:
[0031] The allocation rate, the number of first module layers, the number of second module layers and the number of third module layers of the Lab double-branch filter of the initial crop disease recognition model are adjusted based on the target parameters to obtain a target crop disease recognition model.
[0032] In one embodiment, the step of performing image preprocessing on the preset crop image dataset includes:
[0033] Performing image normalization on the preset crop image data set to obtain a normalized image;
[0034] Normalizing the normalized image to obtain a standardized image;
[0035] The standardized image is cropped to a preset pixel size to obtain the preprocessed preset crop image dataset.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a crop disease identification device, the crop disease identification device comprising:
[0037] A data acquisition module, used to acquire a preset crop image data set;
[0038] A model training module, used for training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor having a plurality of double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions;
[0039] A parameter adjustment module, used for adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model;
[0040] The image recognition module is used to recognize the target crop image based on the target crop disease recognition model to obtain the target crop disease recognition result.
[0041] In addition, to achieve the above-mentioned purpose, the present application also proposes a crop disease identification device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the crop disease identification method described above.
[0042] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the crop disease identification method described above are implemented.
[0043] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the crop disease identification method described above are implemented.
[0044] One or more technical solutions proposed in this application have at least the following technical effects:
[0045] A preset crop image data set is obtained, and a preset image recognition model is trained based on the preset crop image data set to obtain an initial crop disease recognition model. The head of the preset image recognition model is a shallow feature extractor with multiple dual-branch structures. Each branch of the dual branches in the shallow feature extractor is used to extract image features of different dimensions. The dual-branch structure weighted fusion strategy integrates two-way features, which enhances the comprehensive analysis and utilization capabilities of the crop disease recognition model for image features. The parameters of the initial crop disease recognition model are adjusted based on a genetic algorithm to obtain a target crop disease recognition model. The target crop image is recognized based on the target crop disease recognition model to obtain a target crop disease recognition result. According to the optimization result of the genetic algorithm, the optimal initial weight is assigned to the model to achieve optimal model performance, so that the target crop disease recognition model can accurately identify the category of crop diseased leaves, facilitate the screening of crops that meet the quality evaluation standards, and provide a reference for the selection of high-quality crops. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the crop disease identification method of the present application;
[0049] Figure 2 Schematic diagram of four crop data set samples provided for the first embodiment of the crop disease identification method of this application;
[0050] Figure 3 A double-branch structure network diagram provided for the first embodiment of the crop disease identification method of the present application;
[0051] Figure 4 A schematic diagram of the model training and image recognition process provided in Example 1 of the crop disease identification method of the present application;
[0052] Figure 5 A schematic diagram of a process flow provided for the second embodiment of the crop disease identification method of the present application;
[0053] Figure 6 A schematic diagram of a process for performing parameter optimization using a genetic algorithm provided in Example 2 of the crop disease identification method of this application;
[0054] Figure 7 A confusion matrix diagram of the target crop disease recognition model provided in Example 2 of the crop disease recognition method of this application on different data set test sets;
[0055] Figure 8 A network structure diagram of an initial crop disease identification model provided in Example 2 of the crop disease identification method of this application;
[0056] Fig. 9 The network structure diagram of the Inception-A, B, and C modules provided in Example 2 of the crop disease identification method of this application;
[0057] Fig.10 This is a schematic diagram of the module structure of the crop disease identification device according to an embodiment of the present application;
[0058] Fig.11 Schematic diagram of the device structure of the hardware operating environment involved in the crop disease identification method in the embodiment of the present application.
[0059] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0060] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0061] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0062] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a crop disease identification device, etc. The following takes the crop disease identification device as an example to illustrate this embodiment and the following embodiments.
[0063] Based on this, the present application embodiment provides a method for identifying crop diseases. Figure 1 , Figure 1 This is a flow chart of the first embodiment of the crop disease identification method of the present application.
[0064] In this embodiment, the crop disease identification method includes steps S10 to S40:
[0065] Step S10, obtaining a preset crop image dataset;
[0066] It should be noted that the preset crop image dataset is used to train the image recognition model to obtain the crop disease recognition model. The images in the preset crop image dataset should be marked with the crop disease conditions. Figure 2 , Figure 2 Schematic diagram of four crop data set samples provided for the first embodiment of the crop disease identification method of the present application. A publicly available crop data set can be selected as a preset crop image data set so as to compare the performance of the crop disease identification model of the present solution with the existing crop disease identification model based on a unified benchmark. Specifically, crop image data can be selected from the plantvillage data set, an open data set for plant disease identification research, as the preset crop image data set.
[0067] Step S20, training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor having a plurality of double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions;
[0068] It should be noted that the preset image recognition model can be a neural network deep learning model with image recognition function such as YOLOv5, InceptionV3, etc. After the model is trained based on the preset crop image data set, the model will be able to identify the disease conditions of the input crop images. The head of the neural network model is a shallow feature extractor with multiple dual-branch structures. The shallow feature extractor is used to extract low-level features such as image edges, textures, colors, etc. In the dual-branch structure, each branch is designed with different functions to extract features of different dimensions in the image. For example, one branch may be used to extract the color features of the image, while another branch may be used to extract the shape or texture features of the image. The shallow feature extractors with multiple dual-branch structures help to fully capture and express the disease features of crop images.
[0069] In addition, it should be noted that the dual-branch structure can be a dual-channel multi-scale feature fusion module for processing image features based on Lab color space characteristics. Applying multiple Lab color space dual-branch structures to the head shallow feature extractor expands the receptive field of the image recognition model and enriches the feature hierarchy and information content.
[0070] For details, please refer to Figure 3 , Figure 3 A dual-branch structure network diagram provided for the first embodiment of the crop disease identification method of this application. The dual-branch structure includes an L channel and an ab channel. The L channel is used to process the brightness information of the image, and the ab channel is used to process the color information of the image. Each channel has three convolutional layers with regularization and relu activation functions, and the features of the two branches are fused through the Contact feature, which integrates the high-level features of image brightness and color to improve the performance of the model in the recognition task. The following table gives examples of filter division under different Lab ratios.
[0071] Table 1
[0072]
[0073] In a feasible implementation manner, step S20, the step of training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, may include steps A11 to A13:
[0074] Step A11, performing image preprocessing on the preset crop image dataset;
[0075] It should be understood that the size, brightness and clarity of the images in the preset crop image dataset may vary. Preprocessing the images can reduce interference factors in the model training process, improve the quality and consistency of the image data, make it more suitable for model training, and thus improve the generalization ability and accuracy of the model. Image preprocessing may include operations such as resizing the image, enhancing the image contrast, and removing noise.
[0076] In a feasible implementation, step A11 may include steps B11 to B13:
[0077] Step B11, performing image normalization on the preset crop image data set to obtain a normalized image;
[0078] It should be noted that normalizing the images in the crop image dataset can eliminate the scale differences between images and ensure that all images have the same scale and range. The pixel values of the normalized image will be scaled to a specified range, such as [0,1]. The numerical differences of the features of the normalized image are small, which helps to speed up the model training and improve the convergence of the model.
[0079] Step B12, normalizing the normalized image to obtain a standardized image;
[0080] It should be noted that the normalized image can be standardized by subtracting the mean and dividing by the standard deviation, so that the pixel values of the image present a distribution with a mean of 0 and a variance of 1. Standardizing the image can reduce the correlation of the data and make the data easier to process and learn, which helps the model predict more accurately.
[0081] Step B13, cropping the standardized image to a preset pixel size to obtain the preprocessed preset crop image dataset.
[0082] It should be noted that the standardized images are cropped to a preset pixel size to ensure that all input images have the same fixed size before entering the model. This is because most deep learning models require the input size to be fixed, which helps the model better learn the local and global features of the image.
[0083] In the specific implementation, if the crop image dataset used is composed of 256×256 pixel images, the image size can be adjusted to 224×224, and data enhancement can be used to prevent the problem of overuse, such as adding diseased area images through different signal processing operations, image flipping, image offset, shearing, etc., to facilitate subsequent feature extraction.
[0084] Step A12, converting the RGB color space of the pre-processed preset crop image dataset into the Lab color space to obtain a target crop image dataset;
[0085] It should be noted that the RGB color space is composed of three primary colors: red (R), green (G), and blue (B), and the Lab color space is composed of three channels: brightness (L), chromaticity (A), and chromaticity (B). Under strong lighting conditions, the original leaf color in the RGB color space image is biased towards white due to the influence of lighting. In actual scenes, because the impact of pests on plant leaves is partial and small, most crop leaves are in a healthy state. Under the action of chlorophyll, most leaves should appear green. The enhanced image in the Lab color space is closer to the human visual system's perception of color, is less affected by changes in lighting and white balance, and can better distinguish different colors and textures. Converting crop leaf images from RGB color space to Lab color space can improve the accuracy of image processing and analysis, allowing the model to more accurately distinguish leaf diseases.
[0086] In a feasible implementation, step A12 may include steps B21 to B22:
[0087] Step B21, converting the RGB color space of the pre-processed preset crop image data set into the XYZ color space;
[0088] It should be noted that the RGB color space cannot be directly converted to the Lab color space. The RGB color space must be converted to the XYZ color space first, and then the XYZ color space must be converted to the Lab color space. The XYZ color space is a standard color space defined by the International Commission on Illumination. It is independent of a specific display device or output device and can provide a more uniform color representation. Using the XYZ color space as an intermediate space for conversion can ensure the consistency and accuracy of image colors under different devices and lighting conditions.
[0089] In addition, it should be noted that during the conversion process, the RGB space needs to be standardized first, and the RGB values of the image need to be converted from the range of [0,255] to [0,1]. Since the RGB values in the RGB color space are usually gamma-corrected, in order to eliminate the nonlinear effects of gamma correction and make the color space conversion more accurate, before converting them to the XYZ space, these RGB values need to be inversely gamma-corrected to convert them into linear RGB values.
[0090] Exemplarily, the RGB value linearization formula is as follows:
[0091]
[0092] After converting the linearized RGB value to XYZ value, the image in the XYZ color space can be obtained. The formula is as follows:
[0093]
[0094] The conversion matrix between RGB values and XYZ values is a conversion matrix based on the sRGB color space and the D65 light source setting. The sRGB color space is a standard RGB color space. D65 indicates that the color temperature of the light source is 6500 Kelvin, which is close to natural daylight at noon.
[0095] Step B22, converting the XYZ color space into the Lab color space to obtain a target crop image dataset.
[0096] It should be noted that the XYZ values need to be standardized first, and then the Lab values of the standardized XYZ values are converted to obtain the target crop image dataset in the Lab color space.
[0097] Exemplarily, the conversion formula is as follows:
[0098]
[0099] Among them, L*, a* and b* correspond to L, a and b, respectively, X n =95.047, Y n =100,Z n =108.883, the function definition formula of f(t) is as follows:
[0100]
[0101] Step A13: training a preset image recognition model based on the target crop image data set to obtain an initial crop disease recognition model.
[0102] It should be understood that before formally training the target crop image dataset, the dataset needs to be divided. In a specific implementation, it can be divided into a training set, a validation set, and a test set in a ratio of 7:1:2. The training set is used to train the preset image recognition model so that the model learns through the samples in the training set, adjusts its own parameters to minimize the prediction error or loss function, and obtains the initial crop disease recognition model. The validation set is used to subsequently adjust the hyperparameters of the initial crop disease recognition model based on the genetic algorithm and evaluate the performance of the model under different hyperparameters. The test set is used to simulate the performance of the model in real scenarios to evaluate the final performance and generalization ability of the model.
[0103] In a specific implementation, the InceptionV3 model that introduces a dual-branch structure for processing image features based on the lab color space characteristics can be used as a preset image recognition model. The specific training process includes: loading the divided data set into the InceptionV3 model, configuring the hyperparameter weights of the InceptionV3 model, configuring environmental variables, Epoch, batchsize and other related parameters, using the InceptionV3 model for training, and obtaining an initial crop disease recognition model.
[0104] Step S30, adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model;
[0105] It should be noted that the genetic algorithm is a heuristic search algorithm that imitates the principles of natural selection and genetics to optimize the solution to the problem. It first converts the abstract expression of the problem solution into a form that is easy to calculate, such as binary code or real number vector, and then randomly initializes an initial population containing multiple individuals. The fitness function is used to evaluate each individual in the population and quantify the quality of the individual solution. The higher the fitness value, the better the solution represented by the individual. The process of adjusting the parameters of the initial crop disease recognition model based on the genetic algorithm is to solve the optimal parameters of the model and obtain a model close to the global optimal performance, that is, the target crop recognition model.
[0106] Step S40, identifying the target crop image based on the target crop disease identification model to obtain a target crop disease identification result.
[0107] It should be understood that the target crop disease recognition model obtained through the above process can be directly used for disease recognition of crop disease images in real scenes and obtain disease recognition results with higher accuracy.
[0108] For details, please refer to Figure 4 , Figure 4 This is a schematic diagram of the model training and image recognition process provided in Example 1 of the crop disease identification method of this application. Figure 4As shown, a preset crop image dataset is loaded, the images of the preset crop image dataset are normalized, standardized and cropped in turn to obtain a preprocessed preset crop image dataset, the preprocessed preset crop image dataset is divided, and the divided training set is used to train a preset image recognition model to obtain an initial crop disease recognition model, the parameters of the initial crop disease recognition model are optimized based on a genetic algorithm, and a crop disease recognition model optimized by a deep network fusion genetic algorithm in a lab color space is obtained, the divided validation set is loaded into the model, the preset crop disease recognition result is obtained and the performance of the model is evaluated, when the performance evaluation result of the model does not meet expectations, the parameters of the model are fine-tuned and the test set is imported for re-evaluation, when the performance evaluation result of the model meets expectations, a target crop disease recognition model is obtained, the target crop image is identified based on the target crop disease recognition model, and the target crop disease recognition result is obtained.
[0109] In this implementation, a preset crop image data set is obtained, and a preset image recognition model is trained based on the preset crop image data set to obtain an initial crop disease recognition model. The head of the preset image recognition model is a shallow feature extractor with multiple dual-branch structures. Each branch of the dual branches in the shallow feature extractor is used to extract image features of different dimensions. The dual-branch structure weighted fusion strategy integrates two-way features, thereby enhancing the comprehensive analysis and utilization capabilities of the crop disease recognition model for image features. The parameters of the initial crop disease recognition model are adjusted based on a genetic algorithm to obtain a target crop disease recognition model. The target crop image is recognized based on the target crop disease recognition model to obtain a target crop disease recognition result. According to the optimization result of the genetic algorithm, the optimal initial weight is assigned to the model to achieve optimal model performance, thereby enabling the target crop disease recognition model to accurately identify the category of crop diseased leaves, thereby facilitating the screening of crops that meet quality assessment standards and providing a reference for the selection of high-quality crops.
[0110] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 5 , Figure 5 This is a flow chart of the second embodiment of the crop disease identification method of the present application. Step S30 of the crop disease identification method further includes steps S31 to S35:
[0111] Step S31, setting the initial population size;
[0112] It should be noted that the initial population size refers to the number of individuals processed simultaneously in the genetic algorithm. A larger initial population can increase the search space, cover the parameter space more comprehensively, and increase the probability of finding an optimal solution. Specifically, if the initial population size is set to 10, the generated initial population will contain 10 individuals.
[0113] Step S32, selecting preset hyperparameters from the initial crop disease recognition model as individual genes;
[0114] It should be noted that the preset hyperparameters are pre-determined model configuration options, i.e., adjustable parameters in the initial crop recognition model such as learning rate, hierarchy, activation function, etc. Selecting appropriate preset hyperparameters as individual genes can ensure that the genetic algorithm can evolve and optimize based on these parameters in each generation, maintaining directionality and targeting in the process of searching for the optimal individual.
[0115] Step S33, generating an initial population based on the initial population size and the individual genes by a preset genetic algorithm, and iterating the initial population to obtain a target individual;
[0116] It should be understood that through continuous iteration, the genetic algorithm can gradually optimize the individual genes in the population, that is, the combination of preset hyperparameters, to obtain the optimal individual, that is, the target individual, that is, the crop disease recognition model. This iterative process helps to find a better performance parameter combination from a large number of possible hyperparameter configurations, and improve the accuracy and generalization ability of the model.
[0117] In a feasible implementation, step S33 may include steps A21 to A25:
[0118] Step A21, setting the number of iterations;
[0119] It should be understood that the number of iterations determines the number of rounds that the genetic algorithm searches for the target individual. This is one of the termination conditions of the algorithm, which is used to limit the algorithm running time and prevent infinite loops. The appropriate number of iterations can ensure that the algorithm has enough time to explore the solution space while avoiding unnecessary computational overhead.
[0120] Step A22, evaluating the individuals of the initial population based on the evaluation index value of the initial crop disease recognition model to obtain an initial fitness calculation result;
[0121] It should be noted that for the classification model crop disease recognition model, accuracy, specificity, recall and F1-score can be used as evaluation indicators. The values of each evaluation indicator can be calculated by referring to the following table. Among them, TP is used to indicate the number of samples correctly predicted as this category, TN is used to indicate the number of all samples correctly predicted as not belonging to this category by the model, FP is used to indicate the number of samples incorrectly predicted as this category by the model, and FN is used to indicate the number of samples belonging to this category that the model failed to correctly identify.
[0122] Table 2
[0123]
[0124] It should be understood that by evaluating the fitness of each individual in the initial population based on the evaluation index value, the performance of the preset hyperparameter combination corresponding to each individual in the crop disease recognition model can be obtained.
[0125] The calculation formula of fitness is as follows:
[0126]
[0127] Step A23, determining individuals participating in reproduction from the initial population based on the initial fitness calculation result;
[0128] It should be understood that selecting individuals with better performance for reproduction based on the fitness calculation results helps the genetic algorithm to focus resources on individuals that are more likely to produce better performance, thereby obtaining target individuals with better performance.
[0129] Step A24, performing genetic operations on the individuals participating in reproduction based on the number of iterations to obtain a target population;
[0130] It should be noted that genetic operations include screening, crossover, and mutation. By combining and modifying the genes of individuals to generate new individuals, the possibility of obtaining individuals with better fitness in the offspring population can be increased. Among them, crossover simulates the biological chromosome exchange process, by randomly selecting partial gene sequences of two different individuals for exchange, so as to obtain better offspring carrying genes of both parties. Mutation imitates the gene mutation phenomenon in nature, randomly makes slight modifications to certain genes of individuals, introduces new genetic diversity, and prevents the algorithm from falling into local optimality too early. Each iteration represents a round of genetic operations (such as screening, crossover, mutation). When the number of iterations is reached, the final population obtained is the target population.
[0131] Step A25, evaluating the individuals of the target population based on the evaluation index value of the initial crop disease recognition model to obtain a target fitness calculation result, and determining a target individual from the target population based on the target fitness calculation result.
[0132] It should be understood that by evaluating the target individuals obtained after multiple rounds of genetic operations, the performance of the target population can be determined, and the individual with the largest fitness value is used as the target individual.
[0133] Step S34, determining the target parameter of the preset hyperparameter based on the individual gene of the target individual;
[0134] It should be understood that after a preset number of iterations, the genetic algorithm will identify the best performing individual, i.e., the target individual, which represents the best hyperparameter combination found so far. After obtaining the individual genes of the target individual, i.e., the preset hyperparameter configuration, the optimal parameters of the crop disease recognition model, i.e., the target parameters, can be determined.
[0135] In a specific implementation, for the improved InceptionV3 model with a dual-branch Lab dual-branch filter, the allocation rate of the Lab dual-branch filter and the number of Inception-A, B, and C module layers can be used as genes, the allocation rate gene of the Lab dual-branch filter is set in the range of 0 to 1, the number of Inception-A blocks is set in the range of 1 to 3, the number of Inception-B blocks is set in the range of 1 to 4, and the number of Inception-C blocks is set in the range of 1 to 2. The following table shows the best hyperparameter combinations on four datasets, namely, the tomato leaf dataset, the corn leaf dataset, the apple leaf dataset, and the barley leaf dataset, where LabR represents the allocation rate of the Lab dual-branch filter, IA, IB, IC represent the number of modules of Inception-A, Inception-B, and Inception-C, respectively, Total P represents all parameters, and Trainable P represents available parameters.
[0136] Table 3
[0137]
[0138] Step S35, adjusting the parameters of the initial crop disease recognition model based on the target parameters to obtain a target crop disease recognition model.
[0139] It should be understood that after applying the target parameters determined by the genetic algorithm to the model to adjust the preset hyperparameters of the crop disease identification model, the obtained target crop disease identification model will perform more accurately in training and predicting crop diseases.
[0140] For details, please refer to Figure 6 , Figure 6 A flow chart of parameter optimization using a genetic algorithm provided in Example 2 of the crop disease identification method of this application. Figure 6 As shown, after setting the initial population size and the number of iterations, the initial population will be obtained to complete the selection of the initial cluster. The fitness of the individuals in the initial population is calculated based on the evaluation index value of the initial crop disease recognition model to obtain the initial fitness calculation result. The individuals participating in reproduction are screened based on the fitness calculation result, and genetic operations (crossover, mutation) are performed on the individuals participating in reproduction to obtain a new generation of populations. The individual with the maximum fitness is selected as the optimal individual, i.e., the target individual. When the number of iterations is reached, the optimal parameters, i.e., the target parameters, are obtained based on the optimal individual. The target parameters are used for the initial crop disease recognition model training. After the termination conditions are met, the target crop disease recognition model is obtained. The model is saved and loaded into the test set to obtain the recognition and evaluation results of the model. Please refer to Figure 7 , Figure 7 The confusion matrix diagram of the target crop disease recognition model provided in Example 2 of the crop disease recognition method of this application on different data set test sets shows the prediction of the model on each category. By analyzing the confusion matrix, the accuracy, specificity, sensitivity and F1 score of the model on different categories of the tomato leaf dataset, corn leaf dataset, apple leaf dataset and barley leaf dataset can be evaluated, and the results in the following table are obtained.
[0141] Table 4
[0142]
[0143] surface
[0144]
[0145] surface
[0146]
[0147] surface
[0148]
[0149] In a feasible implementation, step S35 may include: adjusting the allocation rate, the number of first module layers, the number of second module layers and the number of third module layers of the Lab dual-branch filter of the initial crop disease identification model based on the target parameters to obtain the target crop disease identification model.
[0150] It should be noted that the crop disease recognition model includes a shallow feature extractor, a deep feature extractor and a classifier. The Lab dual-branch filter is located in the shallow feature extractor part of the crop disease recognition model. It refers to the dual-branch structure used in the Lab color space to extract shallow features of the image. The allocation rate of the Lab dual-branch filter refers to the weights assigned to the two branches in the crop disease recognition model. Adjusting the allocation rate can balance the model's emphasis on different features, so that the model can more effectively extract useful information from the image and improve the accuracy of recognition.
[0151] In addition, it should be noted that the first module, the second module and the third module are located in the deep feature extractor part of the crop disease recognition model, which have different design features to meet the different needs of deep feature extraction. In the deep feature extractor, the first module, the second module and the third module are connected in sequence, and multiple identical modules are stacked together to form a stage. Among them, the first module is located in the early stage of the deep feature extractor, which usually contains several parallel branches, each branch uses a convolution kernel of different sizes, and the outputs of these branches are finally spliced together to form a richer feature map, which is used to gradually increase the dimension of the feature while maintaining computational efficiency. The second module is located in the middle part of the deep feature extractor, which introduces factor decomposition convolution to further improve computational efficiency, decomposing the traditional n×n convolution into two smaller one-dimensional convolutions, such as decomposing the 7x7 convolution into 1x7 and 7x1 continuous convolutions, to reduce the number of parameters and the amount of calculation. The third module is located in the late part of the deep feature extractor, at which time the size of the feature map has been reduced. This module continues to use factor decomposition convolution and is more sophisticated in design than the second module to further refine and enhance feature representation. The design of different modules enables the model to effectively capture the features of the image at different levels while maintaining high computational and memory efficiency. The increase or decrease in the number of layers of different modules will affect the complexity and learning ability of the model. By adjusting the number of module layers with different characteristics, the model can be better adapted to the task of crop disease identification.
[0152] For details, please refer to Figure 8 , Figure 8 This is a network structure diagram of the initial crop disease identification model provided in Example 2 of the crop disease identification method of this application. Figure 8As shown, the initial crop disease recognition model includes a shallow feature extractor with two dual-branch Lab dual-branch filters, a deep feature extractor (i.e., InceptionX) and a classifier with multiple layers of sequentially connected Inception-A modules, Inception-B modules, and Inception-C modules. The Inception-A module, the Inception-B module, and the Inception-C module correspond to the first module, the second module, and the third module, respectively. The Inception-A, B, and C modules are connected in sequence, and in the deep feature extractor, multiple identical modules are stacked together to form a stage. For example, multiple Inception-A modules may appear in succession until the model enters the next stage and inserts a transition module that reduces the spatial size, such as a Reduction module, and then connects multiple Inception-B modules, and so on.
[0153] Please refer to Fig. 9 , Fig. 9 The network structure diagram of the Inception-A, B, and C modules provided in Example 2 of the crop disease identification method of this application. Among them, multiple Inception-A modules are stacked in the early part of the deep feature extractor to extract preliminary features from the input image and obtain rich feature maps. Multiple Inception-B modules are stacked in the middle part of the deep feature extractor for further feature learning. Multiple Inception-C modules are stacked in the late part of the deep feature extractor for final feature extraction.
[0154] This embodiment uses a genetic algorithm to globally optimize the model structure and hyperparameters, including the allocation rate of the Lab dual-branch filter of the initial crop disease recognition model, the number of first module layers, the number of second module layers, and the number of third module layers. By simulating natural selection and genetic mechanisms, the model architecture is dynamically adjusted to find the optimal model configuration, thereby improving the accuracy of the crop disease recognition model and the efficiency of model training.
[0155] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the crop disease identification method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0156] This application also provides a crop disease identification device, please refer to Fig.10 , the crop disease identification device comprises:
[0157] A data acquisition module 10 is used to acquire a preset crop image data set;
[0158] A model training module 20 is used to train a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor with multiple double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions;
[0159] A parameter adjustment module 30, for adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model;
[0160] The image recognition module 40 is used to recognize the target crop image based on the target crop disease recognition model to obtain a target crop disease recognition result.
[0161] The crop disease identification device provided by the present application adopts the crop disease identification method in the above embodiment, and can solve the technical problem of how to accurately identify crop diseases based on crop images. Compared with the prior art, the beneficial effects of the crop disease identification device provided by the present application are the same as the beneficial effects of the crop disease identification method provided by the above embodiment, and other technical features in the crop disease identification device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0162] The present application provides a crop disease identification device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the crop disease identification method in the above-mentioned embodiment 1.
[0163] Reference below Fig.11 , which shows a schematic diagram of the structure of a crop disease identification device suitable for implementing the embodiment of the present application. The crop disease identification device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.11 The crop disease identification device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0164] like Fig.11As shown, the crop disease identification device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the crop disease identification device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the crop disease identification device to communicate wirelessly or wired with other devices to exchange data. Although the crop disease identification device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0165] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0166] The crop disease identification device provided by the present application adopts the crop disease identification method in the above embodiment, which can solve the technical problem of how to accurately identify crop diseases based on crop images. Compared with the prior art, the beneficial effects of the crop disease identification device provided by the present application are the same as the beneficial effects of the crop disease identification method provided by the above embodiment, and the other technical features of the crop disease identification device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0167] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0168] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0169] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the crop disease identification method in the above-mentioned embodiment.
[0170] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0171] The computer-readable storage medium may be included in the crop disease identification device; or may exist independently without being assembled into the crop disease identification device.
[0172] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a crop disease recognition device, the crop disease recognition device: obtains a preset crop image data set; trains a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor with multiple double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions; adjusts the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model; recognizes a target crop image based on the target crop disease recognition model to obtain a target crop disease recognition result.
[0173] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0174] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0175] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0176] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned crop disease identification method, and can solve the technical problem of how to accurately identify crop diseases based on crop images. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the crop disease identification method provided in the above-mentioned embodiment, and will not be repeated here.
[0177] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned crop disease identification method when executed by a processor.
[0178] The computer program product provided by the present application can solve the technical problem of how to accurately identify crop diseases based on crop images. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the crop disease identification method provided by the above embodiment, which will not be repeated here.
[0179] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for identifying crop diseases, characterized in that: The crop disease identification method comprises: Get the preset crop image dataset; Based on the preset crop image data set, a preset image recognition model is trained to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor having a plurality of double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions; Adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model; The target crop image is identified based on the target crop disease identification model to obtain a target crop disease identification result.
2. The crop disease identification method according to claim 1, characterized in that: The step of training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model comprises: Performing image preprocessing on the preset crop image dataset; Converting the RGB color space of the preprocessed crop image dataset into the Lab color space to obtain a target crop image dataset; A preset image recognition model is trained based on the target crop image data set to obtain an initial crop disease recognition model.
3. The crop disease identification method according to claim 2, characterized in that: The step of converting the RGB color space of the preprocessed preset crop image dataset into the Lab color space to obtain the target crop image dataset comprises: Converting the preprocessed RGB color space of the preset crop image data set into an XYZ color space; The XYZ color space is converted into the Lab color space to obtain a target crop image dataset.
4. The crop disease identification method according to claim 1, characterized in that: The step of adjusting the parameters of the initial crop disease identification model based on the genetic algorithm to obtain the target crop disease identification model includes: Set the initial population size; Selecting preset hyperparameters from the initial crop disease recognition model as individual genes; Generate an initial population based on the initial population size and the individual genes through a preset genetic algorithm, and iterate the initial population to obtain a target individual; Determining a target parameter of the preset hyperparameter based on the individual gene of the target individual; The parameters of the initial crop disease identification model are adjusted based on the target parameters to obtain a target crop disease identification model.
5. The crop disease identification method according to claim 4, characterized in that: The step of iterating the initial population to obtain a target individual includes: Set the number of iterations; Evaluate the individuals of the initial population based on the evaluation index value of the initial crop disease recognition model to obtain an initial fitness calculation result; Determining individuals participating in reproduction from the initial population based on the initial fitness calculation result; Performing genetic operations on the individuals participating in reproduction based on the number of iterations to obtain a target population; The individuals of the target population are evaluated based on the evaluation index value of the initial crop disease recognition model to obtain a target fitness calculation result, and a target individual is determined from the target population based on the target fitness calculation result.
6. The crop disease identification method according to claim 4, characterized in that: The initial crop disease recognition model includes a shallow feature extractor and a deep feature extractor, the shallow feature extractor includes a Lab double-branch filter, the deep feature extractor includes a first module, a second module and a third module connected in sequence, and the step of adjusting the parameters of the initial crop disease recognition model based on the target parameters to obtain the target crop disease recognition model includes: The allocation rate, the number of first module layers, the number of second module layers and the number of third module layers of the Lab double-branch filter of the initial crop disease recognition model are adjusted based on the target parameters to obtain a target crop disease recognition model.
7. The crop disease identification method according to claim 2, characterized in that: The step of performing image preprocessing on the preset crop image dataset comprises: Performing image normalization on the preset crop image data set to obtain a normalized image; Normalizing the normalized image to obtain a standardized image; The standardized image is cropped to a preset pixel size to obtain the preprocessed preset crop image dataset.
8. A crop disease identification device, characterized in that: The device comprises: A data acquisition module, used to acquire a preset crop image data set; A model training module, used for training a preset image recognition model based on the preset crop image data set to obtain an initial crop disease recognition model, wherein the head of the preset image recognition model is a shallow feature extractor having a plurality of double-branch structures, and each branch of the double branches in the shallow feature extractor is used to extract image features of different dimensions; A parameter adjustment module, used for adjusting the parameters of the initial crop disease recognition model based on a genetic algorithm to obtain a target crop disease recognition model; The image recognition module is used to recognize the target crop image based on the target crop disease recognition model to obtain the target crop disease recognition result.
9. A crop disease identification device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the crop disease identification method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the crop disease identification method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Diagnosis and control method for diseases and insect pests of transplanted red beans
CN120564041A
Diagnosis and control method of pests and diseases of rock lily
CN120564041B
