Agricultural disease identification method based on active learning

Through the combination of active learning and Transformer model, the problem of insufficient data set quality in agricultural disease identification is solved, the identification accuracy and efficiency are improved, and more accurate agricultural disease identification is achieved.

CN118657991APending Publication Date: 2024-09-17DALIAN NEUSOFT UNIV OF INFORMATION
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410746599.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Agricultural disease identification technology has problems such as limited data set size, uneven data distribution and poor data annotation quality, resulting in model overfitting and low identification accuracy.

Method used

Adopt an active learning-based method to construct a Transformer model for image detection/classification/segmentation by acquiring and preprocessing agricultural disease image data, and perform annotation and data enhancement based on the image annotation system to evaluate and update the training model to improve the data quality and model performance.

Benefits of technology

It effectively reduces the cost of manual annotation, improves the accuracy of training data, improves the generalization ability and recognition accuracy of the model, solves the over-fitting problem, and improves the identification efficiency of agricultural diseases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657991A
    Figure CN118657991A
Patent Text Reader

Abstract

The invention discloses an agricultural disease recognition method based on active learning, and the method comprises the steps: constructing a Transform-based image recognition model for image detection / classification / segmentation, and carrying out the evaluation according to a labeled data set and unlabeled data; the sample images which do not meet the evaluation indexes are added to the sample images in the to-be-labeled data set according to the evaluation result; performing field expert labeling on sample images in the to-be-labeled data set based on an image labeling system, updating the sample images labeled by field experts to a labeled data set, taking the sample images in the updated data set as input data, taking disease types of the sample images as output data, and performing field expert labeling on the sample images in the labeled data set; and based on an image classification verification evaluation function, an image segmentation evaluation function and an image detection evaluation function, updating training is performed on the Transform-based image recognition model to obtain a final image recognition model, so that the manual annotation cost is effectively reduced, the accuracy of training data is improved, the problem that a training data set in a specific field is insufficient is solved, and the training efficiency is improved. The problem that the agricultural disease identification precision and efficiency are insufficient due to the fact that the scale of agricultural disease data image annotation corpora is limited and a model is over-fitted is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of agricultural disease identification, and in particular to an agricultural disease identification method based on active learning. Background Art

[0002] my country's agricultural and rural reform and development have achieved remarkable results, providing solid support for maintaining the stability of the overall economic and social situation. The steady development and continuous strengthening of China's agriculture have benefited from the continuous introduction of a series of policies to promote grain production, the continuous strengthening of the basic support for modern agriculture, and the remarkable achievements in the high-quality development of agriculture. In 2022, the national contribution rate of agricultural science and technology progress reached 62.4%, and science and technology have further improved the comprehensive agricultural production capacity. Agricultural pests and diseases have long been one of the key factors affecting crop yield and quality. Agricultural diseases are mainly predicted and reported on-site by professionals, but this method has the disadvantages of high labor costs, low efficiency, and accuracy limited by the ability of staff.

[0003] With the advent of the Internet age and the development of computer technology, the use of machine automation to train agricultural disease prediction and identification models can effectively monitor crop pests. On the one hand, this method can reduce the use of pesticides and protect the quality and yield of crops. On the other hand, it can reduce labor costs. Pest and disease identification is of great significance to the development of smart agriculture.

[0004] Agricultural disease identification technology has attracted extensive attention from researchers in many fields such as machine learning, computer vision, and agricultural informatics. Famous research institutions for agricultural disease identification include the University of Novi Sad, the University of Bordeaux, and Juan Boumediene University of Science and Technology. Domestic research institutions mainly include the Institute of Agricultural Information of the Chinese Academy of Agricultural Sciences, the Key Laboratory of Agricultural Big Data of the Ministry of Agriculture and Rural Affairs, and the Institute of Agricultural Economics and Information of the Anhui Academy of Agricultural Sciences. The current mainstream research methods are traditional machine learning methods and deep learning methods, that is, training through machine learning methods or deep learning methods on specific data sets, and using the trained models to perform tasks such as classification or prediction. Relevant research institutions have achieved good results in feature extraction, vector representation, and image detection based on traditional machine learning, and have made certain progress in agricultural disease identification based on deep learning, but there is still room for further research and exploration in terms of improving data set quality and model training.

[0005] The quality of data directly determines the performance of model training. The dimensions of measuring data set quality include the number of data sets, whether the annotations are accurate and complete, data distribution, and whether the data is comprehensive. However, the current agricultural disease identification methods have the following problems:

[0006] 1) The current agricultural dataset has a limited corpus of agricultural disease data image annotations:

[0007] Currently, the types and quantity of publicly available agricultural disease data are limited, and the cost of collecting and labeling agricultural data is high. Small amounts of data can lead to overfitting of the model, which means that the model performs well on the training data but performs poorly on the test data. The reason for overfitting is that the model learns the details and noise of the training set too complexly, and the model has poor robustness and generalization ability.

