Small sample plant disease identification method and device, medium and product

Through the two-way weighted feature fusion and situational attention module of the deep nearest neighbor neural network, combined with meta-learning and category marginal loss function, the over-fitting problem of plant disease identification under small samples is solved, and high-performance detection is achieved in the case of insufficient labeled samples. Accurate identification.

CN118587591AActive Publication Date: 2024-09-03ZHEJIANG UNIV OF SCI & TECH

Patent Information

Application Number
CN202410702798.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-09-03
Estimated Expiration
2044-06-03

AI Technical Summary

Technical Problem

Existing technology relies on a large amount of annotated data in plant disease identification, especially in deep neural networks. The annotation cost is high and the samples are insufficient, which can easily lead to overfitting, making it difficult to achieve accurate identification in small samples.

Method used

A deep nearest neighbor neural network is used to perform multi-scale feature fusion and attention feature calculation through a bidirectional weighted feature fusion module, situational attention module and measurement module. It combines meta-learning and category marginal loss functions to reduce the impact of background information and improve recognition accuracy. sex.

Benefits of technology

With fewer labeled samples, high-performance plant disease recognition is achieved, the ability to represent complex disease images is enhanced, the impact of irrelevant background information is reduced, and the recognition accuracy is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118587591A
    Figure CN118587591A
Patent Text Reader

Abstract

The invention discloses a small sample plant disease identification method and device, a medium and a product, and relates to the field of plant disease identification, and the method comprises the steps: inputting a disease image of a to-be-identified plant into a plant disease identification model, and obtaining a disease type of the to-be-identified plant; the plant disease identification model is determined based on a deep nearest neighbor neural network; the deep nearest neighbor neural network comprises a bidirectional weighted feature fusion module, a scene attention module and a measurement module which are connected in sequence; the bidirectional weighted feature fusion module is used for performing multi-scale feature fusion on the input image by adopting a pyramid fusion mode; the scene attention module is used for determining an attention feature map related to a scene where a plant in the input image is located; and the measurement module is used for calculating the similarity between the input image and each disease category according to the attention feature map, and determining the disease category of the plant in the input image. According to the method, plant disease identification can be realized under the condition that the number of marked samples is small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of plant disease identification, and in particular to a small sample plant disease identification method, device, medium and product. Background Art

[0002] Crop diseases are one of the most important agricultural disasters, often leading to a significant decline in crop yield and quality. In the past, farmers and agricultural experts mostly relied on personal experience to identify crop diseases, which was inefficient and easily affected by subjective factors. Due to the diversity of plant diseases and crop types, coupled with the influence of natural environmental elements such as light, occlusion, and shaking, there are huge differences between different crop diseases. In addition, different diseases of the same type of crops are often similar, which requires capturing subtle distinguishing features of specific areas, which poses a severe challenge to achieving accurate crop disease classification.

[0003] In recent years, deep learning methods have been widely used in image-based plant disease recognition tasks. However, existing excellent methods rely heavily on a large amount of labeled training data, especially when the network depth increases and the number of trainable parameters increases, data becomes more important. In the task of plant disease recognition, due to the variety of diseases, experts are required to label them, the labeling cost is high, and many diseases are relatively rare. It is very difficult and time-consuming to obtain a large number of manually labeled disease samples. Once the sample size is insufficient, the model will be at risk of overfitting, resulting in a decrease in performance. Therefore, how to identify plant diseases with fewer labeled samples has become an important research task. Summary of the invention

[0004] The purpose of the present invention is to provide a small sample plant disease identification method, device, medium and product, so as to realize plant disease identification when there are fewer marked samples.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] A method for identifying plant diseases with a small sample, the method comprising:

[0007] Acquire a target image; the target image is a disease image of a plant to be identified;

[0008] Inputting the target image into a plant disease recognition model to obtain the disease category of the plant to be identified;

[0009] The plant disease recognition model is obtained by training a deep nearest neighbor neural network using training data; the deep nearest neighbor neural network includes: a bidirectional weighted feature fusion module, a scenario attention module and a measurement module connected in sequence;

[0010] The bidirectional weighted feature fusion module is used to perform feature fusion of multiple scales on the input image by using a pyramid fusion method to obtain a high-level semantic feature map and a low-level feature map; the bidirectional weighted feature fusion module includes: a backbone network, an upsampling branch and a downsampling branch; the backbone network includes four network layers connected in sequence; the outputs of the first three network layers are connected to the upsampling branch; the upsampling branch is connected to the downsampling branch; the outputs of the first two network layers are residually connected to the downsampling branch; the upsampling branch is used to perform weighted summation and upsampling operations; the downsampling branch is used to perform weighted summation and downsampling operations; the first network layer is used as the input of the bidirectional weighted feature fusion module; the feature map output by the last network layer is the high-level semantic feature map; the feature map output by the downsampling branch is the low-level feature map;

[0011] The scenario attention module is used to determine an attention feature map related to the scene where the plant is located in the input image according to the high-level semantic feature map and the low-level feature map;

