Crop disease and pest identification method and system based on image identification

Through super-resolution restoration of SAGAN generator and multi-scale feature extraction of ViT model, combined with expansion convolution and spatial attention mechanism, the problem of low-resolution image and multi-scale feature capture is solved, and the accuracy of crop pest detection is improved and Practicality.

CN119206506AActive Publication Date: 2024-12-27TAIZHOU POLYTECHNIC COLLEGE

Patent Information

Application Number
CN202411551807.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2024-12-27
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

Existing crop pest and disease detection technologies based on image recognition are susceptible to low-resolution images when dealing with large and complex environments, making it difficult to capture remote global information and multi-scale features, resulting in a decrease in recognition accuracy.

Method used

The SAGAN generator is used to perform super-resolution restoration of low-resolution regions, combined with ViT model and DMSAU-Net to extract multi-scale features, enhance the feature representation of pest and disease regions through expansion convolution and spatial attention mechanisms, and classify them using SVM model.

Benefits of technology

It improves the clarity and identification accuracy of pest and disease characteristics, and can capture pest and disease characteristics at different scales at the same time, improving the accuracy and practicality of pest and disease identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119206506A_ABST
    Figure CN119206506A_ABST
Patent Text Reader

Abstract

The invention discloses a crop disease and pest recognition method and system based on image recognition, and relates to the technical field of image recognition, and the method comprises the steps: collecting a farmland image, recognizing and positioning a disease and pest region in the image, and carrying out the super-resolution restoration of a low-resolution region in the image; local features of the image are extracted through a ViT model, multi-scale features of diseases and insect pests in the image are captured through DMSAU-Net, and the types of the diseases and insect pests are recognized according to the extracted features of the diseases and insect pests. According to the method, detail restoration is carried out on a low-resolution area through the SAGAN generator, the definition of pest and disease damage characteristics is improved, the accuracy of image recognition is greatly improved, the ViT model and the DMSAU-Net model are used, expansion convolution and a multi-scale attention mechanism are combined, the pest and disease damage characteristics under different scales can be captured at the same time, and the image recognition accuracy is improved. The problem that a traditional image processing model is difficult to process multi-scale features is solved, and the accuracy and practicability of disease and pest recognition are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and in particular to a method and system for identifying crop diseases and insect pests based on image recognition. Background Art

[0002] In modern agriculture, with the continuous expansion of crop planting and changes in climatic conditions, the impact of pests and diseases on crop yield and quality is becoming increasingly serious. Traditional pest and disease detection methods rely on manual inspections or physical detection methods, which is time-consuming and labor-intensive, and is prone to missed detections and misjudgments due to subjective factors. In recent years, with the rapid development of artificial intelligence technology and drone technology, image recognition technology has gradually been applied to the agricultural field, providing a new solution for pest and disease detection. Using drones to collect farmland images and combining deep learning algorithms can realize automated detection of pests and diseases in large areas of farmland. This automated detection method based on image recognition not only improves work efficiency, but also significantly reduces costs, providing important technical support for precision agriculture.

[0003] However, the existing pest and disease detection technology still has some shortcomings. First, the existing image recognition technology is easily affected by low-resolution images when dealing with large-scale complex environments, especially at long distances or under insufficient light. The details of the pest and disease area are often not clearly presented, resulting in a decrease in recognition accuracy. Secondly, although the convolutional neural network (CNN) has a strong performance in feature extraction, its receptive field is limited and it is difficult to capture remote global information. Therefore, for farmland with widespread pest and disease distribution, it is impossible to take into account both global and local features at the same time. In addition, most of the existing pest and disease classification models are classification methods based on a single feature scale, which makes it impossible to simultaneously identify and classify disease manifestations at different scales (such as large-scale spots and subtle discoloration). These technical deficiencies limit the accuracy and practicality of pest and disease identification, and there is an urgent need for a more efficient and accurate pest and disease detection technology. Summary of the invention

[0004] In view of the problems existing in the above-mentioned existing crop disease and insect pest identification methods and systems based on image recognition, the present invention is proposed.

[0005] Therefore, the problem to be solved by the present invention is that these technical deficiencies limit the accuracy and practicality of pest and disease identification, and a more efficient and accurate pest and disease detection technology is urgently needed.

[0006] To solve the above technical problems, the present invention provides the following technical solutions: a method for identifying crop pests and diseases based on image recognition, which includes collecting farmland images, identifying and locating pest and disease areas in the images, and performing super-resolution restoration on low-resolution areas in the images; extracting local features of the images through a ViT model and capturing multi-scale features of pests and diseases in the images through DMSAU-Net, and identifying the types of pests and diseases based on the extracted pest and disease features; generating a real-time pest and disease diagnosis report based on the classification results and storing the data generated during the identification.

[0007] As a preferred embodiment of the crop pest and disease identification method based on image recognition described in the present invention, the collecting of farmland images, identifying and locating pest and disease areas in the images refers to setting a drone flight path using automatic route planning software, wherein the drone automatically flies according to a preset route, collects image data of crops along the way, and extracts regional features of pests and diseases in the image through a convolutional neural network model after preprocessing the collected image data, and inputs the extracted feature map into a YOLOv4 target detection model to generate a boundary box of the pest and disease area.