[0008] 2) Currently, agricultural datasets have the problem of uneven data distribution:

[0009] Currently, most of the publicly available agricultural disease data are used for specific tasks. The high cost of data collection and annotation, the small number of data types and the small amount of data have led to prominent problems such as uneven distribution of agricultural disease data. The imbalanced data distribution is manifested in three aspects: imbalanced categories, too small distance between categories and too large distance within categories. The specific explanations for the imbalanced data distribution are as follows:

[0010] Category imbalance: When data is concentrated in a few categories, the model is prone to overfitting. That is, the categories with large data volumes are trained more fully during the training process, while the categories with small data volumes are not trained fully. As a result, when evaluating the performance of the model, the categories with large data volumes perform better, while the categories with small data volumes perform worse.

[0011] The inter-class distance is too small: refers to the distance between the data of each category. The smaller the distance, the higher the similarity of the images between categories. If the inter-class distance is too small, the agricultural diseases and background information of different categories are too similar, making it impossible for the model to accurately distinguish the features of different categories of data, thereby reducing the accuracy of the model and making it difficult for the model to converge during the training process.

[0012] Too large intra-class distance: refers to the distance between data belonging to the same category. The larger the distance, the lower the similarity of the pictures within the category. Large intra-class distance may mean that some data are mislabeled, which requires data cleaning. It may also be data of the same category with different light, different angles, and different backgrounds. This kind of data is correct data and can enhance the robustness and generalization ability of the model to a certain extent. In addition, due to the large differences in the same type of data, it is not easy for the model to converge when training a data set with too large intra-class distance.

[0013] 3) The agricultural dataset has poor data annotation quality, resulting in low accuracy in agricultural disease identification:

[0014] Agricultural disease data labeling requires a professional background in related fields. Currently, most of the labeling is done manually, which makes agricultural disease data labeling difficult. In addition, under different light, angles, and background information, some different types of diseases have similar appearances, but diseases of the same type are not similar, which reduces the accuracy of agricultural disease identification. Summary of the invention

[0015] The present invention provides an agricultural disease identification method based on active learning to overcome the above technical problems.

[0016] In order to achieve the above object, the technical solution of the present invention is:

[0017] An agricultural disease identification method based on active learning comprises the following steps:

[0018] S1: Acquire agricultural disease image data and preprocess it to obtain an agricultural disease image dataset;

[0019] The sample images in the agricultural disease image dataset include agricultural disease data crawled from the Internet, agricultural disease data downloaded from Plant Village, and photographed agricultural disease data;

[0020] S2: Obtain a labeled data set, an unlabeled data set, and a to-be-labeled data set of sample images, and the to-be-labeled data set is initially an empty set;

[0021] The annotated data set is obtained by processing sample images through the created image annotation system;

[0022] S3: Build a Transformer-based image recognition model for image detection / classification / segmentation;

[0023] S4: evaluating the labeled data set and the unlabeled data set by using the Transformer-based image recognition model, and adding sample images that do not meet the evaluation index to the sample images in the data set to be labeled according to the evaluation results;

[0024] The evaluation index includes a first evaluation index used for performing image detection on a labeled data set,

[0025] and the second evaluation metric used for image detection on unlabeled datasets;

[0026] S5: Perform domain expert annotation on sample images in the to-be-annotated dataset based on the image annotation system, and update the sample images annotated by the domain experts into the annotated dataset to obtain an updated dataset;

[0027] S6: Using the sample images in the update data set as input data, using the disease types of the sample images as output data, and updating the Transformer-based image recognition model based on the image classification verification evaluation function, the image segmentation evaluation function, and the image detection evaluation function;

[0028] S7: setting a maximum iteration number, and determining whether the current training iteration number has reached the maximum iteration number. If the current training iteration number has reached the maximum iteration number, confirming that the Transformer-based image recognition model after the current iteration training is the final image recognition model.

[0029] Otherwise, adaptively adjust the model parameter weights of the Transformer-based image recognition model, and repeat steps S5 to S6;

[0030] S8: Identify agricultural diseases based on the final image recognition model.

[0031] Furthermore, the image annotation system described in S2 includes an annotation module, a review module, and a data enhancement module;

[0032] The annotation module is used to perform image annotation operations on sample images to obtain an initial annotation set, and the image annotation operations include image classification annotation, image frame annotation, and image segmentation annotation;

[0033] The review module is used to evaluate the annotation quality of the sample images in the initial annotation set, and re-annotate the sample images that do not meet the annotation quality evaluation index to obtain an audit data set;

[0034] The data enhancement module is used to rotate the sample images in the audit data set, and obtain Gaussian distribution random numbers based on the box-muller algorithm to add noise to the sample images after the rotation operation, so as to enhance the image data and obtain the labeled data set.