[0012] The measurement module is used to calculate the similarity between the input image and each disease category according to the attention feature map, and determine the disease category of the plant in the input image according to the similarity.

[0013] Optionally, the method for determining the plant disease identification model specifically includes:

[0014] Divide the training data into training set and test set;

[0015] Inputting the training set into a deep nearest neighbor neural network, and performing training by meta-learning with the goal of minimizing a category marginal loss function, to obtain a trained deep nearest neighbor neural network; the category marginal loss function is a loss function that introduces a cosine margin and an L2 regularization term;

[0016] The test set is input into the trained deep nearest neighbor neural network for testing, and the tested deep nearest neighbor neural network is determined as the plant disease recognition model.

[0017] Optionally, the scenario attention module includes a first channel attention submodule and a second channel attention submodule; the first channel attention submodule and the second channel attention submodule are used to perform channel attention operation;

[0018] The calculation formula of the scenario attention module is:

[0019]

[0020] Among them, X represents the high-level semantic feature map; Y represents the low-level feature map; X+Y is the input of the first channel attention submodule; Z is the input of the second channel attention submodule; M(X,Y) represents the attention feature map output by the context attention module when X and Y are input; a(l) represents the channel attention operation on l; l takes X+Y or Z.

[0021] Optionally, the calculation formula of the channel attention operation is:

[0022]

[0023] G(l)=β(C 1 (δ(β(C 1 (F Max (l))))));

[0024] L(l)=β(C 2 (δ(β(C 2 (F Avg (l))))));

[0025] Where G(l) represents the output of the global context channel; L(l) represents the output of the local context channel; Sigmoid represents the activation function; δ represents the Relu activation function; C 1 represents dilated convolution; C 2 represents point convolution; β represents batch normalization; F Max (l) represents the global maximum pooling of l; F Avg (l) represents global average pooling of l.

[0026] Optionally, the expression of the category marginal loss function is:

[0027]

[0028] in, Representing learnable parameters in deep nearest neighbor neural networks The corresponding category marginal loss function; Representing learnable parameters in deep nearest neighbor neural networks The corresponding loss function before the introduction of L2 regularization term; It is determined by introducing the cosine margin; λ represents the penalty term coefficient.

[0029] Optionally, the expression of the loss function before introducing the L2 regularization term is:

[0030]

[0031] Among them, L CMLrepresents the loss function before the L2 regularization term is introduced; C represents the number of disease categories in the support set; N represents the number of samples in the query set; C disease categories are randomly selected from the limited training set, and K samples are selected from each selected disease category to form a support set; N samples are randomly selected again from these C disease categories as the query set; represents a local descriptor for training determined according to an attention feature query graph of the nth sample in the query set; the attention feature query graph is an attention feature graph output by the context attention module after the nth sample in the query set is input into the context attention module; express Disease category c with support concentration f The similarity between express Disease category c with support concentration t The similarity between them; S represents the cosine margin; S = m × K × D, m represents the number of local descriptors used for training, D represents the distance added to the similarity between the samples in the query set and the disease categories in the support set; s represents the scale parameter.

[0032] Optionally, the upsampling branch includes: a first fusion unit, a first upsampling unit, a second fusion unit, a second upsampling unit and a third fusion unit; the downsampling branch includes: a fourth fusion unit, a first downsampling unit, a fifth fusion unit, a second downsampling unit, a sixth fusion unit and a third downsampling unit;

[0033] The output of the first network layer in the backbone network is connected to the fourth fusion unit through the first fusion unit; the output of the second network layer is connected to the fifth fusion unit through the second fusion unit; the second fusion unit is connected to the first fusion unit through the first upsampling unit; the fourth fusion unit is connected to the fifth fusion unit through the first downsampling unit; the output of the third network layer is connected to the sixth fusion unit through the third fusion unit; the third fusion unit is connected to the second fusion unit through the second upsampling unit; the fifth fusion unit is connected to the sixth fusion unit through the second downsampling unit; the third downsampling unit is used to output a low-level feature map;

[0034] The first fusion unit, the second fusion unit, the third fusion unit, the fourth fusion unit, the fifth fusion unit and the sixth fusion unit are all used for performing weighted summation;

[0035] The calculation formula of the second fusion unit is:

[0036]

[0037] represents the output of the second fusion unit to the third fusion unit; Represents the output of the second network layer; Represents the output of the third network layer; Represents the weight corresponding to the output of the second network layer; Upsample represents the upsampling operation;

[0038] The calculation formula of the fifth fusion unit is:

[0039]

[0040] represents the output of the fifth fusion unit to the second down-sampling unit; represents the weight corresponding to the output of the first downsampling unit; Downsample represents the downsampling operation; Represents the output of the fourth fusion unit to the first downsampling unit.

[0041] The present invention also provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-mentioned small sample plant disease identification method.

[0042] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned small sample plant disease identification method is implemented.