[0008] As a preferred embodiment of the crop pest identification method based on image recognition of the present invention, the super-resolution restoration of the low-resolution area in the image refers to further analyzing the pest area initially located, using the Sobel operator to calculate the gradients of the image in the horizontal and vertical directions respectively, and calculating the gradient modulus of each pixel after obtaining the gradient value of each pixel through gradient calculation;

[0009] Set a threshold T. If the gradient modulus of a pixel is lower than the threshold T, the pixel area is a low-resolution area.

[0010] The image of the low-resolution area is marked and normalized before being input into the SAGAN generator. The local features of the low-resolution image are extracted through the convolutional layer and the extracted features are linearly transformed to generate the query matrix, key matrix and value matrix respectively. The features of each pixel are converted into query vector, key vector and value vector through different weight matrices.

[0011] Use the dot product to calculate the similarity between the query vector and the key vector, generate a similarity matrix, which represents the similarity between each pixel and other pixels, and use the Softmax function to normalize the similarity matrix to generate the final attention weight matrix;

[0012] Through the attention weight matrix, the SAGAN generator combines the global information and local information of each pixel to form a global feature matrix;

[0013] The residual block structure includes two convolutional layers, and a ReLU activation function is added after each convolutional layer. The generated global feature matrix is ​​used as the initial input of the residual network and two convolution operations are performed to obtain the feature map Y. The input features are added to the feature map Y through a jump connection to obtain the feature map Y1. The obtained feature map is passed to the residual block of the next layer for deeper convolution and feature extraction. After stacking multiple layers of residual blocks, a high-resolution feature map is obtained.

[0014] Collect high-resolution images of crop pest and disease areas as real images, transmit the real images and the generated high-resolution feature maps to the discriminator for analysis to obtain the corresponding authenticity probabilities, and calculate the adversarial loss function based on the discriminator's output of the real images and the generated images;

[0015] The calculation result of the adversarial loss is passed to the generator as feedback. The generator adjusts the parameters according to the feedback information to optimize the generated image and further optimizes the details through the perceptual loss. The perceptual loss extracts the intermediate layer features of the generated image and the real image through the VGG19 network and calculates the image difference.

[0016] The calculated result of the perceptual loss is passed to the generator as feedback, and the generator further optimizes the generated image details based on the feedback information to obtain the final high-resolution pest and disease image.

[0017] As a preferred solution of the crop pest and disease identification method based on image recognition of the present invention, wherein: the extracting local features of the image by the ViT model and capturing the multi-scale features of the pest and disease in the image by the DMSAU-Net refers to dividing the pest and disease image into image blocks of fixed size, and linearly embedding each image block to convert it into a one-dimensional feature vector;

[0018] Use the self-attention mechanism to calculate the feature correlation between each graphic block:

[0019]

[0020] In the formula, Q h and K h are the query matrix and key matrix of the h-th attention head, V is the value matrix, and W H (x) is the Hamming window function, d k is the scaling factor, H is the number of longs, and T is the transpose operation;

[0021] The output of the self-attention mechanism is stacked in multiple layers, the calculation of the self-attention mechanism is repeatedly performed, and the local information is transferred to the global by stacking multiple layers of Transformer structure to obtain the global features. The DMSAU-Net is used to process the multi-scale features of the image through dilated convolution:

[0022]

[0023] Where y[i] is the output eigenvalue of the dilated convolution, x[i] is the input eigenvalue, and r s is the expansion rate, w s [k] is the kth convolution kernel weight at the sth scale, J 1 () is the Bessel function, K is the size of the convolution kernel, and S is the number of multi-scale convolutions;

[0024] The features extracted under different expansion rates are fused to form a multi-scale feature representation to obtain the corresponding regional feature map;

[0025] The spatial attention mechanism is used to further enhance the focus on pest and disease areas:

[0026]

[0027] In the formula, A s is the spatial attention weight, σ() is the Sigmoid activation function, and f conv (F) is the result of convolution operation on the input feature map F. Refers to applying the Laplacian operator to the feature map F, G(F,μ,ω) is the Gaussian kernel function, ‖F‖ 2 is the L2 norm of the feature map F;

[0028] Different features are weighted according to the calculated spatial attention weights, and the features that have undergone multi-scale convolution processing and added with spatial attention weights are used as the final feature representation output to generate a feature set.

[0029] As a preferred embodiment of the crop pest and disease identification method based on image recognition described in the present invention, the method of identifying the type of pest and disease based on the extracted pest and disease features refers to selecting SVM as a classification model, dividing the preprocessed image data into a training set and a test set, training the SVM model using a labeled training data set, optimizing the SVM model parameters through cross-validation and grid search, and evaluating the model performance using a test set after each training cycle. If there is no significant change in the verification difference after the training cycle, the model training is stopped to obtain the trained SVM model, and the feature set is input into the SVM model for classification to obtain the type of pest and disease.

[0030] As a preferred embodiment of the crop pest and disease identification method based on image recognition described in the present invention, the real-time pest and disease diagnosis report generated according to the classification results refers to generating the affected crop range based on the identified pest and disease types by comparing with the pest and disease database, generating a pest and disease diagnosis report including the disease type, disease severity scale, affected crops and disease impact range based on the classification results and crop information, and generating corresponding prevention and control measures according to the pest and disease type and severity in the diagnosis report.