[0035] Furthermore, the annotation quality evaluation index includes the annotation pixel accuracy error index and the annotation label correctness index, and its expression is:

[0036]

[0037]

[0038] Where: M(x, y) represents the regional pixels of the diseased leaves after being annotated by the annotation module; G(x, y) represents the regional pixels actually corresponding to the diseased leaves; W and H represent the width and height of the sample image respectively; ε represents the accuracy error of the annotation pixels; TP represents the number of diseased leaves correctly annotated; FP represents the number of normal leaves that are incorrectly annotated as diseased leaves; FN represents the number of diseased leaves that are incorrectly annotated; P represents the precision of the annotation module; R represents the recall rate of the annotation module; F-score represents the harmonic value of the recall rate and the precision rate, that is, the annotation label correctness index;

[0039] The expression for rotating the sample images in the audit dataset is:

[0040]

[0041] Where: θ represents the rotation angle; (P x ,P y ) represents the randomly generated rotation center; (x, y) represents the coordinates of each pixel in the sample image; (x′, y′) represents the pixel coordinates after rotation.

[0042] Furthermore, the Transformer-based image recognition model constructed in S3 includes an input layer, a linear mapping layer, a Transformer encoding layer, a classification layer, and an output layer connected in sequence;

[0043] The input layer is used to obtain the sample image to be identified and transmit it to the linear mapping layer;

[0044] The linear mapping layer is used to perform linear mapping on the received sample image to obtain a plurality of sub-image vectors, and perform position encoding embedding on each sub-image vector based on a fixed position encoder, obtain a sub-image vector containing a position vector and use it as an input vector;

[0045] The Transformer encoding layer is used to receive the input vector of the linear mapping layer to perform encoding operation to obtain image encoding data;

[0046] And the expression of the encoding operation performed by the Transformer encoding layer is

[0047] x′ l =MSA(LN(x l-1 ))+x l-1 ,l=1...L

[0048]

[0049] Where: x′ l The vector representing the output of the multi-head attention layer; x l-1 represents the input vector; L represents the dimension of the input vector; LN(·) represents the Layer Normalization standardization operation; y represents the output of the Transformer encoding layer; MLP represents the multi-layer perceptron; MSA represents the multi-head self-attention layer;

[0050] The classification layer is used to perform classification and recognition according to the image coding data, and output the classification and recognition results through the output layer.

[0051] Further, the S4 comprises the following steps:

[0052] S41: Perform image detection on the labeled data set based on the Transformer image recognition model to obtain a predicted classification label;

[0053] And obtain the prediction error value between the predicted classification label and the true classification label; and use it as a first evaluation indicator, and compare the first evaluation indicator with a preset first evaluation threshold;

[0054] If the first evaluation index is greater than a preset first evaluation threshold, confirm that the sample image in the labeled data set currently undergoing image detection is an incorrectly labeled sample graphic, and add it to the data set to be labeled;

[0055] Otherwise, confirm that the sample image in the annotated data set currently undergoing image detection is a correctly annotated sample image and retain it in the annotated data set;

[0056] S42: performing image detection on the unlabeled data set based on the Transformer image recognition model to obtain a second evaluation index for each pixel in each sample image;

[0057] The second evaluation index includes a model prediction confidence value and an entropy value, and the model prediction confidence value and the entropy value are compared with a preset confidence value threshold and a preset entropy value respectively;

[0058] And the sample images in the labeled data set whose model prediction confidence value is less than or equal to the preset confidence value threshold, or the sample images in the labeled data set whose entropy value is greater than the preset entropy value are added to the data set to be labeled.

[0059] Furthermore, the expression of the image classification verification evaluation function in S6 is:

[0060] macro_F=(F score1 +F score2 +…+F scoren ) / n

[0061] Where: macro_F represents the image classification verification evaluation value, i.e., the macro average value; F scoren It represents the harmonic value of recall and precision of the nth type of diseased leaves when the Transformer-based image recognition model is used for prediction; n represents the number of disease types of diseased leaves;

[0062] The image segmentation evaluation function and the image detection evaluation function both use the intersection over union function IoU and the average intersection over union function MIoU, and their expressions are:

[0063]

[0064] Where: TP′ represents the number of diseased leaves correctly predicted; FP′ represents the number of normal leaves that are incorrectly predicted as diseased leaves; FN′ represents the number of diseased leaves that are incorrectly predicted; P represents the precision of the Transformer-based image recognition model prediction; R represents the recall of the Transformer-based image recognition model prediction.