[0043] The present invention also provides a computer program product, including a computer program, which implements the above-mentioned small sample plant disease identification method when executed by a processor.

[0044] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0045] The embodiment of the present invention constructs a plant disease recognition model based on a deep nearest neighbor neural network. The bidirectional weighted feature fusion module in the deep nearest neighbor neural network uses a pyramid fusion method to perform feature fusion of multiple scales on the input image to obtain a high-level semantic feature map and a low-level feature map, better aggregate fine-grained features, and enhance the network's representation ability for complex disease images; the situational attention module determines the attention feature map related to the scene where the plant in the input image is located according to the high-level semantic feature map and the low-level feature map, effectively reducing the impact of irrelevant background information; the measurement module is used to calculate the similarity between the input image and each disease category according to the attention feature map, and determine the disease category of the plant in the input image. The deep nearest neighbor neural network with this structure can be trained to obtain a high-performance plant disease recognition model with less training data (i.e., small samples). Therefore, the present invention can realize plant disease recognition with fewer labeled samples. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0047] Figure 1 A schematic diagram of a process flow of a method for identifying plant diseases with a small sample size provided in Example 1 of the present invention;

[0048] Figure 2 A schematic diagram of the structure of a bidirectional weighted feature fusion module provided in Embodiment 1 of the present invention;

[0049] Figure 3 A schematic diagram of the structure of a situational attention module provided in Example 1 of the present invention;

[0050] Figure 4 A schematic diagram of the structure of a deep nearest neighbor neural network provided in Example 1 of the present invention;

[0051] Figure 5 A schematic diagram of feature space clustering and category marginal loss provided in Example 1 of the present invention;

[0052] Figure 6 A schematic diagram of the training process of the deep nearest neighbor neural network provided in Example 1 of the present invention;

[0053] Figure 7 A schematic diagram of the significance comparison of the experimental results provided in Example 1 of the present invention;

[0054] Figure 8 This is a diagram of the internal structure of a computer device. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] Few-shot learning is a new research direction inspired by the rapid learning ability of humans. Few-shot learning can quickly generalize to new categories with limited labeled data support without the need to re-collect data and train models. Few-shot learning has been successfully used in computer vision tasks. Applying few-shot learning to disease image classification is a promising field that is still in its early stages. Few-shot learning can directly classify disease categories that do not exist in the training set, which can save a lot of labeled images and retraining costs. Current few-shot methods mainly target natural scenes, but the difference between disease images and natural scenes is very significant. In natural scenes, plant diseases often have similar backgrounds, and the characteristics of different diseases in the same category are relatively similar.

[0057] The purpose of the present invention is to provide a small sample plant disease identification method, device, medium and product, aiming to achieve plant disease identification when there are fewer marked samples.

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

[0059] Example 1

[0060] like Figure 1 As shown, the small sample plant disease identification method in this embodiment includes:

[0061] Step 101: Acquire a target image; the target image is a disease image of a plant to be identified.

[0062] Step 102: Input the target image into a plant disease recognition model to obtain the disease category of the plant to be identified; wherein the plant disease recognition model is obtained by training a deep nearest neighbor neural network using training data; the deep nearest neighbor neural network includes: a bidirectional weighted feature fusion module, a contextual attention module, and a metric module connected in sequence.

[0063] The deep nearest neighbor neural network of this embodiment is a multi-scale attention fusion and discrimination enhanced deep nearest neighbor neural network (MAFDE-DN4) based on DN4.

[0064] The bidirectional weighted feature fusion module is used to perform feature fusion of multiple scales on the input image using a pyramid fusion method to obtain a high-level semantic feature map and a low-level feature map. The scenario attention module is used to determine the attention feature map related to the scene where the plant in the input image is located based on the high-level semantic feature map and the low-level feature map; the measurement module is used to calculate the similarity between the input image and each disease category based on the attention feature map, and determine the disease category of the plant in the input image based on the similarity.

[0065] The specific structure of each module in the above-mentioned deep nearest neighbor neural network is introduced below.

[0066] (1) Bidirectional weighted feature fusion module.

[0067] See also Figure 2 The bidirectional weighted feature fusion module includes: a backbone network, an upsampling branch and a downsampling branch.

[0068] The backbone network includes four network layers (Layer1-Layer4) connected in sequence; the outputs of the first three network layers are connected to the upsampling branch; the upsampling branch is connected to the downsampling branch; the outputs of the first two network layers are residually connected to the downsampling branch; the upsampling branch is used to perform weighted summation and upsampling operations; the downsampling branch is used to perform weighted summation and downsampling operations; the first network layer serves as the input of the bidirectional weighted feature fusion module; the feature map output by the last network layer is the high-level semantic feature map X; the feature map output by the downsampling branch is the low-level feature map Y.