[0031] As a preferred solution of the crop disease and pest identification method based on image recognition described in the present invention, the data generated during the storage of identification refers to storing the image data collected and analyzed in a database, the database sorts the image data in chronological order and marks the corresponding tags, synchronously backs up the image data in the cloud, and regularly performs integrity checks on the backup data.

[0032] Another object of the present invention is to provide a crop pest identification system based on image recognition, which comprises:

[0033] An image analysis module is used to collect farmland images and analyze them after preprocessing them, so as to identify and locate the pest and disease areas in the farmland;

[0034] An image restoration module is used to detect low-resolution image areas and restore the image to generate a high-resolution image;

[0035] The feature extraction module is used to extract local features of the image and then process the multi-scale features in the image through dilated convolution, and combine the spatial attention mechanism to enhance the feature representation of the pest area;

[0036] Classification module, used to classify the pests and diseases of farmland based on the extracted features and through the SVM model;

[0037] The report generation module is used to generate pest and disease reports based on the classification results and provide prevention and control suggestions, and then store the data generated during the pest and disease identification process.

[0038] A computer device comprises: a memory and a processor; the memory stores a computer program, and the processor implements the steps of a method for identifying crop diseases and insect pests based on image recognition when executing the computer program.

[0039] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a method for identifying crop pests and diseases based on image recognition.

[0040] The beneficial effects of the present invention are as follows: the present invention restores details of low-resolution areas through the SAGAN generator, thereby improving the clarity of pest and disease features, thereby greatly improving the accuracy of image recognition, and using the ViT model and the DMSAU-Net model in combination with the dilated convolution and multi-scale attention mechanism, which can simultaneously capture pest and disease features at different scales, solves the problem that traditional image processing models are difficult to handle multi-scale features, and improves the accuracy and practicality of pest and disease recognition. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0042] Figure 1 The figure is a flowchart of the crop pest and disease identification method based on image recognition.

[0043] Figure 2 This is a structural diagram of the crop disease and pest identification system based on image recognition. DETAILED DESCRIPTION

[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.

[0045] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0046] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it a separate or selective embodiment that is mutually exclusive with other embodiments.

[0047] Example 1, reference Figure 1 and Figure 2 , which is the first embodiment of the present invention, and provides a method for identifying crop diseases and insect pests based on image recognition. The method for identifying crop diseases and insect pests based on image recognition includes:

[0048] S1, collect farmland images, identify and locate pest and disease areas in the images, and perform super-resolution restoration on low-resolution areas in the images;

[0049] Specifically, collecting farmland images, identifying pest and disease areas in the images and locating them means using automatic route planning software (DJI Ground Station) to set the flight path of the drone. The drone automatically flies according to the preset route and collects image data of crops along the way. After pre-processing the collected image data, the regional features of pests and diseases in the image are extracted through a convolutional neural network model, and the extracted feature map is input into the YOLOv4 target detection model to generate a bounding box of the pest and disease area.

[0050] By using automatic route planning software to set the flight path of the drone, a fully automated data collection process is realized. The automatic flight of the drone ensures that within the preset time, image data of a large range of crops can be accurately and efficiently collected. The main task of preprocessing is to perform operations such as denoising, normalization, and color correction on the image data to ensure that the subsequent neural network model input data has a high quality. Through image preprocessing, the present invention significantly improves the robustness of the convolutional neural network model, making the extraction of pest and disease area features more stable and accurate. This step solves the detection error problem caused by inconsistent image quality to a large extent, and lays a good foundation for the accurate identification of pests and diseases. Through multi-layer convolution operations, CNN can extract spatial features, edge features, and texture features in the image step by step, and automatically identify the morphological features of pests and diseases. YOLOv4 simplifies the target detection problem into a regression problem, significantly improves the detection efficiency, and can accurately detect multiple pest and disease areas in complex scenes, generate corresponding bounding boxes, and accurately mark them according to the size, position, and shape of the pests and diseases. The generated pest and disease area bounding box clearly marks the specific area of ​​crops that is infringed by pests and diseases, and provides basic data for subsequent classification models or prevention and control measures.

[0051] Furthermore, super-resolution restoration of low-resolution areas in the image refers to further analyzing the pest and disease areas that have been initially located, using the Sobel operator to calculate the gradients of the image in the horizontal and vertical directions, and then calculating the gradient modulus G of each pixel after obtaining the gradient value of each pixel through gradient calculation:

[0052]

[0053] In the formula, G x is the horizontal gradient, G y is the vertical gradient;

[0054] The threshold T is set by the Otsu method. If the gradient modulus of a pixel is lower than the threshold T, the pixel area is a low-resolution area.

[0055] The image of the low-resolution area is marked and normalized before being input into the SAGAN generator. The local features of the low-resolution image are extracted through the convolutional layer and the extracted features are linearly transformed to generate the query matrix, key matrix and value matrix respectively. The features of each pixel are converted into query vector, key vector and value vector through different weight matrices.

[0056] Use the dot product to calculate the similarity between the query vector and the key vector, generate a similarity matrix, which represents the similarity between each pixel and other pixels, and use the Softmax function to normalize the similarity matrix to generate the final attention weight matrix;