[0065] Beneficial effect: The present invention provides an agricultural disease recognition method based on active learning, by constructing a Transformer-based image recognition model for image detection / classification / segmentation, and evaluating according to labeled data sets and unlabeled data, and adding sample images that do not meet the evaluation indicators to the sample images in the data set to be labeled according to the evaluation results; then based on the image annotation system, the sample images in the data set to be labeled are annotated by domain experts, and the sample images annotated by domain experts are updated to the annotated data set, effectively reducing the manual annotation cost and improving the accuracy of training data, improving the problem of insufficient training data sets in specific fields, and solving the problem of overfitting of the model caused by the limited scale of agricultural disease data image annotation corpus, taking the sample images in the updated data set as input data, and taking the disease type of the sample image as output data, and based on the image classification verification evaluation function, the image segmentation evaluation function and the image detection evaluation function, the Transformer-based image recognition model is updated and trained to obtain the final image recognition model, thereby effectively improving the recognition accuracy and efficiency of agricultural diseases. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0067] Figure 1 It is a flow chart of the agricultural disease identification method based on active learning of the present invention;

[0068] Figure 2 : is the overall framework diagram of the agricultural disease identification method based on active learning in this embodiment;

[0069] Figure 3 This is a framework diagram of the Transformer-based image classification model in this embodiment. DETAILED DESCRIPTION

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

[0071] This embodiment provides an agricultural disease identification method based on active learning, such as Figure 1 to Figure 2 As shown, the following steps are included:

[0072] S1: Acquire agricultural disease image data and preprocess it to obtain an agricultural disease image dataset;

[0073] The sample images in the agricultural disease image dataset include agricultural disease data crawled from the Internet (crawled by crawler tools), agricultural disease data downloaded from PlantVillage, and photographed agricultural disease data;

[0074] Specifically, there are three main sources of agricultural disease image data used in this embodiment: crawling agricultural disease data on the Internet, collecting public agricultural disease data sets, and manually collecting agricultural disease data on site; among them, crawling agricultural disease data on the Internet mainly searches for image data related to agricultural diseases from existing agricultural research institutions, agricultural professional websites and forums, search engines, and social media. Specifically, crawling agricultural disease data on the Internet needs to first determine the URL address of the website or database to be crawled, analyze the structure and data format of the target website or database, determine the storage method and location of the image data, and finally use BeautifulSoup to crawl the image data;

[0075] The public dataset of agricultural diseases is mainly downloaded from Plant Village. This dataset uses Internet images to annotate healthy and diseased crop leaves, covering healthy and diseased images of crops such as apples, blueberries, corn, grapes, and oranges.

[0076] Manual on-site collection of agricultural disease data is difficult and costly. It is necessary to determine the collection specifications from aspects such as the data collection scope, shooting environment, and collection equipment. The specific collection specifications are as follows:

[0077] Data collection scope: diseased leaves of apples, grapes, tomatoes, etc.;

[0078] Shooting environment: shooting in different light (bright, dark, normal), different angles (overhead, sideways), and different times (summer, autumn, etc.);

[0079] Image size: 1200*1600;

[0080] File format: JPG;

[0081] Naming convention: serial number-collected data category;

[0082] Number of pictures: determined according to specific tasks and costs;

[0083] Applicable fields: agricultural disease detection, etc.

[0084] Collection equipment: smart phones, SLR cameras, drones, fixed collection equipment, etc.

[0085] The preprocessing is achieved by existing well-known technical means, including cleaning and processing the collected data, using tools such as opencv to batch remove duplicate data in leaves, analyze outliers, process missing data, and process irregular data, which will not be described in detail here;

[0086] S2: Obtain a labeled data set, an unlabeled data set, and a to-be-labeled data set of a sample image, wherein the to-be-labeled data set is initially an empty set; the labeled data set is obtained by processing the sample image through the created image labeling system;

[0087] And the image annotation system includes an annotation module, an audit module and a data enhancement module;

[0088] The annotation module is used to perform image annotation operations on sample images to obtain an initial annotation set, and the image annotation operations include image classification annotation, image frame annotation, and image segmentation annotation;

[0089] The review module is used to evaluate the annotation quality of the sample images in the initial annotation set, and re-annotate the sample images that do not meet the annotation quality evaluation index to obtain an audit data set;

[0090] Specifically, the annotation quality evaluation index includes the annotation pixel accuracy error index and the annotation label correctness index, and its expression is:

[0091]

[0092] Where: M(x, y) represents the regional pixels of the diseased leaves after being annotated by the annotation module; G(x, y) represents the regional pixels actually corresponding to the diseased leaves; W and H represent the width and height of the sample image respectively; ε represents the accuracy error of the annotation pixels, and the larger the ε is, the greater the difference between the annotated pixels in the data set and the actual pixels is, the worse the annotation quality is; the smaller the ε is, the smaller the difference between the annotated pixels in the data set and the actual pixels is, the better the annotation quality is; TP represents the number of diseased leaves correctly annotated; FP represents the number of normal leaves that are incorrectly annotated as diseased leaves; FN represents the number of diseased leaves that are incorrectly annotated; P represents the precision of the annotation module; R represents the recall rate of the annotation module; F-score represents the harmonic value of the recall rate and the precision rate, that is, the correctness index of the annotation label. When the value of F-score is larger, the more correct the annotation labels are, and the better the annotation quality is;