[0069] like Figure 2 As shown, the upsampling branch includes, from left to right, a first fusion unit, a first upsampling unit, a second fusion unit, a second upsampling unit, and a third fusion unit. The downsampling branch includes, from left to right, a fourth fusion unit, a first downsampling unit, a fifth fusion unit, a second downsampling unit, a sixth fusion unit, and a third downsampling unit.

[0070] The output of the first network layer in the backbone network is connected to the fourth fusion unit through the first fusion unit; the output of the second network layer is connected to the fifth fusion unit through the second fusion unit; the second fusion unit is connected to the first fusion unit through the first upsampling unit; the fourth fusion unit is connected to the fifth fusion unit through the first downsampling unit; the output of the third network layer is connected to the sixth fusion unit through the third fusion unit; the third fusion unit is connected to the second fusion unit through the second upsampling unit; the fifth fusion unit is connected to the sixth fusion unit through the second downsampling unit; the third downsampling unit is used to output a low-level feature map.

[0071] The first fusion unit, the second fusion unit, the third fusion unit, the fourth fusion unit, the fifth fusion unit and the sixth fusion unit are all used for performing weighted summation.

[0072] The calculation formula of the second fusion unit is:

[0073]

[0074] represents the output of the second fusion unit to the third fusion unit; Represents the output of the second network layer; Represents the output of the third network layer; Represents the weight corresponding to the output of the second network layer; Upsample represents the upsampling operation.

[0075] The calculation formula of the fifth fusion unit is:

[0076]

[0077] represents the output of the fifth fusion unit to the second down-sampling unit; represents the weight corresponding to the output of the first downsampling unit; Downsample represents the downsampling operation; Represents the output of the fourth fusion unit to the first downsampling unit.

[0078] (2) Situational attention module.

[0079] The context attention module assigns different weights to local feature descriptors, allowing the network to pay more attention to features that are important to the current task and weaken the impact of background information. Figure 3 The scenario attention module includes a first channel attention submodule and a second channel attention submodule; the first channel attention submodule and the second channel attention submodule are used to perform channel attention operations.

[0080] The calculation formula of the scenario attention module is:

[0081]

[0082] Among them, X represents the high-level semantic feature map; Y represents the low-level feature map; X+Y is the input of the first channel attention submodule; Z is the input of the second channel attention submodule; M(X,Y) represents the attention feature map output by the context attention module when X and Y are input; a(l) represents the channel attention operation on l; l takes X+Y or Z.

[0083] The calculation formula of the channel attention operation is:

[0084]

[0085] G(l)=β(C 1 (δ(β(C 1 (F Max (l)))))) (6)

[0086] L(l)=β(C 2 (δ(β(C 2 (F Avg (l)))))) (7)

[0087] Where G(l) represents the output of the global context channel; L(l) represents the output of the local context channel; Sigmoid represents the activation function; δ represents the Relu activation function; C 1 represents dilated convolution; C 2 represents point convolution; β represents batch normalization; F Max (l) represents the global maximum pooling of l; F Avg (l) represents global average pooling of l.

[0088] (3) Measurement module.

[0089] The metric module is used to measure the similarity between the disease image in each query set and each class representation.

[0090] See also Figure 4 , a bidirectional weighted feature fusion module for learning local feature representation and a contextual attention module for generating attention feature maps Constructing deep embedding modules Deep Embedded Modules It is a multi-branch feature extraction fusion structure.

[0091] In view of the high similarity between plant diseases and significant differences within classes, this embodiment proposes a class margin loss and a deep embedding module. By learning the feature representations of all training samples, all samples are embedded into the feature space, and the samples in the support set S are used to generate class representations.

[0092] Specifically, after deep embedding modules The resulting attention feature map M(X,Y) (also called a deep feature descriptor) is a tensor of h×w×d, where h, w, and d correspond to its width, height, and number of channels, respectively. It can be viewed as a local descriptor of m=h×w dimensions, as described below:

[0093]

[0094] Where m represents the number of local descriptors. Then, the metric module is used to measure the similarity between each disease image and each class representation in the query set. Based on these similarities, the meta-learner generates a classification loss for each point in the current query set. Then the gradient of the total loss of all query samples is back-propagated. Specifically, each image in the given query set Q will be embedded into m local descriptors x i , and then find the k nearest neighbors from each class Then K-NN is used to calculate the cosine similarity between the query image and each category, x i and The similarity calculation formula is as follows:

[0095]

[0096] in represents the similarity between the nth sample (disease image) in the query set and the given support set category c, x i represents the i-th local descriptor of the n-th sample in the query set.

[0097] Based on these similarities, the meta-learner generates a classification loss for each sample in the current query set, and then backpropagates the gradient of the total loss for all query samples. The widely used classification loss function softmax loss is shown below:

[0098]

