A crop disease and pest classification and identification method based on an InheritfeatNet algorithm
By using the InheritfeatNet algorithm and the image intelligent processing module IPS, the problems of low recognition accuracy and high computational cost of crop pests and diseases in outdoor noise environments are solved. This achieves efficient and accurate pest and disease recognition and reduces the requirements for equipment configuration, making it suitable for mobile device applications.
Patent Information
- Application Number
- CN202211647227.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2042-12-21
AI Technical Summary
Existing crop pest and disease identification technologies suffer from poor recognition performance in noisy outdoor environments with low image quality, and also have high computational costs, making them unsuitable for mobile devices.
A crop pest and disease identification and classification network is constructed using the InheritfeatNet algorithm. Preprocessing is performed using the Intelligent Image Processing Module (IPS), including blur detection, skew correction, and information enhancement. The computational requirements are reduced through a multi-modal feature extraction strategy.
It improves the accuracy of pest and disease identification by 10%-15%, reduces the requirements for equipment configuration, and has stronger universality and robustness, making it suitable for mobile device applications.
Smart Images

Figure CN116189175B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of deep learning, specifically relating to a method for classifying and identifying crop diseases and pests based on the InheritfeatNet algorithm. Background Technology
[0002] In recent years, various crop diseases and pests have remained prevalent in my country. These pests and pests are characterized by their large coverage area, high incidence rate, diverse types, and frequent outbreaks that cause widespread damage. Once an outbreak occurs, it directly leads to reduced crop yields and a severe decline in quality, causing significant losses to my country's agricultural production. Because farmers often rely on traditional experience for rough judgments and utilize readily available pesticides and agricultural supplies, they implement simple and crude control measures. This pesticide overuse not only directly leads to ecological imbalance but also harms public health. Currently available crop disease and pest identification technologies perform poorly in noisy outdoor environments and require high-quality images uploaded by users. Traditional identification and classification networks can accurately classify and identify targets when they are clear and distinct, but their performance is poor in noisy environments and under conditions of low image quality.
[0003] Zhang et al. designed a system for judging the pathogen infection of apple leaves using deep learning technology. The researchers divided the collected apple leaves into four categories: healthy leaves, leaves in the early stage of infection, leaves in the middle stage of infection, and leaves in the late stage of infection. Using the VGG16 model for leaf classification, the accuracy rate reached 90.4%. In 2017, Ramcharan et al. from Pennsylvania State University applied transfer learning to train a deep convolutional neural network for cassava pest and disease identification, maintaining an average recognition accuracy of 90%. Liu Tianyu et al. from Gansu Agricultural University trained a regional Faster R-CNN model on collected images and used a classifier to classify and identify the images, achieving an accuracy rate of 60.56%–75.52% for identifying diseased leaves. Tang Xianlun et al. proposed a conditional deep convolutional generative adversarial network model, which combines the advantages of deep convolutional generative adversarial networks and conditional generative adversarial networks. This model achieved an accuracy rate of 84% on the CIFAR10 dataset and reached 90% in crop disease identification and classification. Therefore, the accuracy of existing crop disease and pest identification and classification algorithms is relatively low.
[0004] InheritfeatNet is an algorithm for object recognition and classification that prevents the vanishing gradient problem and the loss of important feature information. It interconnects all layers of a convolutional neural network, allowing each layer to receive additional input from the previous layer and inherit all its features. To reduce computational costs, a feature inheritance region is defined. After each convolution operation, pooling and feature extraction are performed to generate a feature matrix. As feature propagation continues, the feature matrix is continuously updated. Ultimately, this achieves efficient recognition and classification while reducing the number of parameters, significantly lowering computational requirements and facilitating the algorithm's portability to mobile devices for widespread application. Summary of the Invention
[0005] To address the issues of low recognition accuracy and high computational cost in existing algorithms due to unclear user-uploaded images, non-centered target subjects, and crop occlusion, which prevent portability to mobile terminals, this invention proposes a crop pest and disease classification and recognition method based on the InheritfeatNet algorithm. It introduces an intelligent image processing (IPS) module and constructs a crop pest and disease recognition and classification network model based on the InheritfeatNet algorithm. This model improves the accuracy of pest and disease recognition and classification while reducing the requirements for device configuration, exhibiting greater universality and robustness.
[0006] The technical solution of the present invention is as follows:
[0007] A method for identifying crop diseases and pests based on the InheritfeatNet algorithm includes the following steps:
[0008] Step 1: Obtain images of various types of crop diseases and pests, and create a sample dataset of crop diseases and pests.
[0009] Step 2: Construct an image intelligent processing (IPS) module to preprocess the input image;
[0010] Step 3: Build a crop disease and pest identification and classification network model based on the InheritfeatNet algorithm;
[0011] Step 4: Train and optimize the constructed crop disease and pest identification and classification network model;
[0012] Step 5: Evaluate the trained crop pest and disease identification and classification network model, and output and save the model with good evaluation performance;
[0013] Step 6: Use the trained crop pest and disease identification and classification network model to identify the input image; provide intelligent feedback to the user during the image acquisition and identification process.
[0014] Furthermore, in step 1, the sample dataset includes publicly available datasets from existing databases of various types of crop diseases and pests, as well as images of crop diseases and pests collected through field photography using equipment. The sample dataset is a labeled dataset of crop diseases and pests, including different disease and pest data collected from different crops at different times of onset, different disease sites, and different growth stages.
[0015] Furthermore, the specific process of step 2 is as follows:
[0016] Step 2.1: First, determine whether the main subject of the image is blurred. Use the Sobel detection operator to extract the gradient values in the horizontal and vertical directions of the image. Then, evaluate the degree of blur in the input image using the Tenengrad evaluation function. The specific formula is as follows:
[0017]
[0018]
[0019] Where (x,y) are the coordinates of an edge point in the 2D image, Sobel(x,y) represents the gradient of the image at point (x,y), and G... x G y , respectively, are the grayscale values of the horizontal and vertical edge detection images, I(x,y) represent the original image; Tenengrad represents the image sharpness evaluation index, and n represents the total number of pixels in the image;
[0020] Step 2.2: Use the angle measurement method to determine if there is image skew. The specific process of the angle measurement method is as follows: Define alpha as the angle of rotation around the Z-axis when the device is placed horizontally; beta as the angle of rotation around the X-axis when the device is placed horizontally; gamma as the angle of rotation around the Y-axis when the device is placed horizontally. If the gamma of the current image exceeds the set range, it is determined that there is skew.
[0021] Step 2.3: Process the image accordingly based on the evaluation results;
[0022] The combined detection results from steps 2.1 and 2.2 yield four evaluation outcomes: clear and skewed, clear and not skewed, blurry and not skewed, and blurry and skewed.
[0023] When the evaluation result is clear and not skewed, no image processing is performed;
[0024] When the evaluation result is blurry and skewed, the main body of the skewed image is first corrected according to the principle of perspective transformation; then the image information enhancement process is performed on the image after correction transformation.
[0025] When the evaluation result is clear skew, only the image is corrected;
[0026] When the evaluation result is blurry but not skewed, only information enhancement operations are performed on the image.
[0027] Furthermore, the specific process of correction is as follows:
[0028] Outside the diseased leaf, eight feature points are randomly selected based on the leaf outline. Each feature point is expanded by the same step size along the gradient direction of that point. The change in pixel value is used to determine whether the leaf is completely included. The feature matrix corresponding to each point is input into the perspective transformation equation. Each feature point (x,y) corresponds to a target point (x',y'). According to the correspondence between the plane coordinates and homogeneous coordinates in formula (3), the perspective transformation matrix equation is obtained. The coordinates of the eight transformed points are obtained by solving the perspective transformation matrix equations corresponding to the eight points in formula (4). Then, the original image is transformed to this position using formula (5) to obtain the corrected image. The specific formulas used in this part are as follows:
[0029]
[0030]
[0031]
[0032] Where w is the extended dimension variable, R is the two-dimensional coordinate point in the real number field, and P is the three-dimensional coordinate point in the projective space; fg 1~8 This represents eight feature points selected around the image, T represents the target region to be identified and classified, scr represents the original input feature matrix, dst represents the processed output feature matrix, and M represents the feature matrix corresponding to each coordinate point. 11 Let fg1 be the feature matrix corresponding to the position.
[0033] Furthermore, the specific process of image information enhancement is as follows:
[0034] Using Gamma transformation, with the input gray level r as a baseline (r=1), when r>1, the image stretches high-gray-level regions while compressing low-gray-level regions; when r<1, the opposite operation is performed. The specific formula used in this part is as follows:
[0035] s = cr γ (6)
[0036] Where r and s represent the input and output gray levels, respectively, c is the gray-level scaling factor, and γ represents the gray-level mapping method between the input and output images. When γ>1, the contrast of the high gray-level regions of the image is enhanced; when γ<1, the contrast of the low gray-level regions of the image is enhanced; when γ=1, the original image is not changed.
[0037] Furthermore, in step 3, the InheritfeatNet algorithm employs a multi-modal feature extraction strategy, concatenating multiple InheritfeatZones. Each InheritfeatZone generates a feature matrix, which is then passed to every subsequent InheritfeatZone to participate in subsequent convolution operations. This process is repeated until the image feature extraction is complete. Simultaneously, a transmission parameter i is set, representing the number of layers the feature matrix is passed to. The InheritfeatZone connection formula is expressed as:
[0038] X i+1 =Inheritfeat(X0,X1,…X i (7)
[0039] Where X represents the characteristic matrix, X i+1 Let i be the feature map synthesized from i feature maps, and let Inheritfeat(·) denote the connection function.
[0040] Furthermore, the specific process of step 4 is as follows:
[0041] Step 4.1: Divide the sample dataset obtained in Step 1 and processed in Step 2 into training set, test set and validation set according to the random sampling principle;
[0042] Step 4.2: Input the training set and validation set into the crop pest and disease identification and classification network model for training, and obtain the output results;
[0043] Step 4.3: Input the predicted values and label values into the loss function to obtain the training loss; use the cross-entropy loss function; the cross-entropy loss function is defined as follows:
[0044]
[0045] Among them, y i For the label value, y i 'This is the predicted value;
[0046] Step 4.4: Adjust the model parameters based on the training loss and optimize the model using an optimizer; simultaneously, validate the model results using a validation set to obtain the final trained and optimized recognition network; use the Adam optimizer to adjust the model update weights and bias parameters θ. t θ t It is obtained from the following formula,
[0047]
[0048] Where α is the learning rate, m i For the first moment estimate of the gradient, v t∈ is the second moment estimate of the gradient, and ∈ is a constant added to maintain numerical stability.
[0049] Furthermore, in step 5, a test set is used for evaluation. The model is evaluated using an accuracy metric based on the identification and prediction results from the test set data. The accuracy calculation formula is as follows:
[0050]
[0051] Wherein, TP indicates that the sample prediction value matches the true value and is positive, TN indicates that the sample prediction value is positive and the true value is negative, FP indicates that the sample prediction value is negative and the true value is positive, and FN indicates that the sample prediction value matches the true value and is negative. When the accuracy reaches 95%, the model that has been trained is output and saved; otherwise, the model is retrained.
[0052] Further, step 6 is as follows: The user takes real-time images of crop diseases and pests. First, the images are intelligently processed by the Image Intelligent Processing IPS module. Then, the preprocessed images are input into the InheritfeatNet recognition and classification network. Features are extracted through convolutional layers, and the properties of each layer's features are inherited to the next layer. Finally, a feature matrix corresponding to the target image is generated. Then, pooling, fully connected layers, and activation functions are used to recognize and classify the target. Finally, the top three prediction results ranked from highest to lowest confidence are returned, and the result with the highest confidence is selected as the final recognition result.
[0053] Furthermore, in step 6, the intelligent feedback process is as follows:
[0054] When the image captured by the user in real time is unclear to the point of being unable to distinguish features, lacks pests or diseases, is too small, or is obscured by other crops, the system will provide the user with a prompt message, prompting the user to re-acquire the image to be identified; if the image to be identified contains the target object and the image quality of the current image to be identified is high, the system will provide the user with specific pest or disease identification information and the name of the pest or disease based on the results identified by the model.
[0055] The beneficial technical effects of this invention are as follows:
[0056] 1. To address the issue of blurry images captured by some farmers due to equipment limitations or skewed subjects in user-uploaded images, an IPS module is proposed for intelligent image processing.
[0057] 2. To address the issues of gradient vanishing and gradient exploding that commonly used convolutional neural networks for classification cause bias in prediction results, an inherited feature architecture is proposed to record and update the forward feature matrix, ensuring maximum retention of feature information and improving the recognition and classification accuracy by 10% to 15%.
[0058] 3. To address the problem that current recognition and classification networks require training a large number of parameters during runtime, resulting in high demands on computing power and memory and making it impossible for the algorithm to interface with mobile devices, the InheritZone module is proposed. By extracting features multiple times, it reduces the number of parameters and memory usage, greatly reducing the computing power requirements and creating conditions for migrating this method to mobile terminals in the future. Attached Figure Description
[0059] Figure 1 This is a flowchart of the crop disease and pest classification and identification method based on the InheritfeatNet algorithm of the present invention.
[0060] Figure 2 This is a process diagram of intelligent image processing using the IPS module in this invention. Detailed Implementation
[0061] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0062] This invention addresses the problem of generating a large number of parameters during the identification process in traditional methods. It also considers that the devices used by the target audience of such methods are not adapted to the operating conditions of traditional methods. Therefore, it proposes an image intelligent processing module (IPS) and a feature matrix generation structure, and combines the InheritfeatNet algorithm to improve the accuracy of crop pest and disease identification.
[0063] like Figure 1 As shown, a method for identifying crop diseases and pests based on the InheritfeatNet algorithm is presented. Users capture images of crop diseases and pests in real time. First, the IPS module performs intelligent image processing operations such as blur detection, skew correction, and image enhancement. Then, a crop disease and pest identification and classification network model based on the InheritfeatNet algorithm identifies and classifies the images. Finally, intelligent feedback is provided based on the current image identification results. The InheritfeatNet algorithm can efficiently and accurately identify crop disease and pest categories, has low computational cost, and is easy to interface with mobile devices, thus helping researchers develop mobile-based apps.
[0064] The method specifically includes the following steps:
[0065] Step 1: Obtain images of various types of crop diseases and pests, and create a sample dataset of crop diseases and pests.
[0066] This invention combines publicly available datasets from various existing databases of crop diseases and pests with images of crop diseases and pests collected in the field using devices such as mobile phones to create a sample dataset. The resulting crop disease and pest sample dataset is a labeled dataset, including data on different diseases and pests collected from different crops at different times of onset, different affected parts, and different growth stages.
[0067] Step 2: Construct an image intelligent processing (IPS) module to preprocess the input image.
[0068] The IPS module includes a blur detection section, a skew image correction section, and an image enhancement section. The blur detection section is used to evaluate the degree of blur in the input image; the skew image correction section is used to detect and correct skew in the image; and the image enhancement section is used to enhance the detected blurry image, making the image information more prominent.
[0069] like Figure 2 As shown, the specific process of intelligent preprocessing performed by the IPS module is as follows:
[0070] Step 2.1: First, determine whether the main subject of the image is blurred. Use the Sobel detection operator to extract the gradient values in the horizontal and vertical directions of the image. Then, evaluate the degree of blur of the input image according to the Tenengrad evaluation function.
[0071] This invention defines a Sobel score of 100 as the maximum. Based on experimental results, the model performs poorly on input images with scores below 53. Therefore, when the sharpness target Target < 60, subsequent image enhancement processing is required. The formulas used in this section are as follows:
[0072]
[0073]
[0074] Where (x,y) are the coordinates of an edge point in the 2D image, Sobel(x,y) represents the gradient of the image at point (x,y), and G... x G y , respectively, are the grayscale values of the horizontal and vertical edges detected in the image, where I(x,y) represents the original image. Tenengrad represents the image sharpness evaluation index, and n represents the total number of pixels in the image.
[0075] When the value of Tenengrad is less than 60, the image is considered blurry and requires enhancement processing.
[0076] Step 2.2: This invention defines an angle measurement method used to read the flip angle data of the mobile device's built-in gyroscope, thereby determining whether there will be any skewness when capturing images. The specific process of the angle measurement method is as follows:
[0077] Let alpha be the angle of rotation around the Z-axis when the device is horizontally placed, alpha∈[0,2π]; beta be the angle of rotation around the X-axis when the device is horizontally placed, beta∈[-π,π]; and gamma be the angle of rotation around the Y-axis when the device is horizontally placed.
[0078] Based on a rough statistical analysis of people's daily photography habits, the results show that... The angle chosen for most people's photos. Among the three parameters above, gamma has the greatest impact on the degree of image skew. When the data indicates that gamma exceeds... If the deviation is within a certain range, it will be considered as skewed; if it is within a certain range, it will be considered as not skewed.
[0079] Step 2.3: Process the image accordingly based on the evaluation results.
[0080] The present invention obtains four evaluation results by combining the detection in steps 2.1 and 2.2: clear and skewed, clear and not skewed, blurry and not skewed, and blurry and skewed.
[0081] When the evaluation result is a clear image with a prominent subject (i.e., clear and not skewed), no image processing is required;
[0082] When the evaluation result is a blurry and skewed image, the subject is corrected using the perspective transformation equation. The specific process is as follows: first, the skewed image is processed, and the skewed subject is corrected according to the principle of perspective transformation; then, the image information is enhanced on the image after the correction transformation.
[0083] When the evaluation result is clear skew, only the image is corrected;
[0084] When the evaluation result is blurry but not skewed, only information enhancement operations are performed on the image.
[0085] The specific process of correction is as follows:
[0086] This invention randomly selects eight feature points on the outside of the diseased leaf based on the leaf contour. To maximize the complete inclusion of the leaf body within this octagon, each feature point is expanded by the same step size along its gradient direction. The change in pixel value determines whether the leaf is fully contained. The feature matrix corresponding to each point is input into the perspective transformation equation. Each feature point (x, y) corresponds to a target point (x', y'). Based on the correspondence between planar coordinates and homogeneous coordinates in formula (3), the perspective transformation matrix equation can be derived. By solving the perspective transformation matrix equations corresponding to the eight points in formula (4), the coordinates of the eight transformed points are obtained. Then, the original image is transformed to this position using formula (5) to obtain the corrected image. The specific formulas used in this part are as follows:
[0087]
[0088]
[0089]
[0090] Where w is the extended dimension variable, R is the two-dimensional coordinate point in the real number field, and P is the three-dimensional coordinate point in the projective space; fg 1~8 This represents eight feature points selected around the image, T represents the target region to be identified and classified, scr represents the original input feature matrix, dst represents the processed output feature matrix, and M represents the feature matrix corresponding to each coordinate point. 11 Let fg1 be the feature matrix corresponding to the position.
[0091] The specific process of image information enhancement is as follows:
[0092] This invention employs Gamma transformation, setting the input gray level r. With r=1 as a baseline, when r>1, it stretches the higher gray-level regions of the image while compressing the lower gray-level regions; when r<1, the opposite operation is performed. This enhances contrast and makes image information more prominent. The specific formulas used in this part are as follows:
[0093] s = cr γ (6)
[0094] Where r and s represent the input and output gray levels respectively, c is the gray-level scaling factor, usually c=1, and γ represents the gray-level mapping method between the input and output images. When γ>1, the contrast of the high gray-level areas of the image is enhanced; when γ<1, the contrast of the low gray-level areas of the image is enhanced; when γ=1, the original image is not changed.
[0095] Step 3: Build the InheritfeatNet crop disease and pest identification network;
[0096] The InheritfeatNet algorithm employs a multi-modal feature extraction strategy, concatenating multiple InheritfeatZones. Each InheritfeatZone generates a feature matrix, which is then passed to every subsequent InheritfeatZone for further convolution operations. This process is repeated until all image features are extracted. A pass parameter `i` is set, representing the number of layers the feature matrix is passed to. The InheritfeatZone connection formula is expressed as:
[0097] X i+1 =Inheritfeat(X0,X1,…X i (7)
[0098] Where X represents the characteristic matrix, X i+1 Let i be the feature map synthesized from i feature maps, and let Inheritfeat(·) denote the connection function.
[0099] Step 4: Train and optimize the constructed crop disease and pest identification and classification network model based on the InheritfeatNet algorithm. The specific process is as follows:
[0100] Step 4.1: Divide the sample dataset obtained in Step 1 and processed in Step 2 into training set, test set and validation set according to the random sampling principle;
[0101] Step 4.2: Input the training set and validation set into the crop pest and disease identification network for training, and obtain the output results;
[0102] Step 4.3: Input the training output (predicted value) and the actual result (label value) into the loss function to obtain the training loss;
[0103] This invention employs the cross-entropy loss function. The cross-entropy loss function is defined as follows:
[0104]
[0105] Among them, y i For the label value, y i 'This is the predicted value.'
[0106] Step 4.4: Adjust the model parameters based on the training loss and optimize the model using an optimizer. Simultaneously, validate the model results using a validation set to obtain the final trained and optimized recognition network. This invention employs the Adam optimizer to adjust the model update weights and bias parameter θ. t θ t It can be obtained from the following formula,
[0107]
[0108] Where α is the learning rate, m i For the first moment estimate of the gradient, v t ∈ is the second moment estimate of the gradient, and ∈ is a constant added to maintain numerical stability.
[0109] Step 5: Use the test set to evaluate the trained crop disease and pest identification network model, and output and save the model with good evaluation performance.
[0110] The model is evaluated using accuracy as a metric by identifying and predicting data from the test set. The accuracy calculation formula is as follows:
[0111]
[0112] Where TP indicates that the predicted value matches the true value and is positive, TN indicates that the predicted value is positive and the true value is negative, FP indicates that the predicted value is negative and the true value is positive, and FN indicates that the predicted value matches the true value and is negative. When the accuracy reaches 95%, the currently trained model is output and saved; otherwise, the model is retrained.
[0113] Step 6: Use the trained crop pest and disease identification network model to identify the input image. During the image acquisition and identification process, provide intelligent feedback to the user. The specific process is as follows:
[0114] Users capture images of crop diseases and pests in real time. First, the image intelligent processing IPS module performs intelligent processing operations such as correction, noise reduction, and information enhancement. Then, the preprocessed image is input into the InheritfeatNet recognition and classification network. Features are extracted through convolutional layers, and the properties of features from each layer are inherited to the next layer. Finally, a feature matrix corresponding to the target image is generated. Then, pooling, fully connected layers, and activation functions are used to recognize and classify the target. Finally, the top three prediction results ranked from high to low confidence are returned, and the result with the highest confidence is selected as the final recognition result.
[0115] The intelligent feedback process is as follows: when the image to be identified captured by the user in real time is unclear to the point that the features cannot be distinguished, there are no pests or diseases, the size is too small, or it is blocked by other crops, the user is given a prompt message to re-acquire the image to be identified; if the target object exists in the image to be identified and the image quality of the current image to be identified is high, the user is given specific pest and disease identification information based on the results identified by the model, and the name of the pest or disease is given.
[0116] Researchers can develop a crop pest and disease identification system based on a network model. This system can be a mobile app. The system includes an image upload module and an online identification module. In the image upload module, users upload images acquired in real time. If the uploaded image is unclear to the point of indistinguishable features, lacks pest or disease characteristics, is too small, or is obscured by other crops, the system will provide a message to the user: "Unable to identify! Please re-upload!" In the online identification module, if the image contains the target object and the uploaded image is of high quality, the system will, based on the model's identification results, provide the user with "Pest or disease identified," along with the pest or disease name and other information.
[0117] This invention underwent verification and comparison experiments.
[0118] Experimental environment configuration: Windows 10 operating system, Intel(R) Xeon(R) W-2245 CPU @ 3.90GHz, Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz (8 CPUs), ~2.3GHz, Python 3.8, PyTorch 1.1.1
[0119] The experiment selected different datasets for identifying different types of data, as detailed in Table 1:
[0120] Table 1 Dataset Information
[0121]
[0122] To evaluate the merits of this invention, it was compared with the Vgg-16 method proposed by the Visual Geometry Group, the AlexNet method proposed by Wang et al., and the ResNet method proposed by He et al. The results are shown in Table 2.
[0123] Table 2 Comparison results of different methods
[0124]
[0125] As shown in Table 2, on the same dataset, the method proposed in this invention improves the accuracy of crop identification and classification by nearly 15% compared to the Vgg-16 method and by nearly 20% compared to the AlexNet method. However, since most images in PlantVillage are high-resolution close-up images, this method does not show a significant advantage when compared to ResNet, and its accuracy in prediction is comparable to ResNet, with an improvement of only 3.3%. However, when images are skewed or blurry, this method shows a more significant advantage, improving by 6% to 32% compared to the other three methods. Furthermore, for the large PlantVillage dataset, this method performs better in terms of memory usage compared to the other three methods. However, due to the complex module structure, the time consumed is increased, which is an area where this invention needs further improvement.
[0126] Of course, the above description is not intended to limit the present invention, and the present invention is not limited to the examples given above. Any changes, modifications, additions or substitutions made by those skilled in the art within the scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A method for classifying and identifying crop diseases and pests based on the InheritfeatNet algorithm, characterized in that, Includes the following steps: Step 1: Obtain images of various types of crop diseases and pests, and create a sample dataset of crop diseases and pests. Step 2: Construct an image intelligent processing (IPS) module to preprocess the input image; the specific process is as follows: Step 2.1: First, determine whether the main subject of the image is blurred. Use the Sobel detection operator to extract the gradient values in the horizontal and vertical directions of the image. Then, evaluate the degree of blur in the input image using the Tenengrad evaluation function. The specific formula is as follows: Where (x,y) are the coordinates of an edge point in the 2D image, Sobel(x,y) represents the gradient of the image at point (x,y), and G... x G y , respectively, are the grayscale values of the horizontal and vertical edge detection images, I(x,y) represent the original image; Tenengrad represents the image sharpness evaluation index, and n represents the total number of pixels in the image; Step 2.2: Use the angle measurement method to determine if there is image skew. The specific process of the angle measurement method is as follows: Define alpha as the angle of rotation around the Z-axis when the device is placed horizontally; beta as the angle of rotation around the X-axis when the device is placed horizontally; gamma as the angle of rotation around the Y-axis when the device is placed horizontally. If the gamma of the current image exceeds the set range, it is determined that there is skew. Step 2.3: Process the image accordingly based on the evaluation results; The combined detection results from steps 2.1 and 2.2 yield four evaluation outcomes: clear and skewed, clear and not skewed, blurry and not skewed, and blurry and skewed. When the evaluation result is clear and not skewed, no image processing is performed; When the evaluation result is blurry and skewed, the main body of the skewed image is first corrected according to the principle of perspective transformation; then the image information enhancement process is performed on the image after correction transformation. When the evaluation result is clear skew, only the image is corrected; When the evaluation result is blurry but not skewed, only information enhancement operations are performed on the image; The specific process of correction is as follows: Outside the diseased leaf, eight feature points are randomly selected based on the leaf outline. Each feature point is expanded by the same step size along the gradient direction of that point. The change in pixel value is used to determine whether the leaf is completely included. The feature matrix corresponding to each point is input into the perspective transformation equation. Each feature point (x,y) corresponds to a target point (x',y'). According to the correspondence between the plane coordinates and homogeneous coordinates in formula (3), the perspective transformation matrix equation is obtained. The coordinates of the eight transformed points are obtained by solving the perspective transformation matrix equations corresponding to the eight points in formula (4). Then, the original image is transformed to this position using formula (5) to obtain the corrected image. The specific formulas used are as follows: Where w is the extended dimension variable, R is the two-dimensional coordinate point in the real number field, and P is the three-dimensional coordinate point in projective space; fg1~8 represent eight feature points selected around the image, T represents the target region to be identified and classified, scr represents the input original feature matrix, dst represents the output processed feature matrix, and M represents the feature matrix corresponding to each coordinate point. 11 Let fg1 be the feature matrix at the corresponding position; The specific process of image information enhancement is as follows: Using Gamma transformation, with the input gray level r as a baseline (r=1), when r>1, the image stretches high-gray-level regions while compressing low-gray-level regions; when r<1, the opposite operation is performed. The specific formula used is as follows: s=cr γ (6); Where r and s represent the input and output gray levels, respectively, c is the gray-level scaling factor, and γ represents the gray-level mapping method between the input and output images. When γ>1, the contrast of the high gray-level areas of the image is enhanced; when γ<1, the contrast of the low gray-level areas of the image is enhanced; when γ=1, the original image is not changed. Step 3: Build a crop disease and pest identification and classification network model based on the InheritfeatNet algorithm; The InheritfeatNet algorithm employs a multi-modal feature extraction strategy, concatenating multiple InheritfeatZones. Each InheritfeatZone generates a feature matrix, which is then passed to every subsequent InheritfeatZone for further convolution operations. This process is repeated until the image feature extraction is complete. A pass parameter i is set, representing the number of layers the feature matrix is passed to. The InheritfeatZone connection formula is expressed as: X i+1 =Inheritfeat(X0,X1,……X i ) (7); Where X represents the characteristic matrix, X i+1 The feature map is synthesized from i feature maps, and Inheritfeat(·) represents the connection function; Step 4: Train and optimize the constructed crop disease and pest identification and classification network model; Step 5: Evaluate the trained crop pest and disease identification and classification network model, and output and save the model with good evaluation performance; Step 6: Use the trained crop pest and disease identification and classification network model to identify the input image; provide intelligent feedback to the user during the image acquisition and identification process.
2. The crop disease and pest classification and identification method based on the InheritfeatNet algorithm according to claim 1, characterized in that, In step 1, the sample dataset includes publicly available datasets from existing databases of various types of crop diseases and pests, as well as crop disease and pest images collected in the field by equipment. The sample dataset is a labeled dataset of crop diseases and pests, including different disease and pest data collected from different crops at different times of onset, different disease sites, and different growth stages.
3. The crop disease and pest classification and identification method based on the InheritfeatNet algorithm according to claim 1, characterized in that, The specific process of step 4 is as follows: Step 4.1: Divide the sample dataset obtained in Step 1 and processed in Step 2 into training set, test set and validation set according to the random sampling principle; Step 4.2: Input the training set and validation set into the crop pest and disease identification and classification network model for training, and obtain the output results; Step 4.3: Input the predicted values and label values into the loss function to obtain the training loss; use the cross-entropy loss function; the cross-entropy loss function is defined as follows: Among them, y i For the label value, y i 'This is the predicted value; Step 4.4: Adjust the model parameters based on the training loss and optimize the model using an optimizer; simultaneously, validate the model results using a validation set to obtain the final trained and optimized recognition network; use the Adam optimizer to adjust the model update weights and bias parameters θ. t θ t It is obtained from the following formula, Where α is the learning rate, m i For the first moment estimate of the gradient, v t ∈ is the second moment estimate of the gradient, and ∈ is a constant added to maintain numerical stability.
4. The crop disease and pest classification and identification method based on the InheritfeatNet algorithm according to claim 1, characterized in that, In step 5, a test set is used for evaluation. The model is evaluated using accuracy metrics based on the identification and prediction of the test set data. The accuracy calculation formula is as follows: Wherein, TP indicates that the sample prediction value matches the true value and is positive, TN indicates that the sample prediction value is positive and the true value is negative, FP indicates that the sample prediction value is negative and the true value is positive, and FN indicates that the sample prediction value matches the true value and is negative. When the accuracy reaches 95%, the model that has been trained is output and saved; otherwise, the model is retrained.
5. The crop disease and pest classification and identification method based on the InheritfeatNet algorithm according to claim 1, characterized in that, The specific process of step 6 is as follows: The user takes real-time images of crop diseases and pests. First, the images are intelligently processed by the image intelligent processing IPS module. Then, the preprocessed images are input into the InheritfeatNet recognition and classification network. Features are extracted through convolutional layers, and the properties of each layer's features are inherited to the next layer. Finally, a feature matrix corresponding to the target image is generated. Then, pooling, fully connected layers, and activation functions are used to achieve target recognition and classification. Finally, the top three prediction results ranked from high to low confidence are returned, and the largest result is selected as the final recognition result.
6. The crop disease and pest classification and identification method based on the InheritfeatNet algorithm according to claim 1, characterized in that, In step 6, the intelligent feedback process is as follows: When the image captured by the user in real time is unclear to the point of being unable to distinguish features, lacks pests or diseases, is too small, or is obscured by other crops, the system will provide the user with a prompt message, prompting the user to re-acquire the image to be identified; if the image to be identified contains the target object and the image quality of the current image to be identified is high, the system will provide the user with specific pest or disease identification information and the name of the pest or disease based on the results identified by the model.
Citation Information
Patent Citations
Imaging device, imaging method and recording medium
CN110300254A
Image definition judgment method based on improved Retinex algorithm
CN111062887A
Pepper disease identification method, identification system and computer readable storage medium
CN114170137A
Bolt loosening state identification method based on improved convolutional neural network
CN114266280A
Mobile phone placement position detection method and device
CN115240385A