[0093] The data enhancement module is used to perform a rotation operation on the sample images in the audit data set, and obtain a Gaussian distribution random number based on the box-muller algorithm to add noise to the sample images after the rotation operation, so as to enhance the image data and obtain the labeled data set;

[0094] Most of the agricultural disease samples in this embodiment are photographed from the front of the leaves, but in actual applications, the photographer will shoot from multiple angles. Therefore, the existing images are randomly rotated and the rotation angle is less than 90 degrees.

[0095] The expression for rotating the sample images in the audit dataset is:

[0096]

[0097] Where: θ represents the rotation angle; (P x ,P y ) represents the randomly generated rotation center; (x, y) represents the coordinates of each pixel in the sample image; (x′, y′) represents the pixel coordinates after rotation.

[0098] In addition, data enhancement can be performed by adding noise to the original image. Since the color features of the lesions in the image need to be retained, Gaussian noise is added to simulate the blurring caused by lighting and jitter during shooting. Gaussian distribution random numbers are obtained through the box-muller algorithm and superimposed on the original image.

[0099] In this embodiment, an image annotation system is first established. The image annotation system is divided into an annotation module and an audit module. 5% of the data to be annotated is randomly selected and named D. 0, distributed to the annotation module for separate annotation. A small part of the data is selected for annotation in the first round. The annotation module uses the EasyData tool to perform image classification, frame annotation, and image segmentation annotation on the diseased leaves. The image classification annotation mainly distinguishes whether the image is a healthy leaf or a diseased leaf. If it is a diseased leaf, the specific disease category needs to be marked. The frame annotation needs to fit the rectangular frame as close to the diseased position as possible, and the edge pixel of the annotation object needs to be judged. Then, it is checked whether the surrounding borders of the frame are within 1 pixel of the edge pixel of the disease to prevent the annotation of redundant leaves and background information.

[0100] The review module is responsible for manually reviewing the data annotated by the annotation module. It can perform sampling or full sample review of the annotated data. It needs to determine whether the annotation is complete, accurate, and the annotation category is correctly identified. Samples that do not meet the quality requirements will be sent back for re-labeling. If most of the annotated data do not meet the quality requirements, they need to be sent back and re-labeled. The evaluation indicators of image annotation quality usually include the annotation pixel accuracy error and the correctness of the annotation label.

[0101] S3: Build a Transformer-based image recognition model for image detection / classification / segmentation;

[0102] Specifically, Figure 3 As shown, the Transformer-based image recognition model includes an input layer, a linear mapping layer, a Transformer encoding layer, a classification layer, and an output layer connected in sequence;

[0103] The input layer is used to obtain the sample image to be identified and transmit it to the linear mapping layer;

[0104] The linear mapping layer is used to perform linear mapping on the received sample image to obtain a plurality of sub-image vectors, and perform position encoding embedding on each sub-image vector based on a fixed position encoder, obtain a sub-image vector containing a position vector and use it as an input vector;

[0105] Specifically, the linear mapping layer is used to map the image into 1D data and obtain the sub-image vector. Here, one image is taken as an example, and the same operation is performed on the other images, that is, the image of size (224, 224) is divided into multiple sub-images of size (16, 16), and the dimension of each sub-image is (16, 16, 3). The sub-image is converted into 1D data, and the length is the product of the values ​​of each dimension of the sub-image, which is 768. Each image will produce 196 sub-images, that is, the input sequence length is 196, and the final image dimension is converted to (196, 768); the position vector uses fixed position encoding to obtain a standard trainable 1D position encoding embedding, and finally the position vector is added to the sub-image vector to obtain the input vector represented as x 0 , as the input of the Transformer encoding layer;

[0106] The Transformer encoding layer is used to receive the input vector of the linear mapping layer to perform encoding operation to obtain image encoding data;

[0107] Specifically, the function of the Transformer encoding layer is to perform Transformer encoding on the vector obtained by the linear mapping layer, and the Transformer encoder is composed of a multi-head self-attention layer MSA and a multi-layer perceptron block MLP. LayerNorm is applied before each multi-layer perceptron block, and a residual connection is applied after each multi-layer perceptron block. Q, K, and V represent the query, keys, and values ​​vectors respectively; W Q ,W K ,W V are their corresponding weight matrices, d k represents the dimension of K; its expression is

[0108]

[0109] head i =Attention(QW i Q ,KW i K ,VW i V )

[0110] MultiHead(Q,K,V)=Connect(head i ,...,head h )W O

[0111] Where: head i represents the attention head; i represents the number of attention heads; Multihead(Q,K,V) represents multi-head attention, that is, connecting multiple attention heads together; W o Represents the weight matrix corresponding to multi-head attention;