[0099] where p n Represents the classification probability of the disease image in the query set, C represents the number of disease categories in the support set; N represents the number of samples in the query set; C disease categories are randomly selected from the limited training set, and K samples are selected from each selected disease category to form a support set; N samples are randomly selected again from these C disease categories as the query set. In the metric module, the score of the category to which the query image belongs is usually calculated by the weighted sum of the cosine distances between local descriptors. In order to enhance feature discriminability and better separate similar classes in the feature space, an additional interval should be introduced for the softmax loss function, which helps to increase the inter-class distance in the embedding space so that the embedding function can better characterize the base class data. The similarity measurement module can more accurately predict the sample category and improve the accuracy of metric learning. To this end, this embodiment proposes a category margin loss (CML) for small sample learning. Through An additional margin is formulated to add additional discriminative distance to each class.

[0100] Specifically, in order to use the local descriptor in this embodiment as the basis for each query set image x and class c f The cosine similarity between them adds S = m × K × D distance, where each sample image has m local descriptors and K is the class c. f The number of samples included, D represents the distance added to the similarity between the samples in the query set and the disease categories in the support set. Finally, since the cos value interval is [-1,1], a scale parameter s is added to enlarge The improved CML is as follows:

[0101]

[0102] Among them, L CML represents the loss function before the L2 regularization term is introduced; C represents the number of disease categories in the support set; N represents the number of samples in the query set; f and t are both the numbers of disease categories; the fth disease category c f With the tth disease category c t Different; randomly select C disease categories from the limited training set, and select K samples from each selected disease category to form a support set; randomly select N samples from these C disease categories as the query set; represents a local descriptor for training determined according to an attention feature query graph of the nth sample in the query set; the attention feature query graph is an attention feature graph output by the context attention module after the nth sample in the query set is input into the context attention module; express Disease category c with support concentration f The similarity between express Disease category c with support concentration t The similarity between them; S represents the cosine margin; S = m × K × D, m represents the number of local descriptors used for training, D represents the distance added to the similarity between the samples in the query set and the disease categories in the support set; s represents the scale parameter.

[0103] Figure 5 The feature space clustering and class margin loss are shown. This embodiment adds an extra margin to each class to increase the discriminative distance. The margin is then integrated into the classification loss to make similar classes more separable in the embedding space.

[0104] For small sample learning methods, when generalizing to new categories in the test phase, overfitting will occur due to the small number of support set samples. This embodiment introduces the L2 regularization constraint term (also known as weight decay) based on the improved category marginal loss. This process aims to reduce the complexity of the model by adding a penalty term coefficient λ to the loss function to limit the size of the weight, thereby promoting the model to better generalize to unseen data. The specific loss function expression with the L2 regularization term is as follows:

[0105]

[0106] in, Representing learnable parameters in deep nearest neighbor neural networks The corresponding category marginal loss function; Representing learnable parameters in deep nearest neighbor neural networks The corresponding loss function before the introduction of L2 regularization term; It is determined by introducing the cosine margin; λ represents the penalty term coefficient.

[0107] The back propagation derivative formula is:

[0108]

[0109] Gradient descent formula before adding L2 regularization term:

[0110]

[0111] Gradient descent formula after adding L2 regularization term:

[0112]

[0113] Where α is the learning rate. When the regularization term is added, the weight decay of the parameters makes the network weights decrease continuously, which enhances the model's anti-disturbance ability and reduces overfitting in the case of data differences.

[0114] In one example, in combination with the above introduction to each module, the method for determining the plant disease identification model specifically includes:

[0115] (1) The training data is divided into a training set and a test set. C disease categories are randomly selected from the limited training set, and K samples are selected from each selected disease category to form a support set; N samples are randomly selected from these C disease categories as the query set.

[0116] (2) Input the training set into a deep nearest neighbor neural network, and train it by meta-learning with the goal of minimizing the category marginal loss function to obtain a trained deep nearest neighbor neural network; the category marginal loss function is a loss function that introduces cosine margin and L2 regularization terms. The expression of the category marginal loss function is shown in formula (13). The expression of the loss function before the L2 regularization term is introduced in formula (13) is shown in formula (12).

[0117] The training process may exemplarily include:

[0118] A classification task is constructed based on the base class data for training, and then a new classification task is constructed in the new class data for testing. The FSL dataset consists of base class data Dbase and Dnovel, where the Dbase and Dnovel data categories are mutually exclusive, which means that the data used in the test has not been seen in the training. Each classification task is set to N-way, K-shot, and a scenario training method is adopted. For each episode, C disease categories are randomly selected from a limited data set, and K samples are selected from each selected disease category to form a support set (Support Set, denoted as S). At the same time, a certain number of samples are randomly selected again from these C disease categories as the query set (Query Set, denoted as Q).

[0119] During the training process, an episode is extracted from the training data as input data. For each episode, there are N = 5 classes, but each class has only K = 1 labeled samples, which is called an N-way K-shot task. The network parameters are updated by decreasing the loss function, and a similar method is used in the subsequent validation and testing processes. Unlike updating parameters during training, the validation set is only used to select the optimal hyperparameters, and the test set is only used to evaluate model performance.