[0057] Through the attention weight matrix, the SAGAN generator combines the global information and local information of each pixel to form a global feature matrix;

[0058] This process ensures that the characteristics of each pixel not only rely on its local information, but also combine the global relationship with other pixels. In this way, the image restoration process not only pays attention to local details, but also ensures the coherence of global features. This lays a solid foundation for subsequent residual network processing, so that the image can be carefully restored at both the global and local levels. In complex pest and disease areas, the transition between the restored lesions and their surrounding backgrounds is ensured to be natural.

[0059] The residual block structure includes two convolutional layers, and a ReLU activation function is added after each convolutional layer. The generated global feature matrix is ​​used as the initial input of the residual network and two convolution operations are performed to obtain the feature map Y. The input features are added to the feature map Y through a jump connection to obtain the feature map Y1. The obtained feature map is passed to the residual block of the next layer for deeper convolution and feature extraction. After stacking multiple layers of residual blocks, a high-resolution feature map is obtained.

[0060] High-resolution images of crop pest and disease areas are collected as real images. The real images and the generated high-resolution feature maps are transmitted to the discriminator for analysis to obtain the corresponding authenticity probabilities. The adversarial loss function is calculated based on the output of the discriminator for the real images and the generated images:

[0061] L GAN =E[log(D(f))]+E[log (1-D(G(M)))],

[0062] Where, L GANis the loss function of the generative adversarial network, D(f) is the predicted output of the discriminator for the real image f, the range is [0,1], indicating the probability that the image is "real", D(G(M)) is the predicted output of the discriminator for the generated image G(M), the range is also [0,1], indicating the probability that the image is "generated", E() is the expected operation on the sample set, that is, the average of the entire training set or batch data;

[0063] The calculation result of the adversarial loss is passed to the generator as feedback. The generator adjusts the parameters according to the feedback information to optimize the generated image and further optimizes the details through the perceptual loss. The perceptual loss extracts the intermediate layer features of the generated image and the real image through the VGG19 network and calculates the image difference:

[0064]

[0065] Where, L 1 is the perceptual loss, which is used to compare the difference between the generated image G(M) and the real image f in high-level features, φ a (G(M)) and φ a (f) is the feature map extracted from the ath layer of the pre-trained VGG19 network. These feature maps represent the intermediate semantic information of the image.

[0066] The calculated result of the perceptual loss is passed to the generator as feedback. The generator further optimizes the generated image details based on the feedback information to obtain the final high-resolution pest and disease image.

[0067] After perceptual loss optimization, the high-resolution images generated by the generator are not only close to the real images in overall structure, but also more realistic and natural in details, texture and visual effects.

[0068] The super-resolution restoration step detects and marks low-resolution areas through the Sobel operator, and uses the SAGAN generator to restore low-resolution images to high-resolution images, effectively solving the problem that low-resolution images are difficult to accurately capture details in pest and disease detection. The SAGAN generator introduces a self-attention mechanism when generating images, so that the restored image is not only clear in local features, but also retains global information, thereby improving the accuracy of pest and disease area detection. By generating query matrices, key matrices, and value matrices to calculate the similarity between pixels, this process improves the generative adversarial network's understanding of the correlation between pixels in the image. The adversarial loss function is combined with the perceptual loss to further optimize the processing of details and ensure the authenticity and visual consistency of the generated image. Through the design of the residual block, the present invention can maintain the effective transmission of features in multi-layer convolution operations and prevent information loss or over-smoothing in deep networks. The residual block adds the input low-resolution features to the features after deep convolution through a "jump connection", thereby improving the network's ability to capture complex image features. The high-resolution pest and disease images finally generated are not only highly matched with the real images globally, but also fully optimized in terms of details. In the process of generating high-resolution images, the present invention achieves a dual optimization effect on the details and overall perception of the generated images by combining adversarial loss and perceptual loss. The adversarial loss evaluates the similarity between the generated image and the real image through the discriminator to ensure the realism of the generated image; the perceptual loss extracts the intermediate layer features through the VGG19 network to further optimize the details of the generated image, making the generated image closer to the real scene in terms of details. The combination of the two not only improves the overall quality of the generated image, but also makes the image richer in the expression of subtle features, which is particularly suitable for complex crop pest and disease image analysis.

[0069] S2, extract the local features of the image through the ViT model and capture the multi-scale features of pests and diseases in the image through DMSAU-Net, and identify the type of pests and diseases based on the extracted pest and disease features;

[0070] Specifically, the ViT model is used to extract the local features of the image and the DMSAU-Net is used to capture the multi-scale features of the pests and diseases in the image. The pest and disease image is divided into image blocks of fixed size, and each image block is linearly embedded and converted into a one-dimensional feature vector z i :

[0071] z i =B(x b )+p b ,

[0072] In the formula, B(x b ) is the result of the embedding matrix, which transforms the image block x b Mapped to feature space, p bIt is the position embedding of the image block, which is used to retain the spatial position information of each image block in the image;

[0073] Use the self-attention mechanism to calculate the feature correlation between each graphic block:

[0074] The core of the self-attention mechanism is to calculate the dependencies between feature blocks through query, key and value matrices. The original self-attention mechanism formula is:

[0075]