[0112] And the expression of the encoding operation performed by the Transformer encoding layer is

[0113] x′ l =MSA(LN(x l-1 ))+x l-1 ,l=1...L

[0114]

[0115] Where: x′l The vector representing the output of the multi-head attention layer; x l-1 represents the input vector; L represents the dimension of the input vector; LN(·) represents the Layer Normalization standardization operation; y represents the output of the Transformer encoding layer; MLP represents the multi-layer perceptron; MSA represents the multi-head self-attention layer;

[0116] The classification layer is used to perform classification and recognition according to the image coding data, and output the classification and recognition results through the output layer.

[0117] Specifically, the classification layer includes a fully connected layer and a tanh activation function, and the classification result is obtained through the fully connected layer and the tanh activation function. The training process for the image detection and segmentation tasks is similar to that for the image classification task, and the algorithm therein can be replaced by other machine learning algorithms for image detection and image segmentation tasks, for example, Yolov3 and Unet algorithms;

[0118] S4: performing evaluation according to the labeled data set and the unlabeled data set by using the Transformer-based image recognition model, and adding sample images that do not meet the evaluation index to sample images in the data set to be labeled according to the evaluation results;

[0119] The evaluation index includes a first evaluation index used for performing image detection on a labeled data set,

[0120] and the second evaluation metric used for image detection on unlabeled datasets;

[0121] In this embodiment, the data sources to be annotated include three parts of data: D 0 There may not be correctly labeled data in R 0 Data with low confidence in model predictions and R 0 The specific acquisition method for the data with large amount of information includes the following steps:

[0122] S41: Perform image detection on the labeled data set based on the Transformer image recognition model to obtain a predicted classification label; obtain a prediction error value between the predicted classification label and the true classification label; and use the error value as a first evaluation indicator, and compare the first evaluation indicator with a preset first evaluation threshold;

[0123] If the first evaluation index is greater than the preset first evaluation threshold, the sample image in the annotated data set currently undergoing image detection is confirmed to be an incorrectly annotated sample graphic, and is added to the data set to be annotated; otherwise, the sample image in the annotated data set currently undergoing image detection is confirmed to be a correctly annotated sample graphic, and is retained in the annotated data set;

[0124] That is, this implementation D 0 There may not be correctly labeled data in the 0 Model (Transformer-based image recognition model) for D 0 The image detection is performed on the dataset to obtain the predicted classification results of the diseases in the dataset. If the predicted label is consistent with D 0 If the labeling results are inconsistent, this part of the data may be D 0 If there are mislabeled data in the data set, then this part of the data is added to the data set to be labeled H 0 middle;

[0125] S42: Perform image detection on the unlabeled dataset based on the Transformer image recognition model to obtain a second evaluation index for each pixel in each sample image; the second evaluation index includes a model prediction confidence value and an entropy value, and the model prediction confidence value and entropy value are compared with a preset confidence value threshold and a preset entropy value respectively, and the sample images in the labeled dataset whose model prediction confidence value is less than or equal to the preset confidence value threshold; or the sample images in the labeled dataset whose entropy value is greater than the preset entropy value are added to the dataset to be labeled.

[0126] That is, this implementation obtains R 0 The model predicts data with low confidence, that is, the deep learning model is used to predict the unlabeled data as R 0 , obtain the confidence of the model prediction of each sample; if the confidence is lower than the threshold, this part of the data is the data with low confidence in model prediction, and it is added to the data set to be labeled H 0 And by obtaining R 0 Data with large amount of information: that is, select sample data with large entropy as the undetermined labeled data. The entropy calculation formula is:

[0127] x H =-∑ i P θ (y i |x)·lnP θ (y i |x)

[0128] Where: P θ (y i |x) means when the input is x, the output is y i The probability of the class; x represents the input data; y i Indicates the classification category;

[0129] S5: Perform domain expert annotation on sample images in the to-be-annotated dataset based on the image annotation system, and update the sample images annotated by the domain experts into the annotated dataset to obtain an updated dataset;

[0130] Specifically, the image annotation system uses the EasyData tool to manually annotate the data set H 0 , and check the data set H 0 Whether the labeling is correct, to obtain more valuable sample data;

[0131] S6: Using the sample images in the update data set as input data, using the disease types of the sample images as output data, and updating the Transformer-based image recognition model based on the image classification verification evaluation function, the image segmentation evaluation function, and the image detection evaluation function;

[0132] The expression of the image classification verification evaluation function is:

[0133]

[0134] macro_F=(F score1 +F score2 +…+F scoren ) / n

[0135] Where: macro_F represents the image classification verification evaluation value, i.e., the macro average value; F scoren It represents the harmonic value of recall and precision of the nth type of diseased leaves when the Transformer-based image recognition model is used for prediction; n represents the number of disease types of diseased leaves;