[0120] (3) Inputting the test set into the trained deep nearest neighbor neural network for testing, and determining the tested deep nearest neighbor neural network as the plant disease recognition model.

[0121] In order to obtain rich fine-grained information about plant diseases, the small sample plant disease recognition method of this embodiment designs a bidirectional weighted feature fusion module to fuse shallow features to enhance feature diversity, embeds upsampling branches and downsampling branches into the existing backbone network, and demonstrates good feature extraction capabilities; designs a scenario attention module to obtain scene category-related attention maps, divides deep local descriptors into scene-related and irrelevant parts, thereby effectively reducing the impact of irrelevant background information; improves the softmax loss function in the original DN4, introduces a cosine margin to push different categories away from each other, enhances the representation ability of local descriptors for base class data, learns a more discriminative feature space, and adds an L2 regularization constraint to stabilize the training process; adopts the MAFDE-DN4 network model to identify and classify plant leaf disease images, determines the category to which the leaf disease belongs, and can realize plant disease recognition with fewer labeled samples.

[0122] Combine the following Figure 6 , a specific implementation process of the above-mentioned small sample plant disease identification method in practical application is introduced, and the effectiveness of this method is verified.

[0123] The accurate identification of plant diseases based on deep learning can effectively improve crop yields. Its good detection performance depends largely on large-scale manually annotated data sets, which faces great technical and economic difficulties. In view of the scarcity of plant disease data in the prior art, the complexity of the distribution of diseased leaves in real scenes, and the significant intra-class differences and inter-class similarities of plant disease types, this specific example is based on the improved multi-scale attention fusion and discriminant enhanced deep nearest neighbor neural network MAFDE-DN4 of DN4 to obtain the category of plant leaf diseases. Among them, the bidirectional weighted feature fusion module with enhanced feature correlation can better aggregate fine-grained features and enhance the network's representation ability for complex disease images. In view of the problem that sparse feature descriptors are easily affected by irrelevant noise under small sample conditions, the scene attention module is used to obtain the scene category-related attention map, which effectively reduces the impact of irrelevant background information. An additional spacing is introduced between the category margins to improve the original softmax loss function, amplify the difference between classes and reduce the distance within the class, and add the L2 regularization constraint term to stabilize the training process.

[0124] In order to simulate different actual scenarios, different dataset settings are set. Under the 1-shot task and 5-shot settings, this embodiment achieved an accuracy of 59.61% and 81.41% under the intra-domain strategy, and an accuracy of 36.54% and 51.23% under the cross-domain strategy. The experimental results show that whether it is a dataset with a single background or a field dataset with a complex background in a real scenario, the method of this embodiment is superior to existing related work in the field of plant disease identification. MAFDE-DN4 based on small sample learning greatly reduces the demand for new categories of plant disease data. A specific implementation process is as follows:

[0125] 1. Preparation of experimental materials

[0126] In order to simulate the data samples collected in the real environment, the plant disease dataset is divided into three parts for training, validation and testing. According to the requirements of FSL, the categories of the training set, validation set and test set are not intersecting. 22 categories in PVG are used for training, 6 categories are used for validation, and 10 tomato categories are used for testing. In PV-FG-Setting, 28 categories of PVG are used for training and 6 categories are used for testing. In order to simulate the data samples collected in the real environment, the dataset shot in the real scene is used. The 10 categories of FGVC8 are used for testing with 1000 samples in each category. All samples in FGVC8 are shot in real scenes, and have more complex background information than the training set. All categories belong to apple leaf diseases, which belong to subclass classification tasks.

[0127] See also Figure 6 , MAFDE-DN4 small sample learning algorithm adopts episodic training method. The training process is the same as the standard meta-learning process, which includes two stages: meta-training and meta-testing. In the meta-training stage, the episodic training method is adopted. For each set, a small training set and test set are sampled from the entire base class data set to construct a small classification task. In the meta-testing stage, the trained model is used to identify samples from new categories. Specifically, in each episode of meta-training, N-way, K-shot are extracted from the base class data as classification samples. The metric-based meta-learning method (DN4) embeds the samples into the feature space, clusters all samples around each class separately, and then uses these class representations as labels to judge the test samples. After that, the metric module is used to measure the similarity between the query sample and each class representation in the embedding space.

[0128] 2. Shallow feature extraction of image samples

[0129] See also Figure 2The deep embedding module includes a bidirectional weighted feature fusion module and a context attention module. Layer1-Layer4 represents the traditional backbone network in the bidirectional weighted feature fusion module, such as resnet12 or conv4. The pyramid feature fusion structure in the bidirectional weighted feature fusion module includes a downsampling branch and an upsampling branch. These two branches are built based on the residual structure and feature fusion unit. On the first and second layer feature maps, the residual structure is used for cross-layer connection, which is specifically manifested as Figure 1 middle and In the figure, N represents the number of samples, C represents the number of channels, and H and W represent height and width respectively. The feature information extracted by the bidirectional weighted feature fusion module contains two output information, one is the high-level semantic feature map X in the feature pyramid, and the other is the low-level feature map Y that deeply fuses the shallow information of the first three layers. X and Y are broadcasted and added to get the input X, and the attention feature map is obtained through the scene attention module, see Figure 3 ,The context attention module contains a global context channel and a local context channel. The global context channel contains global maximum pooling and dilated convolution, and the local context channel contains global average pooling and point convolution.