[0076] In order to enhance the model's ability to capture different features, a multi-head attention mechanism is introduced to decompose the query, key, and value matrices into multiple heads so that each head can focus on different feature areas. In the multi-head attention mechanism, in order to adjust the weights of different heads, the Hamming window function W is introduced. H (x), the Hamming window function is often used to smooth signals in signal processing. Here, it is used to weight the attention values ​​of different heads to ensure a smooth transition between attention values. When calculating the query, key, and value matrices, we use the QR decomposition of the orthogonal matrix to optimize the computational efficiency of the matrix. This method can ensure the orthogonality of the matrix and improve numerical stability. The introduction of QR decomposition can optimize the calculation of the query, key, and value matrices and ensure the accuracy of numerical calculations;

[0077] The improved self-attention mechanism formula is as follows:

[0078]

[0079] In the formula, Q h and K h are the query matrix and key matrix of the h-th attention head, V is the value matrix, and W H (x) is the Hamming window function, which is used to weight the calculation results of each attention head. k is the scaling factor, H is the number of longs, and T is the transpose operation;

[0080] The output of the self-attention mechanism is stacked in multiple layers, the calculation of the self-attention mechanism is repeatedly performed, and the local information is transferred to the global by stacking multiple layers of Transformer structure to obtain the global features. The DMSAU-Net is used to process the multi-scale features of the image through dilated convolution:

[0081] The core of the existing dilated convolution is to capture a wider range of features by expanding the receptive field of the convolution kernel. The formula of the original dilated convolution is:

[0082]

[0083] In the existing dilated convolution, usually only a single-scale convolution kernel is used to extract features. In order to enhance the ability to express multi-scale features, a multi-scale convolution kernel is introduced, and each scale convolution kernel uses a different dilation rate r. s To expand the receptive field, so as to capture features of different scales, in order to further optimize the response of features at different scales, the first-order Bessel function is introduced To adjust the weight of each feature, the smooth transition between features can be enhanced, while capturing more complex details, and convolutional features of all scales are fused to form the final multi-scale feature output;

[0084] The improved dilated convolution formula is:

[0085]

[0086] Where y[i] is the output eigenvalue of the dilated convolution, x[i] is the input eigenvalue, and r s is the expansion rate, which indicates the expansion multiple of the receptive field of the convolution kernel. It is used to adjust the convolution operation at different scales. According to the experimental tuning setting, w s [k] is the weight of the kth convolution kernel at the sth scale. The weights of convolution kernels of different scales may be different. Each convolution kernel is used to extract features of different scales. It is learned through the parameters of the convolution operation and is usually optimized through back propagation during network training. is a first-order Bessel function, which is used to adjust the characteristic response under different expansion rates. 1 () is the Bessel function, K is the size of the convolution kernel, which indicates the receptive field of the convolution kernel, S is the number of multi-scale convolutions, which indicates the number of scales of simultaneous convolution operations, and i is the index, which refers to the target output position of the convolution calculation;

[0087] The features extracted under different expansion rates are fused to form a multi-scale feature representation to obtain the corresponding regional feature map;

[0088] The spatial attention mechanism is used to further enhance the focus on pest and disease areas:

[0089] The core of the original spatial attention mechanism is to perform a convolution operation on the input feature map and then normalize the convolution result through an activation function (such as sigmoid). The basic formula of the mechanism is:

[0090] A s =σ(f conv (F)),

[0091] It cannot capture the area with large mutation in the feature map, so the second-order derivative (Laplacian) and Gaussian kernel function are introduced to improve it. The second-order derivative can capture areas with drastic changes in space, especially mutation points or boundaries in pest and disease images, which is very important for improving the focus on high-frequency areas in feature maps. In order to further smooth the noise in the feature map and better focus on local changes, the Gaussian kernel function G(F,μ,ω) is introduced. The Gaussian kernel function can smooth the pixels in the feature map and highlight the areas with relatively large eigenvalues. In order to prevent the output eigenvalue from being too large and avoid unstable network training, the L2 regularization term ‖F‖ is introduced. 2 , which ensures that the eigenvalues ​​are within a reasonable range and that the model will not fail due to some extreme features. Therefore, a new spatial attention mechanism formula is generated:

[0092]

[0093] In the formula, A s is the spatial attention weight, σ() is the Sigmoid activation function, and f conv (F) is the result of convolution operation on the input feature map F. It refers to applying the Laplacian operator to the feature map F. It calculates the second-order derivative of the feature map and is used to capture the areas with drastic changes in the feature map. G(F,μ,ω) is a Gaussian kernel function used to smooth the feature map F. It adjusts the smoothness of different areas through the mean μ and standard deviation ω of the feature map. ‖F‖ 2 It is the L2 norm of the feature map F, which is used for regularization to prevent the output value from being too large and causing numerical instability;

[0094] Different features are weighted according to the calculated spatial attention weights, and the features that have undergone multi-scale convolution processing and added spatial attention weights are used as the final feature representation output and a feature set is generated. These features have integrated local, global, and different scale information, and have been strengthened by the attention mechanism to focus on the pest and disease area.

[0095] If the pest and disease regional features show significant scale changes (such as the coexistence of local small spots and large-scale diseases), the ViT model is first used to extract the features, and then DMSAU-Net is used to reprocess the features processed by the ViT model. If the pest and disease features are mainly concentrated in areas with strong local or global correlation, ViT is used for feature extraction;