[0136] The image segmentation evaluation function and the image detection evaluation function both use the intersection-over-union function IoU and the average intersection-over-union function MIoU, that is, when the Transformer-based image recognition model is updated for image segmentation training, the image segmentation evaluation function is the intersection-over-union function IoU and the average intersection-over-union function MIoU; when the Transformer-based image recognition model is updated for image detection training, the image detection evaluation function is also the intersection-over-union function IoU and the average intersection-over-union function MIoU, and its expression is:

[0137]

[0138] Where: TP′ represents the number of diseased leaves correctly predicted; FP′ represents the number of normal leaves that are incorrectly predicted as diseased leaves; FN′ represents the number of diseased leaves that are incorrectly predicted; P represents the precision of the Transformer-based image recognition model prediction; R represents the recall of the Transformer-based image recognition model prediction.

[0139] S7: setting a maximum iteration number, and determining whether the current training iteration number has reached the maximum iteration number. If the current training iteration number has reached the maximum iteration number, confirming that the Transformer-based image recognition model after the current iteration training is the final image recognition model.

[0140] Specifically, the manually annotated data is updated to the training data of image classification, detection, and segmentation, and the image classification, detection, and segmentation models are updated through incremental learning or relearning to improve the model effect. The process of obtaining the dataset to be annotated, the annotation by domain experts, and the update of the deep learning model is repeated until the iteration round exceeds the set threshold, and the final image classification, detection, and segmentation model is obtained;

[0141] Otherwise, adaptively adjust the model parameter weights of the Transformer-based image recognition model through the back propagation algorithm, and repeat steps S5 to S6;

[0142] S8: Identify agricultural diseases based on the final image recognition model.

[0143] This embodiment constructs a Transformer-based image recognition model for image detection / classification / segmentation, and evaluates it based on the labeled data set and the unlabeled data, and adds sample images that do not meet the evaluation indicators to the sample images in the data set to be labeled based on the evaluation results; then, based on the image annotation system, the sample images in the data set to be labeled are annotated by domain experts, and the sample images annotated by domain experts are updated to the annotated data set, thereby effectively reducing the cost of manual annotation and improving the accuracy of training data, improving the problem of insufficient training data sets in specific fields, and solving the problem of overfitting of the model caused by the limited scale of the image annotation corpus of agricultural disease data. The sample images in the updated data set are used as input data, and the disease type of the sample image is used as output data. Based on the image classification verification evaluation function, the image segmentation evaluation function and the image detection evaluation function, the Transformer-based image recognition model is updated and trained to obtain the final image recognition model, thereby effectively improving the recognition accuracy and efficiency of agricultural diseases.

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

Claims

1. A method for identifying agricultural diseases based on active learning, characterized in that: The following steps are involved: S1: Acquire agricultural disease image data and preprocess it to obtain an agricultural disease image dataset; The sample images in the agricultural disease image dataset include agricultural disease data crawled from the Internet, agricultural disease data downloaded from PlantVillage, and photographed agricultural disease data; S2: Obtain a labeled data set, an unlabeled data set, and a to-be-labeled data set of sample images, and the to-be-labeled data set is initially an empty set; The annotated data set is obtained by processing sample images through the created image annotation system; S3: Build a Transformer-based image recognition model for image detection / classification / segmentation; S4: evaluating the labeled data set and the unlabeled data set by using the Transformer-based image recognition model, and adding sample images that do not meet the evaluation index to the sample images in the data set to be labeled according to the evaluation results; The evaluation index includes a first evaluation index used for performing image detection on a labeled data set, and the second evaluation metric used for image detection on unlabeled datasets; S5: Perform domain expert annotation on sample images in the to-be-annotated dataset based on the image annotation system, and update the sample images annotated by the domain experts into the annotated dataset to obtain an updated dataset; S6: Using the sample images in the update data set as input data, using the disease types of the sample images as output data, and updating the Transformer-based image recognition model based on the image classification verification evaluation function, the image segmentation evaluation function, and the image detection evaluation function; S7: setting a maximum iteration number, and determining whether the current training iteration number has reached the maximum iteration number. If the current training iteration number has reached the maximum iteration number, confirming that the Transformer-based image recognition model after the current iteration training is the final image recognition model. Otherwise, adaptively adjust the model parameter weights of the Transformer-based image recognition model, and repeat steps S5 to S6; S8: Identify agricultural diseases based on the final image recognition model.

2. The agricultural disease identification method based on active learning according to claim 1, characterized in that: The image annotation system described in S2 includes an annotation module, a review module, and a data enhancement module; The annotation module is used to perform image annotation operations on sample images to obtain an initial annotation set, and the image annotation operations include image classification annotation, image frame annotation, and image segmentation annotation; The review module is used to evaluate the annotation quality of the sample images in the initial annotation set, and re-annotate the sample images that do not meet the annotation quality evaluation index to obtain an audit data set; The data enhancement module is used to rotate the sample images in the audit data set, and obtain Gaussian distribution random numbers based on the box-muller algorithm to add noise to the sample images after the rotation operation, so as to enhance the image data and obtain the labeled data set.