[0130] Global average pooling is used to remove invalid information from local branches, and lightweight point convolution is used as a local channel context extractor to perform channel information interaction point by point at each spatial position. For the global branch, global maximum pooling is used to extract global features. Compared with global average pooling, maximum pooling can capture the significant features of a specific area by selecting the maximum value in the area, thereby better capturing the contour features of the object. In addition, dilated convolution is introduced to quickly expand the receptive field range and reduce the loss of feature information without introducing additional parameters. Considering that the quality of the initial integrated features may affect the final fusion weight, we directly use the initial input features X and Y as the fusion input of the second stage to avoid the influence of channel attention on the quality of the initial features.

[0131] It is understandable that compared with the complex feature extraction process in traditional algorithms, the image feature extraction module based on deep learning technology can quickly and easily extract image features, including image color, texture, and shape. In the case of image detection, the multi-layer image feature extraction module extracts rich detail information from low-level features and rich semantic information from high-level features to obtain better feature robustness.

[0132] refer to Figure 2, from left to right are the three fusion processes of the bidirectional weighted feature fusion module, and the final fusion output after the scene attention module. This experiment uses a heat map to compare the extraction effect of the improved deep embedding module on plant disease image features, and compares the effects of 4 types of plant diseases. This experiment uses the method described to extract disease information at multiple scales, which can focus on more disease areas and effectively reduce the impact of background noise. Figure 7 As shown, Figure 7 Part (A) represents the original input image. Figure 7 Part (B) of represents the output of the baseline model. Figure 7 Part (C) of the figure shows the outputs of different layers of the three fusion processes of the bidirectional weighted feature fusion module from left to right. Figure 7 The (D) part represents the final fusion output after the scenario attention module. As the network depth increases, the model focuses on the area from the edge to the location of the leaf disease. The rightmost side is the final output, which can accurately locate the diseased area. For example, in the fourth row of apple powdery mildew, the method of this embodiment effectively enhances the leaf area and reduces the influence of similar backgrounds. The above results show that the method of this embodiment can effectively highlight the discriminative features of the target in the recognition task compared to the baseline model, thereby improving the model recognition accuracy.

[0133] Example 2

[0134] A computer device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the small sample plant disease identification method in embodiment 1.

[0135] Example 3

[0136] A computer-readable storage medium stores a computer program, which implements the small sample plant disease identification method in embodiment 1 when executed by a processor.

[0137] Example 4

[0138] A computer program product includes a computer program, which implements the small sample plant disease identification method in embodiment 1 when executed by a processor.

[0139] Example 5

[0140] A computer device whose internal structure diagram can be shown as Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store pending transactions. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the small sample plant disease identification method in Example 1 is implemented.

[0141] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the object or fully authorized by all parties.

[0142] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present invention may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited thereto. The processor involved in each embodiment provided by the present invention may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, etc., but are not limited thereto.

[0143] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0144] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for identifying plant diseases using a small sample, characterized in that: The method comprises: Acquire a target image; the target image is a disease image of a plant to be identified; Inputting the target image into a plant disease recognition model to obtain the disease category of the plant to be identified; The plant disease recognition model is obtained by training a deep nearest neighbor neural network using training data; the deep nearest neighbor neural network includes: a bidirectional weighted feature fusion module, a scenario attention module and a measurement module connected in sequence; The bidirectional weighted feature fusion module is used to perform feature fusion of multiple scales on the input image by using a pyramid fusion method to obtain a high-level semantic feature map and a low-level feature map; the bidirectional weighted feature fusion module includes: a backbone network, an upsampling branch and a downsampling branch; the backbone network includes four network layers connected in sequence; the outputs of the first three network layers are connected to the upsampling branch; the upsampling branch is connected to the downsampling branch; the outputs of the first two network layers are residually connected to the downsampling branch; the upsampling branch is used to perform weighted summation and upsampling operations; the downsampling branch is used to perform weighted summation and downsampling operations; the first network layer is used as the input of the bidirectional weighted feature fusion module; the feature map output by the last network layer is the high-level semantic feature map; the feature map output by the downsampling branch is the low-level feature map; The scenario attention module is used to determine an attention feature map related to the scene where the plant is located in the input image according to the high-level semantic feature map and the low-level feature map; The measurement module is used to calculate the similarity between the input image and each disease category according to the attention feature map, and determine the disease category of the plant in the input image according to the similarity.