[0096] In the pest and disease identification scenario, a large number of complex feature changes are usually involved. For example, the size, shape, color changes and other features of pests and diseases on crop leaves may be extremely complex locally. The global feature extraction through the ViT model can quickly capture the long-distance dependencies and contextual information of the pest and disease area, effectively simplifying the difficulty of subsequent processing, and further strengthening the details and multi-scale information of the pest and disease area through multi-scale convolution and attention mechanisms, making the recognition results more comprehensive and refined. Combining the advantages of ViT and DMSAU-Net, the features of the pest and disease area are fully covered, from the global to the details, achieving higher recognition accuracy and computational efficiency, and adapting to complex pest and disease scenarios.

[0097] The ViT model extracts local features of the image through the self-attention mechanism and can establish global correlations between image blocks. Compared with the traditional CNN model, the advantage of the ViT model lies in its ability to better handle long-distance dependencies. This feature is particularly beneficial in the identification of crop pests and diseases, because the features of the diseased area are often scattered, and the traditional convolutional network may not be able to accurately capture these scattered regional features. ViT can effectively capture the disease information distributed in different areas by calculating the feature correlation between each image block, greatly improving the accuracy of pest and disease area identification. The self-attention mechanism is repeated through multi-layer stacking and multi-head structure, which enhances the model's comprehensive perception of local and global features in pest and disease images. The self-attention mechanism of each layer can analyze the image from different angles and different scales, ensuring that the pest and disease features can be accurately extracted regardless of whether they are large-scale spots or fine disease textures. Compared with a single feature extraction method, this stacked multi-layer structure significantly improves the performance of the model. DMSAU-Net combines dilated convolution and multi-scale feature extraction. By extracting the features of pests and diseases at different dilation rates, the present invention can capture the manifestations of pests and diseases at a larger range and a more subtle level. For example, some pests and diseases appear as large areas of discoloration on crop leaves, while other pests and diseases may only appear as small local spots. Through the use of dilated convolution, the present invention can not only capture these small disease areas, but also obtain disease information over a larger range. This fusion of multi-scale features solves the problem that traditional methods cannot accurately identify complex diseases at a single scale. The spatial attention mechanism further enhances the attention to the pest and disease area by calculating the spatial correlation of each area in the feature map. In the task of pest and disease identification, the features of the diseased area are often not significant and are easily disturbed by the background or other parts of the crop. By introducing the spatial attention mechanism, the model can focus more attention on the diseased area, thereby improving the accuracy of recognition. In particular, by combining the Laplacian operator and the Gaussian kernel function, the model can process small diseased areas in the image more finely and reduce the possibility of misjudgment.

[0098] Furthermore, identifying the type of pests and diseases according to the extracted pest and disease features refers to selecting SVM as a classification model, dividing the preprocessed image data into a training set and a test set, training the SVM model using the labeled training data set, optimizing the SVM model parameters through cross-validation and grid search, and evaluating the model performance using the test set after each training cycle. If there is no significant change in the verification difference after the training cycle, the model training is stopped to obtain the trained SVM model, and the feature set is input into the SVM model for classification to obtain the type of pests and diseases.

[0099] The characteristics of crop pests and diseases are highly complex and may include multi-dimensional features such as color, texture, and shape. SVM can perform well in handling classification problems with complex boundaries by finding the decision boundary that maximizes the classification interval. SVM has strong generalization ability, especially when the training sample size is small. SVM can effectively avoid overfitting by optimizing the decision boundary to ensure the stable performance of the model in real scenes. Compared with other common classification algorithms, such as decision trees and KNN (K nearest neighbor algorithm), SVM can better cope with the nonlinear distribution of pest and disease characteristics. Therefore, the application of the SVM model not only improves the classification accuracy, but also ensures the consistency and stability of the model on different data sets. In the model training process, avoiding overfitting and underfitting is the core issue of model tuning. Through cross-validation, the present invention can maximize the generalization ability of the model in a limited data set.

[0100] S3, generating a real-time pest and disease diagnosis report based on the classification results and storing the data generated during the identification;

[0101] Specifically, generating a real-time disease and insect pest diagnosis report based on the classification results means generating the affected crop range based on the identified disease and insect pest types by comparing them with the disease and insect pest database, generating a disease and insect pest diagnosis report including the disease type, disease severity scale, affected crops and disease impact range based on the classification results and crop information, and generating corresponding prevention and control measures based on the disease and insect pest type and severity in the diagnosis report.