3. The agricultural disease identification method based on active learning according to claim 2 is characterized in that: The annotation quality evaluation index includes the annotation pixel accuracy error index and the annotation label correctness index, and its expression is: Where: M(x, y) represents the regional pixels of the diseased leaves after being annotated by the annotation module; G(x, y) represents the regional pixels actually corresponding to the diseased leaves; W and H represent the width and height of the sample image respectively; ε represents the accuracy error of the annotation pixels; TP represents the number of diseased leaves correctly annotated; FP represents the number of normal leaves that are incorrectly annotated as diseased leaves; FN represents the number of diseased leaves that are incorrectly annotated; P represents the precision of the annotation module; R represents the recall rate of the annotation module; F-score represents the harmonic value of the recall rate and the precision rate, that is, the annotation label correctness index; The expression for rotating the sample images in the audit dataset is: Where: θ represents the rotation angle; (P x ,P y ) represents the randomly generated rotation center; (x, y) represents the coordinates of each pixel in the sample image; (x′, y′) represents the pixel coordinates after rotation.

4. The agricultural disease identification method based on active learning according to claim 3 is characterized in that: The Transformer-based image recognition model constructed in S3 includes an input layer, a linear mapping layer, a Transformer encoding layer, a classification layer, and an output layer connected in sequence; The input layer is used to obtain the sample image to be identified and transmit it to the linear mapping layer; The linear mapping layer is used to perform linear mapping on the received sample image to obtain a plurality of sub-image vectors, and perform position encoding embedding on each sub-image vector based on a fixed position encoder, obtain a sub-image vector containing a position vector and use it as an input vector; The Transformer encoding layer is used to receive the input vector of the linear mapping layer to perform encoding operation to obtain image encoding data; And the expression of the encoding operation performed by the Transformer encoding layer is x l '=MSA(LN(x l-1 ))+x l-1 ,l=1...L Where: x′ l The vector representing the output of the multi-head attention layer; x l-1 represents the input vector; L represents the dimension of the input vector; LN(·) represents the Layer Normalization standardization operation; y represents the output of the Transformer encoding layer; MLP represents the multi-layer perceptron; MSA represents the multi-head self-attention layer; The classification layer is used to perform classification and recognition according to the image coding data, and output the classification and recognition results through the output layer.

5. The agricultural disease identification method based on active learning according to claim 4 is characterized in that: The S4 comprises the following steps: S41: Perform image detection on the labeled data set based on the Transformer image recognition model to obtain a predicted classification label; And obtain the prediction error value between the predicted classification label and the true classification label; and use it as a first evaluation indicator, and compare the first evaluation indicator with a preset first evaluation threshold; If the first evaluation index is greater than a preset first evaluation threshold, confirm that the sample image in the labeled data set currently undergoing image detection is an incorrectly labeled sample graphic, and add it to the data set to be labeled; Otherwise, confirm that the sample image in the annotated data set currently undergoing image detection is a correctly annotated sample image and retain it in the annotated data set; S42: performing image detection on the unlabeled data set based on the Transformer image recognition model to obtain a second evaluation index for each pixel in each sample image; The second evaluation index includes a model prediction confidence value and an entropy value, and the model prediction confidence value and the entropy value are compared with a preset confidence value threshold and a preset entropy value respectively; And the sample images in the labeled data set whose model prediction confidence value is less than or equal to the preset confidence value threshold, or the sample images in the labeled data set whose entropy value is greater than the preset entropy value are added to the data set to be labeled.

6. The agricultural disease identification method based on active learning according to claim 1, characterized in that: The expression of the image classification verification evaluation function described in S6 is: macro_F=(F score1 +F score2 +…+F scoren ) / n Where: macro_F represents the image classification verification evaluation value, i.e., the macro average value; F scoren It represents the harmonic value of recall and precision of the nth type of diseased leaves when the Transformer-based image recognition model is used for prediction; n represents the number of disease types of diseased leaves; The image segmentation evaluation function and the image detection evaluation function both use the intersection over union function IoU and the average intersection over union function MIoU, and their expressions are: Where: TP′ represents the number of diseased leaves correctly predicted; FP′ represents the number of normal leaves that are incorrectly predicted as diseased leaves; FN′ represents the number of diseased leaves that are incorrectly predicted; P represents the precision of the Transformer-based image recognition model prediction; R represents the recall of the Transformer-based image recognition model prediction.

Citation Information

Cited By

  • Underwater image structure disease full-automatic marking method and system

    CN118898775A

  • Change detection pattern spot optimization method, electronic equipment and computer product

    CN119887833A

  • Change detection patch optimization method, electronic device, and computer product

    CN119887833B