2. The small sample plant disease identification method according to claim 1, characterized in that: The method for determining the plant disease identification model specifically includes: Divide the training data into training set and test set; Inputting the training set into a deep nearest neighbor neural network, and performing training by meta-learning with the goal of minimizing a category marginal loss function, to obtain a trained deep nearest neighbor neural network; the category marginal loss function is a loss function that introduces a cosine margin and an L2 regularization term; The test set is input into the trained deep nearest neighbor neural network for testing, and the tested deep nearest neighbor neural network is determined as the plant disease recognition model.

3. The small sample plant disease identification method according to claim 1, characterized in that: The scenario attention module includes a first channel attention submodule and a second channel attention submodule; the first channel attention submodule and the second channel attention submodule are used to perform channel attention operations; The calculation formula of the scenario attention module is: Among them, X represents the high-level semantic feature map; Y represents the low-level feature map; X+Y is the input of the first channel attention submodule; Z is the input of the second channel attention submodule; M(X,Y) represents the attention feature map output by the context attention module when X and Y are input; a(l) represents the channel attention operation on l; l takes X+Y or Z.

4. The small sample plant disease identification method according to claim 3, characterized in that: The calculation formula of the channel attention operation is: a(l)=Sigmoid(G(l)⊕L(l)); G(l)=β(C1(δ(β(C1(F Max (l)))))); L(l)=β(C2(δ(β(C2(F Avg (l)))))); Among them, G(l) represents the output of the global context channel; L(l) represents the output of the local context channel; Sigmoid represents the activation function; δ represents the Relu activation function; C1 represents the dilated convolution; C2 represents the point convolution; β represents batch normalization; F Max (l) represents the global maximum pooling of l; F Avg (l) represents global average pooling of l.

5. The small sample plant disease identification method according to claim 2, characterized in that: The expression of the category marginal loss function is: in, Representing learnable parameters in deep nearest neighbor neural networks The corresponding category marginal loss function; Representing learnable parameters in deep nearest neighbor neural networks The corresponding loss function before the introduction of L2 regularization term; It is determined by introducing the cosine margin; λ represents the penalty term coefficient.

6. The method for identifying plant diseases using a small sample according to claim 5, characterized in that: The expression of the loss function before the introduction of the L2 regularization term is: Among them, L CML represents the loss function before the L2 regularization term is introduced; C represents the number of disease categories in the support set; N represents the number of samples in the query set; C disease categories are randomly selected from the limited training set, and K samples are selected from each selected disease category to form a support set; N samples are randomly selected again from these C disease categories as the query set; represents a local descriptor for training determined according to an attention feature query graph of the nth sample in the query set; the attention feature query graph is an attention feature graph output by the context attention module after the nth sample in the query set is input into the context attention module; express Disease category c with support concentration f The similarity between express Disease category c with support concentration t The similarity between them; S represents the cosine margin; S = m × K × D, m represents the number of local descriptors used for training, D represents the distance added to the similarity between the samples in the query set and the disease categories in the support set; s represents the scale parameter.

7. The small sample plant disease identification method according to claim 1, characterized in that: The upsampling branch includes: a first fusion unit, a first upsampling unit, a second fusion unit, a second upsampling unit and a third fusion unit; the downsampling branch includes: a fourth fusion unit, a first downsampling unit, a fifth fusion unit, a second downsampling unit, a sixth fusion unit and a third downsampling unit; The output of the first network layer in the backbone network is connected to the fourth fusion unit through the first fusion unit; the output of the second network layer is connected to the fifth fusion unit through the second fusion unit; the second fusion unit is connected to the first fusion unit through the first upsampling unit; the fourth fusion unit is connected to the fifth fusion unit through the first downsampling unit; the output of the third network layer is connected to the sixth fusion unit through the third fusion unit; the third fusion unit is connected to the second fusion unit through the second upsampling unit; the fifth fusion unit is connected to the sixth fusion unit through the second downsampling unit; the third downsampling unit is used to output a low-level feature map; The first fusion unit, the second fusion unit, the third fusion unit, the fourth fusion unit, the fifth fusion unit and the sixth fusion unit are all used for performing weighted summation; The calculation formula of the second fusion unit is: represents the output of the second fusion unit to the third fusion unit; Represents the output of the second network layer; Represents the output of the third network layer; Represents the weight corresponding to the output of the second network layer; Upsample represents the upsampling operation; The calculation formula of the fifth fusion unit is: represents the output of the fifth fusion unit to the second down-sampling unit; represents the weight corresponding to the output of the first downsampling unit; Downsample represents the downsampling operation; Represents the output of the fourth fusion unit to the first downsampling unit.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the small sample plant disease identification method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the small sample plant disease identification method according to any one of claims 1 to 7 is implemented.

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

Citation Information

Patent Citations

  • Deep learning-based tomato disease and insect pest detection and identification method

    CN116630803A

  • Small sample learning classification method for fruit and vegetable disease identification

    CN116843952A

Cited By

  • Image recognition method based on few-sample incremental learning and edge updating system

    CN121280807A

  • Plant leaf disease image small sample classification method

    CN121564391A