[0102] In traditional pest management, farmers often rely on expert manual diagnosis, resulting in slow response speed. By generating an automated diagnostic report based on the classification results, specific pest types and their severity can be quickly generated, significantly shortening the time from identification to decision-making. By comparing the pest database, the system avoids the subjective bias that may exist in manual identification and ensures the accuracy of the identification results. By generating reports based on systematic classification results, the objectivity of diagnostic information is ensured, and a scientific basis is provided for subsequent decision-making. By combining image analysis technology with the database, the system can automatically calculate the area or number of affected crops, avoiding errors in manual statistics. In large-scale farmland operations, this technology is particularly important, which can help farmers quickly understand the spread of diseases and take preventive measures in time. Compared with the limitations of manual detection, the system can obtain the affected conditions of a large range of crops from a global perspective. This is of great significance for managers to carry out comprehensive pest control, and can ensure that the prevention and control measures are more accurate. Traditional disease assessment mostly relies on empirical judgment, while the present invention quantifies the severity of diseases through algorithms, making the assessment more objective and accurate. For example, by comparing historical data in the disease database with the current classification results, the spread speed and potential impact of pests and diseases can be accurately determined to ensure that prevention and control measures can be carried out in a targeted manner. The quantification of the severity of the disease can provide the system with automated prevention and control response decisions. For example, mild diseases may only require biological control, while severe diseases may require more radical chemical control solutions. Through accurate assessment of the severity of the disease, the system can generate corresponding prevention and control plans to improve the efficiency of prevention and control measures. The system can provide targeted prevention and control plans based on different types of pests and diseases and affected crops. This measure avoids the "one-size-fits-all" prevention and control method, making the prevention and control measures more scientific and reasonable. For example, for different crops and pests and diseases, the system can recommend the appropriate type of agent and application dosage.

[0103] Furthermore, storing the data generated during recognition means storing the collected and analyzed image data in a database, which sorts the image data in chronological order and marks them with corresponding tags, simultaneously backs up the image data in the cloud, and regularly performs integrity checks on the backup data.

[0104] By sorting the data in chronological order and marking the corresponding tags, this process can significantly improve the traceability and retrieval efficiency of the data. By synchronizing local data to the cloud in real time or regularly, it can effectively prevent data loss caused by hardware failure, natural disasters or human error. Cloud backup not only provides redundant storage for data, but also has the advantages of distributed storage, making large-scale data management easier.

[0105] Example 2, reference Figure 2, which is the second embodiment of the present invention, is different from the previous embodiment and provides a crop pest identification system based on image recognition, which includes:

[0106] An image analysis module is used to collect farmland images and analyze them after preprocessing them, so as to identify and locate the pest and disease areas in the farmland;

[0107] An image restoration module is used to detect low-resolution image areas and restore the image to generate a high-resolution image;

[0108] The feature extraction module is used to extract local features of the image and then process the multi-scale features in the image through dilated convolution, and combine the spatial attention mechanism to enhance the feature representation of the pest area;

[0109] Classification module, used to classify the pests and diseases of farmland based on the extracted features and through the SVM model;

[0110] The report generation module is used to generate pest and disease reports based on the classification results and provide prevention and control suggestions, and then store the data generated during the pest and disease identification process.

[0111] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0112] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0113] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0114] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

Claims

1. A method for identifying crop pests and diseases based on image recognition, characterized in that: include, Collect farmland images, identify and locate pest and disease areas in the images, and perform super-resolution restoration on low-resolution areas in the images; The local features of the image are extracted through the ViT model, and the multi-scale features of pests and diseases in the image are captured through DMSAU-Net. The types of pests and diseases are identified based on the extracted pest and disease features. Generate real-time pest and disease diagnosis reports based on the classification results and store the data generated during identification.

2. The method for identifying crop pests and diseases based on image recognition according to claim 1, characterized in that: The collecting of farmland images, identifying and locating pest and disease areas in the images refers to using automatic route planning software to set a drone flight path, the drone automatically flies according to a preset route, and collects image data of crops along the way. After pre-processing the collected image data, the regional features of the pests and diseases in the image are extracted through a convolutional neural network model, and the extracted feature map is input into a YOLOv4 target detection model to generate a boundary box of the pest and disease area.

3. The method for identifying crop diseases and insect pests based on image recognition as claimed in claim 2, characterized in that: The super-resolution restoration of the low-resolution area in the image refers to further analyzing the pest and disease area that has been initially located, using the Sobel operator to calculate the gradients of the image in the horizontal and vertical directions respectively, and calculating the gradient modulus of each pixel after obtaining the gradient value of each pixel through the gradient calculation; Set a threshold T. If the gradient modulus of a pixel is lower than the threshold T, the pixel area is a low-resolution area. The image of the low-resolution area is marked and normalized before being input into the SAGAN generator. The local features of the low-resolution image are extracted through the convolutional layer and the extracted features are linearly transformed to generate the query matrix, key matrix and value matrix respectively. The features of each pixel are converted into query vector, key vector and value vector through different weight matrices. Use the dot product to calculate the similarity between the query vector and the key vector, generate a similarity matrix, which represents the similarity between each pixel and other pixels, and use the Softmax function to normalize the similarity matrix to generate the final attention weight matrix; Through the attention weight matrix, the SAGAN generator combines the global information and local information of each pixel to form a global feature matrix; The residual block structure includes two convolutional layers, and a ReLU activation function is added after each convolutional layer. The generated global feature matrix is ​​used as the initial input of the residual network and two convolution operations are performed to obtain the feature map Y. The input features are added to the feature map Y through a jump connection to obtain the feature map Y1. The obtained feature map is passed to the residual block of the next layer for deeper convolution and feature extraction. After stacking multiple layers of residual blocks, a high-resolution feature map is obtained. Collect high-resolution images of crop pest and disease areas as real images, transmit the real images and the generated high-resolution feature maps to the discriminator for analysis to obtain the corresponding authenticity probabilities, and calculate the adversarial loss function based on the discriminator's output of the real images and the generated images; The calculation result of the adversarial loss is passed to the generator as feedback. The generator adjusts the parameters according to the feedback information to optimize the generated image and further optimizes the details through the perceptual loss. The perceptual loss extracts the intermediate layer features of the generated image and the real image through the VGG19 network and calculates the image difference. The calculated result of the perceptual loss is passed to the generator as feedback, and the generator further optimizes the generated image details based on the feedback information to obtain the final high-resolution pest and disease image.

4. The method for identifying crop pests and diseases based on image recognition as claimed in claim 3, characterized in that: The extracting of local features of the image by the ViT model and capturing the multi-scale features of pests and diseases in the image by the DMSAU-Net refers to dividing the pest and disease image into image blocks of fixed size, and linearly embedding each image block to convert it into a one-dimensional feature vector; Use the self-attention mechanism to calculate the feature correlation between each graphic block: In the formula, Q h and K h are the query matrix and key matrix of the h-th attention head, V is the value matrix, and W H (x) is the Hamming window function, d k is the scaling factor, H is the number of longs, and T is the transpose operation; The output of the self-attention mechanism is stacked in multiple layers, the calculation of the self-attention mechanism is repeatedly performed, and the local information is transferred to the global by stacking multiple layers of Transformer structure to obtain the global features. The DMSAU-Net is used to process the multi-scale features of the image through dilated convolution: Where y[i] is the output eigenvalue of the dilated convolution, x[i] is the input eigenvalue, and r s is the expansion rate, w s [k] is the weight of the kth convolution kernel at the sth scale, J1() is the Bessel function, K is the size of the convolution kernel, and S is the number of multi-scale convolutions; The features extracted under different expansion rates are fused to form a multi-scale feature representation to obtain the corresponding regional feature map; The spatial attention mechanism is used to further enhance the focus on pest and disease areas: In the formula, A s is the spatial attention weight, σ() is the Sigmoid activation function, and f conv (F) is the result of convolution operation on the input feature map F. It means applying the Laplacian operator to the feature map F, G(F,μ,ω) is the Gaussian kernel function, ‖F‖2 is the L2 norm of the feature map F; Different features are weighted according to the calculated spatial attention weights, and the features that have undergone multi-scale convolution processing and added with spatial attention weights are used as the final feature representation output to generate a feature set.

5. The method for identifying crop diseases and insect pests based on image recognition as claimed in claim 4, characterized in that: The method of identifying the type of pests and diseases according to the extracted pest and disease features refers to selecting SVM as a classification model, dividing the preprocessed image data into a training set and a test set, training the SVM model using a labeled training data set, optimizing the SVM model parameters through cross-validation and grid search, and evaluating the model performance using the test set after each training cycle. If there is no significant change in the verification difference after the training cycle, the model training is stopped to obtain the trained SVM model, and the feature set is input into the SVM model for classification to obtain the type of pests and diseases.

6. The method for identifying crop pests and diseases based on image recognition according to claim 5, characterized in that: Generating a real-time disease and insect pest diagnosis report based on the classification results refers to generating the range of affected crops based on the identified disease and insect pest types by comparing them with the disease and insect pest database, generating a disease and insect pest diagnosis report including the disease type, disease severity scale, affected crops and disease impact range based on the classification results and crop information, and generating corresponding prevention and control measures based on the disease and insect pest type and severity in the diagnosis report.

7. The method for identifying crop pests and diseases based on image recognition according to claim 6, characterized in that: The data generated during storage and identification refers to storing the image data collected and analyzed in a database. The database sorts the image data in chronological order and marks corresponding tags. The image data is backed up in the cloud synchronously, and the backup data is regularly checked for integrity.

8. A crop pest identification system based on image recognition based on the crop pest identification method based on image recognition according to any one of claims 1 to 7, characterized in that: include, An image analysis module is used to collect farmland images and analyze them after preprocessing them, so as to identify and locate the pest and disease areas in the farmland; An image restoration module is used to detect low-resolution image areas and restore the image to generate a high-resolution image; The feature extraction module is used to extract local features of the image and then process the multi-scale features in the image through dilated convolution, and combine the spatial attention mechanism to enhance the feature representation of the pest area; Classification module, used to classify the pests and diseases of farmland based on the extracted features and through the SVM model; The report generation module is used to generate pest and disease reports based on the classification results and provide prevention and control suggestions, and then store the data generated during the pest and disease identification process.

9. A computer device comprising: Memory and processor; The memory stores a computer program, wherein the processor implements the steps of the crop disease and insect pest identification method based on image recognition according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the crop disease and insect pest identification method based on image recognition according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Image translation method, system, medium and equipment

    CN115115870A

  • Remote sensing image super-resolution reconstruction method based on MT-SRGAN

    CN117196950A

  • Scutellaria baicalensis disease and pest identification system and method

    CN118628922A

  • Super-resolution on text-to-image synthesis with gans

    GB202319189D0

  • Expression recognition method based on attention-modulated contextual spatial information

    WO2023185243A1

Cited By

  • Jujube tree disease and insect pest monitoring and identifying method and system based on remote sensing technology

    CN120236250A

  • Disease and pest image multi-scale detection method, device and equipment and storage medium

    CN120953673A