Tea disease detection method and system
By using ResNet-50 and self-attention distillation module in tea disease detection, combined with multi-scale feature adaptive fusion module, the problem of high computational complexity and inability to capture long-distance dependencies in tea disease detection is solved. Improve detection accuracy and model generalization capabilities.
Patent Information
- Application Number
- CN202411352619.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-27
AI Technical Summary
In the detection of tea disease, traditional CNN models have high computational complexity and large memory overhead in tea disease, which can't capture long-distance dependencies, affecting detection accuracy.
ResNet-50 is used as the backbone network, and the residual block of ResNet is introduced for multi-scale feature extraction, and through the self-attention distillation module and the multi-scale feature adaptive fusion module, global and local information are captured and feature maps are fused to improve detection accuracy.
It effectively reduces the impact of scale changes and complex background on detection accuracy, improves the accuracy of tea disease detection, and enhances the robustness and generalization ability of the model.
Smart Images

Figure CN119206440A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically to a tea disease detection method and system integrating multi-scale features and self-attention distillation. Background Art
[0002] As one of my country's traditional cash crops, tea has important economic and cultural value. However, the growth process of tea is easily affected by diseases, which is a key factor affecting the yield and quality of tea. Therefore, it is of great significance to realize rapid detection of tea diseases as early as possible during the tea growth cycle and assist tea farmers in controlling diseases, so as to improve the tea farmers' response speed to diseases.
[0003] Traditional identification of tea diseases is mostly done manually, which is inefficient and costly. Therefore, it is of great significance to study how to use machine vision and image perception to automatically, timely and accurately identify tea diseases. With the rise of computer vision technology, image processing and machine learning technology have been applied to the detection of plant diseases.
[0004] At present, tea disease detection methods mainly include those based on machine learning models and neural network models. Traditional machine learning models such as decision trees, support vector machines (SVM), K-means clustering, random forests, etc. require artificially designed feature extraction methods for different types of diseases, and then training and detection. This process is very complicated and easily interfered by environmental factors such as light, shooting angle and background. Moreover, the model has weak generalization ability and cannot be effectively applied to other types of detection tasks. In recent years, with the development of deep learning in the field of target detection, this method has also been applied to tea disease detection. Among them, the convolutional neural network (CNN) can automatically learn the multi-level and high-order features of the shape, color, texture and other disease images in tea disease detection with its powerful feature extraction ability. Compared with the shortcomings of traditional methods that require artificially designed features, CNN has obvious advantages in disease detection and has produced many research results. However, when dealing with complex tea disease detection scenarios, although the feature maps generated by convolutional neural networks can effectively express local features, they cannot capture the global correlation information between long-distance pixels, which limits the traditional methods' accurate understanding of the overall structure and global features of tea disease images. Especially when dealing with disease scales that vary and backgrounds that are complex, traditional methods cannot accurately understand the overall situation of tea diseases, leading to further challenges to their detection performance. Compared with CNN, the Transformer model gives feature extractors more powerful global information interaction capabilities through the self-attention mechanism, enabling them to quickly establish a global receptive field, thereby achieving more accurate scene understanding. This advantage effectively makes up for the shortcomings of CNN in dealing with tea disease detection.
[0005] However, when processing image data, traditional CNN models usually divide the image into a series of small blocks and process these small blocks separately, which has high computational complexity and large memory overhead, and cannot capture long-distance dependencies, affecting the accuracy of tea disease detection. Summary of the invention
[0006] In response to the problems existing in the above-mentioned fields, the present invention proposes a tea disease detection method and system, which can solve the technical problems that the traditional CNN model usually divides the image into a series of small blocks and processes these small blocks separately, has high computational complexity and large memory overhead, and cannot capture long-distance dependencies, thus affecting the accuracy of tea disease detection.
[0007] In order to solve the above technical problems, the present invention discloses a method for detecting tea diseases, comprising the following steps:
[0008] Acquire tea disease images to be detected;
[0009] Construct a network model; the network model includes a multi-scale feature extraction module that uses ResNet-50 as a backbone network and introduces a residual block of ResNet as the backbone of the backbone network to extract feature maps; a self-attention distillation module that introduces a self-attention mechanism on the extracted feature maps to obtain global and local feature maps; and a multi-scale feature adaptive fusion module that fuses the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module;
[0010] Train the network model to obtain a tea disease detection model;
[0011] The tea disease image to be detected is input into the tea disease detection model, and the feature of the tea disease image is extracted through the residual block of ResNet to obtain a multi-scale feature map of the tea disease image; the multi-scale feature map is input into the self-attention mechanism in parallel, and the global and local feature maps of the tea disease image are obtained by capturing the global and local information of the tea disease image; the multi-scale, global and local feature maps of the tea disease image are fused to obtain the fused tea disease representation, the tea disease is detected, and the tea disease detection result is output.
[0012] Preferably, the step of obtaining a multi-scale feature map of a tea disease image comprises the following steps:
[0013] The backbone network ResNet-50 uses the residual block of ResNet as the basic structure. ResNet is a deep convolutional neural network. The residual connection of the residual block of ResNet is introduced to solve the gradient disappearance problem in the deep network.
[0014] Each residual block of ResNet-50 contains multiple convolutional layers and a skip connection to capture multi-scale and local range tea disease information; feature maps of different scales of tea disease images are extracted through the convolutional layers, and the feature maps of different scales of the input tea disease images are directly transferred to the output feature maps through the skip connection.
[0015] Preferably, the obtaining of global and local feature maps comprises the following steps:
[0016] By constructing multiple branches, multi-scale feature maps are extracted, and each branch is responsible for processing feature maps at a specific scale;
[0017] A self-attention mechanism is introduced on the extracted multi-scale feature maps, and the captured multi-scale and local tea disease information is input into the self-attention mechanism in parallel. The self-attention mechanism learns the detail information in the feature maps of different scales and combines the detail information with the global representation to obtain the global and local feature maps, forming a representation of the global and local areas.
[0018] Preferably, the fusing of multi-scale, global and local feature maps of the tea disease image comprises the following steps:
[0019] According to the multi-scale feature map of the tea disease image and the global and local feature maps of the leaf disease image, the features of different scales and branches of the tea disease image are extracted, including feature maps of different resolutions and feature representations of different branches;
[0020] The features of different scales and branches of the extracted tea disease images are combined and weighted, and adaptive weight parameters are assigned to feature maps of different scales through a multi-scale feature adaptive fusion module to obtain the fused tea disease representation.
[0021] Preferably, the network architecture of the multi-scale feature adaptive fusion module specifically includes:
[0022] The multi-scale feature adaptive fusion module includes Concat, Upsample, Conv, CBS Bottleneckwith 3convolutions modules and an adaptive feature fusion module AFF, wherein:
[0023] Through the multi-scale feature adaptive fusion module, adaptive weight parameters are assigned to feature maps of different scales;
[0024] The adaptive feature fusion module is used to fuse and automatically learn to filter out useless information, and the fusion process is differentiable, and the weights are learned and updated through back propagation;
[0025] The three CSP Bottleneck with 3 convolutions modules in the middle column output three feature layers of different scales, which are fused to obtain the adaptive feature fusion modules AFF1, AFF2 and AFF3. The features of the three layers corresponding to AFF1, AFF2 and AFF3 are transformed, multiplied by the corresponding weight coefficients and added to obtain the new fused feature maps AFF1, AFF2 and AFF3.
[0026] Preferably, the outputting of tea disease detection results comprises the following steps:
[0027] The fused tea disease representation is used as the input of the classification and regression tasks in the tea disease detection process;
[0028] Tea disease detection includes the location and classification of tea diseases. By introducing the loss function, the accuracy of the tea disease detection process for target location and category detection is evaluated.
[0029] Preferably, the calculation formula of the loss function is:
[0030] L=L loc +L conf +L cls
[0031] Where, L loc represents the positioning loss, L cls represents the classification loss, L conf represents the confidence loss;
[0032] Among them, the positioning loss adopts CIoU loss, while considering the area of the overlapping area, the center distance of the bounding box, and the consistency of the aspect ratio of the bounding box; the calculation process of CIoU loss is:
[0033]
[0034]
[0035]
[0036] Where c is the diagonal distance between the predicted box and the minimum closure area of the real box, ρ is the Euclidean distance function, b and b gt are the center points of the predicted box and the true box, ν is the similarity of the aspect ratio, α is the weight coefficient, w and h are the width and height of the predicted box, respectively;
[0037] That is, the positioning loss L loc The calculation process is:
[0038]
[0039] Where i represents the row index of the image grid, j represents the column index of the image grid, is an indicator function indicating whether the jth bounding box of the i-th grid contains the target object; S 2 represents the scale of the image, and B represents the number of bounding boxes;
[0040] Classification loss L cls The binary cross entropy loss function is used, and the calculation formula is:
[0041]
[0042] In the formula, c' is the currently recognized category, and classes is all the categories to be detected; and are the predicted probability and true probability that the target in the j-th anchor box of the i-th grid belongs to category c';
[0043] Confidence loss L conf The calculation formula is:
[0044]
[0045] In the formula, Indicates whether the j-th anchor box of the i-th grid does not have an object. If there is no object, it is 1, otherwise it is 0; noobj is a constant coefficient used to balance the impact of positive and negative samples on the loss function; and are the confidence of the predicted box and the true value box respectively.
[0046] Preferably, the tea disease images to be detected include tea disease information of tea net cake disease, tea round red star disease, tea cloud leaf blight disease, tea cake disease, tea red rust algae disease and tea algae spot disease.
[0047] Preferably, the training of the network model comprises the following steps:
[0048] Use the labelimg image annotation tool to mark each sample image, annotate the bounding box of the tea disease target, and use the labeled sample images as training sets to train the tea disease detection model.
[0049] Preferably, a tea disease detection system is also included, comprising:
[0050] A data acquisition module, used to acquire tea disease images to be detected;
[0051] A tea disease detection model construction module is used to construct a network model; the network model includes a multi-scale feature extraction module that uses ResNet-50 as a backbone network and introduces the residual block of ResNet as the backbone of the backbone network to extract feature maps; a self-attention distillation module is used to introduce a self-attention mechanism on the extracted feature maps to obtain global and local feature maps; a multi-scale feature adaptive fusion module is used to fuse the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module; the network model is trained to obtain a tea disease detection model;
[0052] The tea disease detection module is used to input the tea disease image to be detected into the tea disease detection model, extract the features of the tea disease image through the residual block of ResNet, and obtain the multi-scale feature map of the tea disease image; input the multi-scale feature map in parallel into the self-attention mechanism, and obtain the global and local feature maps of the tea disease image by capturing the global and local information of the tea disease image; fuse the multi-scale, global and local feature maps of the tea disease image to obtain the fused tea disease representation, detect the tea disease, and output the tea disease detection result.
[0053] Compared with the prior art, the present invention has the following beneficial effects:
[0054] The tea disease detection method proposed by the present invention uses a tea disease detection model constructed by the invention. The model uses ResNet-50 as a backbone network, introduces the residual block of ResNet as the backbone of the backbone network to extract feature maps, can effectively extract feature information of tea disease images, and has good translation invariance, and provides a good input basis for feature extraction of subsequent self-attention distillation modules and feature fusion of multi-scale feature adaptive fusion modules. By introducing a self-attention mechanism on the extracted feature maps to realize the interaction of global and local information, and obtain global and local feature maps, the self-attention mechanism can also learn the detail information in feature maps of different scales, and combine it with the global representation to form an accurate representation of the global and local regions. The multi-scale, global and local feature maps are weighted fused, and feature maps of different scales are input in parallel to obtain a more comprehensive and accurate representation of tea diseases, which can effectively reduce the influence of scale changes and complex backgrounds on detection accuracy, and improve the accuracy of the model, so as to effectively deal with the problems of variable scales of tea diseases and small data sets. This tea disease detection model can provide a reference for intelligent diagnosis of tea diseases, help tea farmers detect and identify tea diseases more accurately, take timely control measures, protect the health of tea gardens, and improve the quality and yield of tea. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a schematic diagram of the overall method flow of the present invention;
[0056] Figure 2 A tea disease detection model architecture integrating multi-scale features and self-attention distillation proposed in an embodiment of the present invention;
[0057] Figure 3 A diagram showing the backbone network structure of a tea disease detection model provided by an embodiment of the present invention;
[0058] Figure 4 A network architecture diagram of the self-attention distillation module of the tea disease detection model provided in an embodiment of the present invention;
[0059] Figure 5 A distillation principle diagram based on an intermediate layer feature map of a self-attention distillation module of a tea disease detection model provided in an embodiment of the present invention;
[0060] Figure 6 A network architecture diagram of a multi-scale feature fusion module of a tea disease detection model provided in an embodiment of the present invention;
[0061] Figure 7 An example of a plant leaf disease image provided by an embodiment of the present invention;
[0062] Figure 8An example diagram of diseased tea leaves provided by an embodiment of the present invention;
[0063] Fig. 9 A diagram showing the areas of interest of the tea disease detection model before and after improvement provided by an embodiment of the present invention;
[0064] Fig.10 A diagram showing the effect of detecting small-scale diseases provided by an embodiment of the present invention;
[0065] Fig.11 This is a diagram of the detection effect of different scale changes provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The following will be combined with the attached embodiment of the present invention Figure 1-Figure 11 , the technical solutions in the embodiments of the present invention are clearly and completely described. It should be understood that the terms described in the present invention are only used to describe specific implementation methods and are not used to limit the present invention.
[0067] Example
[0068] In order to cope with complex factors such as variable scales of tea diseases, dense diseases and occlusion, a tea disease detection method (Self-attention distillation network, SADN) with multi-scale self-attention feature fusion is provided in an embodiment of the present invention. The method uses a multi-scale feature extraction module based on ResNet to obtain local detail features of tea disease images at different scales, such as texture and edges, so as to effectively express multi-scale local features. A self-attention mechanism is introduced on the extracted feature map to enhance the model's ability to capture global dependencies and generalize the global and local information of tea disease images with stronger generalization capabilities, so as to form corresponding feature representations and obtain global and local feature maps of tea disease images. The multi-scale, global and local feature maps of tea disease images are fused, and adaptive weight parameters are assigned to feature maps of different scales to obtain the fused tea disease representation, detect tea diseases, and output tea disease detection results. The method improves the accuracy of tea disease detection. Experimental results show that the average detection accuracy of the tea disease detection method proposed by the present invention is significantly improved, and the accuracy is higher than that of the current mainstream target detection network. The method provides a theoretical basis for detecting tea diseases in tea gardens.
[0069] Specifically, the tea disease detection method proposed by the present invention is as follows: Figure 1 As shown, the method comprises the following steps:
[0070] S1: Acquire tea disease images to be detected;
[0071] S2: Build a network model. The network architecture of the network model is as follows Figure 2 As shown;
[0072] The network model includes a multi-scale feature extraction module that uses ResNet-50 as the backbone network and introduces the residual block of ResNet as the backbone of the backbone network to extract feature maps; a self-attention distillation module that introduces a self-attention mechanism on the extracted feature maps to obtain global and local feature maps; and a multi-scale feature adaptive fusion module that fuses the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module.
[0073] S3: training the network model to obtain a tea disease detection model;
[0074] S4: Input the tea disease image to be detected into the tea disease detection model, extract features of the tea disease image through the residual block of ResNet, and obtain a multi-scale feature map of the tea disease image; input the multi-scale feature map in parallel into the self-attention mechanism, and obtain the global and local feature maps of the tea disease image by capturing the global and local information of the tea disease image; fuse the multi-scale, global and local feature maps of the tea disease image to obtain the fused tea disease representation, detect the tea disease, and output the tea disease detection result.
[0075] The tea disease detection method proposed in the present invention improves the model's ability to characterize multi-scale features of diseases, allowing it to pay more attention to key features, thereby improving the accuracy of disease detection.
[0076] In step S2, the network architecture of the constructed network model combines the convolutional network and the self-attention mechanism, and also combines the distillation training strategy, such as Figure 2 The figure shows that it contains four key functional parts, namely the backbone network, the self-attention distillation module, the multi-scale feature adaptive fusion module and the detection network.
[0077] In the backbone network and self-attention distillation module, the fusion of convolutional network and self-attention mechanism is used to extract rich and diverse feature information. The specific steps are as follows:
[0078] ResNet50 is used as the main network, and the residual block of ResNet is introduced as the backbone of the network to extract features of tea disease images. These residual blocks obtain multi-scale feature maps of tea disease images by capturing tea disease information of different scales and local ranges. A self-attention mechanism is introduced on the extracted feature map, and the multi-scale feature maps of tea disease images are input into the self-attention mechanism in parallel to realize the multi-scale input of the self-attention mechanism. By capturing the global and local information of tea disease images, the global and local information are interacted.
[0079] The self-attention distillation module introduces the self-attention mechanism on the extracted feature map, and inputs the multi-scale feature maps of the tea disease image into the self-attention mechanism in parallel, realizing the multi-scale input of the self-attention mechanism, and interacting the global and local information by capturing the global and local information of the tea disease image. Secondly, by using the training strategy of knowledge distillation, the detection model can better capture the characteristics of tea diseases and have better generalization ability and flexibility.
[0080] The multi-scale feature adaptive fusion module fuses the multi-scale, global and local feature maps of the acquired tea disease images to provide a more comprehensive and accurate tea disease representation.
[0081] The detection network predicts the classification or regression task of the fused tea disease representation.
[0082] Through the combination and synergy of the above four key functional parts, the tea disease detection model obtained can effectively deal with the problems of variable scales of tea diseases and small data sets. By introducing the residual block of ResNet in the ResNet-50 backbone network as the backbone of the backbone network, rich tea disease feature information of different scales can be extracted. The self-attention distillation module obtains global and local feature maps by introducing the self-attention mechanism on the extracted feature maps, realizes the interaction of global and local information, and utilizes the knowledge of the teacher model. The multi-scale feature adaptive fusion module fuses the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module, so that the model can capture more feature information. The detection network is used for the final classification or regression prediction. This self-attention distillation method can improve the robustness and generalization ability of the model, so as to better adapt to the complexity and variability of tea diseases.
[0083] The ResNet-50 backbone network of the tea disease detection model of the present invention introduces the residual block of ResNet as the basic structure. ResNet is a deep convolutional neural network that solves the gradient vanishing problem in deep networks by introducing residual connections. This design enables the network to train a deeper model without sacrificing performance or causing gradient attenuation during propagation.
[0084] Specifically, the present invention uses ResNet-50 as the basic architecture of the backbone network. The backbone network structure diagram is as follows: Figure 3 As shown in the figure, ResNet-50 consists of 50 layers, each of which contains multiple convolutional layers and a skip connection shortcut connection. These convolutional layers are used to extract features of different scales of the image, while the skip connection directly transfers the input features to the output features, avoiding the gradient vanishing problem.
[0085] In the tea disease detection task, the backbone network can effectively capture tea disease information of different scales and local ranges. Since the manifestations of tea diseases at different levels may be different, the multi-scale feature extraction module in the network model constructed by the present invention uses the backbone network of ResNet-50 to extract rich tea disease feature information from feature maps of different scales. In addition, the backbone network of ResNet-50 also has good translation invariance, that is, when cropped or scaled at different positions, the network can still maintain good performance.
[0086] In summary, the ResNet-50 used in the present invention as the backbone network can effectively extract the feature information of tea disease images and has good translation invariance, providing a good input basis for the subsequent self-attention distillation and feature fusion modules.
[0087] The present invention also uses the idea of knowledge distillation of self-attention to construct the self-attention distillation module, which is used to realize the multi-scale input of the self-attention mechanism, the interaction of global and local information, and the use of prior knowledge of the teacher model. Specifically, the self-attention distillation module inputs feature maps of different scales into the self-attention mechanism in parallel to capture the global and local information of the tea disease image. At the same time, the self-attention distillation module uses the training strategy of knowledge distillation to improve the ability of the detection model.
[0088] In the self-attention distillation module, multiple branches need to be constructed to extract multi-scale feature maps. Each branch is responsible for processing feature maps at a specific scale. Figure 2 As shown in the figure, the self-attention distillation module sets up three branches to process high-resolution, medium-resolution and low-resolution feature maps respectively. The self-attention mechanism is introduced on the feature map to realize the interaction of global and local information. The self-attention mechanism can learn the important features in the feature maps of different scales and integrate them to form a global representation of the entire image. At the same time, the self-attention mechanism can also learn the detailed information in the feature maps of different scales through the training strategy of knowledge distillation, and combine it with the global representation to form an accurate representation of the local area. In this way, the self-attention distillation module can better capture the characteristics of tea disease images and improve the performance of the detection model.
[0089] In order to further improve the generalization ability of the detection model, the knowledge of the teacher model is introduced into the self-attention distillation module. The teacher model is usually a high-quality model that has been trained with a large amount of annotations and can provide rich knowledge and high-level feature representation. The network architecture of the self-attention distillation module is shown in the figure below. Figure 4As shown, Transformer is the student model, and the teacher model is composed of a pre-trained model DT-base, which is trained on the ImageNet and Plant Village datasets. The Transformer of the present invention is based on the Vision Transformer architecture, and when training the student model, the knowledge of the teacher model is learned through the distillation loss function.
[0090] By transferring the knowledge of the teacher model to the student model, the student model can learn more features and high-level representations, thereby improving its performance and robustness. Figure 5 As shown, the feature-based distillation loss can be expressed as follows
[0091] L FeaD (f T (x),f S (x)) = L F (Φ T (f T (x)),Φ S (f S (x)))
[0092] Among them, f T (x) and f S (x) represents the intermediate layer feature map of the teacher network and the student network respectively; Φ T (f T (x)) and Φ S (f S (x)) represent the transformation functions used when the intermediate layer features of the teacher network and the student network are not of the same dimension; Represents the similarity function used to match the intermediate features of the teacher network and the student network.
[0093] In summary, the self-attention distillation module is a key component of the tea disease detection model constructed by the present invention. By inputting feature maps of different scales in parallel and applying the self-attention mechanism and knowledge distillation strategy, the self-attention distillation module can effectively utilize a small amount of data samples and enhance the network's ability to recognize features of different scales, thereby improving the performance and generalization ability of the detection model.
[0094] The multi-scale feature adaptive fusion module fuses the multi-scale, global and local feature maps of the acquired tea disease images to obtain a more comprehensive and accurate representation of tea diseases.
[0095] In this fusion module, it is necessary to extract and fuse the features of different scales and branches from the multi-scale, global and local feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module. These features can include feature maps of different resolutions and feature representations from different branches. By combining and weighting these features and assigning adaptive weight parameters to feature maps of different scales through the multi-scale feature adaptive fusion module, the fused tea disease representation can be obtained. The fused tea disease representation is used as the input for positioning and classification of the detection network.
[0096] The network architecture of the multi-scale feature adaptive fusion module is as follows: Figure 6 As shown in the figure, the multi-scale feature adaptive fusion module consists of Concat, Upsample, Conv, (CBSBottleneckwith3convolutions, C3) modules and adaptive feature fusion module (Adaptivefeaturefusion, AFF).
[0097] Through the multi-scale feature adaptive fusion module, adaptive weight parameters are assigned to feature maps of different scales, and AFF achieves the functions of efficient fusion and automatic learning to filter out useless information. At the same time, its fusion process is differentiable, and weights can be learned and updated through back propagation, which has the advantages of simple implementation and small amount of calculation.
[0098] like Figure 6 The specific process shown is: the three C3 modules in the middle column output feature layers of three different scales, and AFF1, AFF2 and AFF3 are obtained through feature fusion of the multi-scale feature adaptive fusion module.
[0099] Taking AFF3 as an example, the features of the three layers are transformed, multiplied by the corresponding weight coefficients and added together to obtain the new fused feature map AFF3. The calculation formula is as follows:
[0100] AFF3=X 1→3 ×α 3 +X 2→3 ×β 3 +X 3→3 ×γ 3
[0101] Among them, X 1→3 The top C3 output feature layer is transformed to the same size as the bottom C3 output feature layer by adjusting the number of channels and scaling the size; X 2→3 and X 3→3 For X 1→3 The same operation; α, β and γ are the respective weight coefficients, which are obtained through back propagation during training.
[0102] The tea disease detection model constructed by the present invention simultaneously locates and classifies the acquired tea disease images through a loss function, and the calculation formula of the loss function is:
[0103] L=L loc +L conf +L cls
[0104] Among them, L loc represents the positioning loss, L cls represents the classification loss, L conf Represents the confidence loss.
[0105] The positioning loss uses CIoU loss, which takes into account the area of the overlapping area, the center distance of the bounding box, and the consistency of the aspect ratio of the bounding box.
[0106] The calculation process of CIoU loss is:
[0107]
[0108]
[0109]
[0110] Where c is the diagonal distance between the predicted box and the minimum closure area of the real box, ρ is the Euclidean distance function, b and b gt are the center points of the predicted box and the real box, ν is the similarity of the aspect ratio, α is the weight coefficient, and w and h are the width and height of the predicted box, respectively.
[0111] Therefore, the localization loss L loc The calculation process is:
[0112]
[0113] Where i represents the row index of the image grid, j represents the column index of the image grid, is an indicator function indicating whether the jth bounding box of the i-th grid contains the target object; S 2 represents the scale of the image and B represents the number of bounding boxes.
[0114] Classification loss L cls The binary cross entropy loss function is used, and its calculation formula is:
[0115]
[0116] In the formula, c' is the currently recognized category, and classes is all the categories to be detected; and are the predicted probability and true probability that the target in the j-th anchor box of the i-th grid belongs to category c'.
[0117] Confidence loss L conf The calculation formula is:
[0118]
[0119] In the formula, Indicates whether the j-th anchor box of the i-th grid does not have an object. If there is no object, it is 1, otherwise it is 0; noobj is a constant coefficient used to balance the impact of positive and negative samples on the loss function; and are the confidence of the predicted box and the true value box respectively.
[0120] The present invention detects tea diseases through experiments, and the selected experimental data are the plant disease dataset of Plant Village and the dataset specially collected for tea diseases. Specifically, the plant disease dataset provided by Plant Village is a resource library containing a large number of plant leaf images, covering 54,305 leaf photos of 14 different plants, which represent 38 common plant diseases, some of which are as follows Figure 7 As shown, Figure 7 (a) in the figure represents apple black spot disease, (b) in the figure represents tomato scab disease, and (c) in the figure represents potato wilt disease. By using these data, the model can be further optimized.
[0121] The tea disease dataset used in the experimental data of this invention comes from the research group of Professor Jiang Zhaohui of Anhui Agricultural University. It contains 776 disease images with a resolution of 906×600, covering 6 common tea diseases: tea net cake disease, tea round red star disease, tea cloud leaf blight, tea cake disease, tea red rust algae disease, and tea algae spot disease. Some examples are as follows: Figure 8 As shown, Figure 8 Figure (a) shows tea net cake disease, Figure (b) shows tea round red star disease, Figure (c) shows tea cloud leaf blight disease, Figure (d) shows tea cake disease, Figure (e) shows tea red rust algae disease, and Figure (f) shows tea algae spot disease.
[0122] However, the original samples collected by the experimental data of the present invention do not provide the bounding box information of the tea disease target. In order to be applicable to the disease detection task, the present invention uses the labelimg image annotation tool to have professionals annotate the bounding box of the tea disease target on each sample image as a training set to train the constructed network model. This process provides a standard data set for training and evaluating the tea disease detection model, so that the model can automatically identify and locate tea diseases.
[0123] At the same time, in order to solve the problem of class imbalance in image data sets, which may cause overfitting or underfitting of machine learning models during training, the present invention uses data enhancement technology to expand and diversify the original data set, which can effectively improve the generalization ability of the model for new data, thereby enhancing the overall robustness and prediction accuracy of the model. In this experimental process, the present invention used a variety of data enhancement methods, including rotation, adding noise and exposure, and by applying these methods, 7640 enhanced samples were generated.
[0124] In the experiment, the pixel ratios of the target mask relative to the image were counted and sorted. About 20% of the target scales were less than 0.0207, and 34% of the target scales were greater than 0.345, indicating that the scale span of the targets in the dataset is very large and there are significant differences.
[0125] The algorithm setting of the tea disease detection model was implemented based on Python 3.8, PyTorch 1.7.0, and CUDA 11.0 frameworks, and the training was performed on a server equipped with an RTX 3090 Ti GPU. The Adam optimizer was used, the BatchSize was set to 8, and 300 epochs were trained. When processing the enhanced samples, the data was divided into a training set and a validation set at a ratio of 8:2. This data division method helps to maintain data balance and evaluate model performance in the test phase to obtain more reliable results.
[0126] The present invention uses mean average precision (mAP) as the main evaluation index to evaluate the performance of the disease detection model. mAP measures the performance of the model by calculating the area under the precision-recall curve, comprehensively considering the detection accuracy of each category in the data set, and calculates the average precision AP of each category and takes the average value to obtain the final mAP. The calculation formula is as follows:
[0127]
[0128]
[0129] Among them, AP i represents the average accuracy of the i-th class, N represents the total number of categories, n and p(r) represent the category and the area under the precision-recall curve is integrated respectively.
[0130] The performance of the model is further analyzed using precision (P) and recall (R).
[0131] Precision refers to the ratio of the number of correctly detected target boxes to the number of all predicted target boxes, which reflects the accuracy of the model. The precision calculation formula is:
[0132]
[0133] The recall rate refers to the ratio of the number of correctly detected target boxes to the number of actual target boxes, which reflects the integrity of the model. The recall rate calculation formula is:
[0134]
[0135] In order to verify the effectiveness of the tea disease detection model proposed in the present invention, under the same experimental conditions, the tea disease detection model designed was compared with other traditional detection models using the tea disease image dataset obtained by the present invention. The comparison results are shown in Table 1.
[0136] Table 1 Comparative analysis of tea disease detection algorithms
[0137] method P(%) R(%) mAP(%) RetinaNet 89.16 90.44 89.82 YOLOv3-tiny 90.34 82.66 86.57 YOLOv4-tiny 95.13 90.59 92.82 SADN 92.23 94.76 94.72
[0138] From the comparison results in Table 1, it can be seen that the average precision of the tea disease detection model proposed in the present invention is 1.9 percentage points higher than that of YOLOv4-tiny, and the accuracy is 1.89 percentage points higher than that of YOLOv3-tiny. This is because the tea disease detection model of the present invention adopts a multi-scale feature adaptive fusion module to better handle the problem of variable scales of tea diseases.
[0139] In order to explore the self-attention mechanism introduced by the self-attention distillation module of the tea disease detection model proposed in the present invention on the extracted feature map, the global and local feature maps are obtained, and the changes in the tea disease detection model's attention area are visualized using heat map visualization technology to facilitate observation of the model's attention area. Fig. 9 As shown in the figure, it is the attention area diagram of the tea disease detection model before and after improvement. Fig. 9 The first column of pictures (a) is the original picture of tea diseases, the second column of pictures (b) is the first column of pictures (a) of the model before improvement is the visualization of tea diseases, and the third column of pictures (c) is the first column of pictures (a) of the model after improvement is the visualization of tea diseases. From the attention area diagrams in the visualization of tea diseases of the models before and after improvement, it can be seen that the darker the color, the more attention the model pays. Comparing the third column of pictures (c) with the second column of pictures (b), it can be seen that the visualization of the improved model pays more attention to the feature information of the target position, indicating that the self-attention distillation module of the present invention can make more full use of the contextual information in the picture, thereby improving the detection and understanding capabilities of objects.
[0140] In order to verify the effectiveness of the tea disease detection model proposed in the present invention, the present invention sets up an ablation experiment, uses ResNet as the backbone network, and gradually adds each network module to verify the rationality and effectiveness of the network structure. The comparison results of the ablation test performance indicators are shown in Table 2.
[0141] Table 2 Comparison of ablation test performance indicators
[0142] Self-Attention Distillation Module Multi-scale self-attention feature extraction module mAP(%) × × 93.22 √ × 93.53 × √ 93.96 √ √ 94.72
[0143] By analyzing the ablation test results in Table 2, it can be seen that the tea disease detection model improved by the self-attention distillation module improves the mAP by 0.31 percentage points. The knowledge of the teacher network is transferred to the student network based on the self-attention mechanism, which enables the tea disease detection model to better capture the characteristics of tea diseases and improve the detection accuracy.
[0144] The tea disease detection model improved by the multi-scale adaptive feature fusion module increased mAP by 0.74 percentage points. The multi-scale adaptive feature fusion module assigns adaptive weight parameters to feature maps of different scales to improve the accuracy of tea disease detection.
[0145] The tea disease detection model that uses the self-attention distillation module and the multi-scale adaptive feature fusion module has improved its mAP by 1.5 percentage points. The performance indicators have been significantly improved, thanks to the coordinated use of the two to achieve better performance improvement.
[0146] In order to evaluate the effect of the tea disease detection model proposed in the present invention on detecting tea diseases, the trained tea disease detection model was verified for detection accuracy using a test set. Fig.10 The following is a diagram showing the detection effect of small-scale diseases.
[0147] from Fig.10 It can be seen that each tea disease can be accurately detected, among which the probability of tea cake disease (TCD) is above 0.80, indicating that the model can effectively detect tea cake disease with high confidence. This is due to the self-attention distillation module using the rich knowledge of the teacher model to capture the global dependency between pixels in the tea image, realize the effective interaction between global and local features, and improve the accuracy of detection.
[0148] also, Fig.11 The detection effect diagram of different scale changes. TCRS in the figure represents tea red rust algae disease, LBOTM represents tea leaf blight disease, Fig.11 The right image shows the coexistence of diseases of various scales, indicating that the tea disease detection model proposed in the present invention can achieve effective detection.
[0149] In order to improve the model performance under the condition of limited data samples and solve the multi-scale problem in the tea disease detection task, the present invention proposes a tea disease detection method, which introduces a self-attention distillation module and a self-attention mechanism to enhance the model's ability to capture global dependencies and generalize features with stronger capabilities. Experimental comparison with the classic target detection method shows that the tea disease detection model proposed in the present invention has high accuracy. Therefore, by using this model, tea farmers can detect and identify tea diseases more accurately, so as to take necessary control measures in time to protect the health of the tea garden, which will help improve the quality and yield of tea.
[0150] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
[0151] In addition, unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as commonly understood by those skilled in the art to which the present invention belongs. All documents mentioned in this specification are incorporated by reference to disclose and describe the methods related to the documents. In the event of any conflict with any incorporated document, the content of this specification shall prevail.
Claims
1. A method for detecting tea diseases, characterized in that: The following steps are involved: Acquire tea disease images to be detected; Construct a network model; the network model includes a multi-scale feature extraction module that uses ResNet-50 as a backbone network and introduces a residual block of ResNet as the backbone of the backbone network to extract feature maps; a self-attention distillation module that is used to introduce a self-attention mechanism on the extracted feature maps to obtain global and local feature maps; Multi-scale feature adaptive fusion module, used to fuse the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module; Train the network model to obtain a tea disease detection model; The tea disease image to be detected is input into the tea disease detection model, and the feature of the tea disease image is extracted through the residual block of ResNet to obtain a multi-scale feature map of the tea disease image; the multi-scale feature map is input into the self-attention mechanism in parallel, and the global and local feature maps of the tea disease image are obtained by capturing the global and local information of the tea disease image; the multi-scale, global and local feature maps of the tea disease image are fused to obtain the fused tea disease representation, the tea disease is detected, and the tea disease detection result is output.
2. The tea disease detection method according to claim 1, characterized in that: The method of obtaining a multi-scale feature map of a tea disease image comprises the following steps: The backbone network ResNet-50 introduces the residual block of ResNet as the backbone infrastructure of the backbone network. ResNet is a deep convolutional neural network. The residual connection of the residual block of ResNet is introduced to solve the gradient disappearance problem in the deep network. Each residual block of ResNet-50 contains multiple convolutional layers and a skip connection to capture multi-scale and local range tea disease information; feature maps of different scales of tea disease images are extracted through the convolutional layers, and the feature maps of different scales of the input tea disease images are directly transferred to the output feature maps through the skip connection.
3. The tea disease detection method according to claim 2, characterized in that: The step of obtaining global and local feature maps comprises the following steps: Construct multiple branches to extract multi-scale feature maps, each branch is responsible for processing feature maps at a specific scale; A self-attention mechanism is introduced on the extracted multi-scale feature map, and the captured multi-scale and local range tea disease information is input into the self-attention mechanism in parallel; The self-attention mechanism uses the knowledge distillation training strategy to learn the detail information in the feature maps of different scales, and combines the detail information with the global representation to obtain the global and local feature maps, forming the representation of the global and local regions. Among them, the training strategy of knowledge distillation uses the knowledge of the student model and the teacher model. Based on the VisionTransformer architecture, when training the student model, the knowledge of the teacher model is learned through the distillation loss function; By transferring the knowledge of the teacher model to the student model, the student model learns more features and representations.
4. The tea disease detection method according to claim 3, characterized in that: The method of fusing the multi-scale, global and local feature maps of the tea disease image comprises the following steps: According to the multi-scale feature map of the tea disease image and the global and local feature maps of the leaf disease image, the features of different scales and branches of the tea disease image are extracted, including feature maps of different resolutions and feature representations of different branches; The features of different scales and branches of the extracted tea disease images are combined and weighted. Through the multi-scale feature adaptive fusion module, adaptive weight parameters are assigned to the feature maps of different scales to obtain the fused tea disease representation.
5. The tea disease detection method according to claim 4, characterized in that: The network architecture of the multi-scale feature adaptive fusion module specifically includes: The multi-scale feature adaptive fusion module includes Concat, Upsample, Conv, CBS Bottleneck with 3 convolutions modules and an adaptive feature fusion module AFF, wherein: Through the multi-scale feature adaptive fusion module, adaptive weight parameters are assigned to feature maps of different scales; The adaptive feature fusion module is used to fuse and automatically learn to filter out useless information, and the fusion process is differentiable, and the weights are learned and updated through back propagation; The three CSP Bottleneck with 3 convolutions modules in the middle column output three feature layers of different scales, which are fused to obtain the adaptive feature fusion modules AFF1, AFF2 and AFF3. The features of the three layers corresponding to AFF1, AFF2 and AFF3 are transformed, multiplied by the corresponding weight coefficients and added to obtain the new fused feature maps AFF1, AFF2 and AFF3.
6. The tea disease detection method according to claim 5, characterized in that: The method of outputting the tea disease detection result comprises the following steps: The fused tea disease representation is used as the input of the classification and regression tasks in the tea disease detection process; Tea disease detection includes the location and classification of tea diseases. By introducing the loss function, the accuracy of the tea disease detection process for target location and category detection is evaluated.
7. The tea disease detection method according to claim 6, characterized in that: The calculation formula of the loss function is: L=L loc +L conf +L cls Where, L loc represents the positioning loss, L cls represents the classification loss, L conf represents the confidence loss; Among them, the positioning loss adopts CIoU loss, while considering the area of the overlapping area, the center distance of the bounding box, and the consistency of the aspect ratio of the bounding box; the calculation process of CIoU loss is: Where c is the diagonal distance between the predicted box and the minimum closure area of the real box, ρ is the Euclidean distance function, b and b gt are the center points of the predicted box and the true box, ν is the similarity of the aspect ratio, α is the weight coefficient, w and h are the width and height of the predicted box, respectively; That is, the positioning loss L loc The calculation process is: Where i represents the row index of the image grid, j represents the column index of the image grid, is an indicator function indicating whether the jth bounding box of the i-th grid contains the target object; S 2 represents the scale of the image, and B represents the number of bounding boxes; Classification loss L cls The binary cross entropy loss function is used, and the calculation formula is: In the formula, c' is the currently recognized category, and classes is all the categories to be detected; and are the predicted probability and true probability that the target in the j-th anchor box of the i-th grid belongs to category c'; Confidence loss L conf The calculation formula is: In the formula, Indicates whether the j-th anchor box of the i-th grid does not have an object, if not, it is 1, otherwise, it is 0; noobj is a constant coefficient used to balance the impact of positive and negative samples on the loss function; and are the confidence of the predicted box and the true value box respectively.
8. The method for detecting tea diseases according to claim 1, characterized in that: The tea disease images to be detected include tea disease information of tea net cake disease, tea round red star disease, tea cloud leaf blight disease, tea cake disease, tea red rust algae disease and tea algae spot disease.
9. The tea disease detection method according to claim 8, characterized in that: The training of the network model comprises the following steps: Use the labelimg image annotation tool to mark each sample image, annotate the bounding box of the tea disease target, and use the labeled sample images as training sets to train the tea disease detection model.
10. A tea disease detection system, characterized in that: include: A data acquisition module, used to acquire tea disease images to be detected; A tea disease detection model construction module is used to construct a network model; the network model includes a multi-scale feature extraction module that uses ResNet-50 as a backbone network and introduces a residual block of ResNet as the backbone of the backbone network to extract feature maps; a self-attention distillation module is used to introduce a self-attention mechanism on the extracted feature maps to obtain global and local feature maps; The multi-scale feature adaptive fusion module is used to fuse the feature maps extracted by the multi-scale feature extraction module and the self-attention distillation module; the network model is trained to obtain a model for tea disease detection; The tea disease detection module is used to input the tea disease image to be detected into the tea disease detection model, extract the features of the tea disease image through the residual block of ResNet, and obtain the multi-scale feature map of the tea disease image; input the multi-scale feature map in parallel into the self-attention mechanism, and obtain the global and local feature maps of the tea disease image by capturing the global and local information of the tea disease image; fuse the multi-scale, global and local feature maps of the tea disease image to obtain the fused tea disease representation, detect the tea disease, and output the tea disease detection result.
Citation Information
Cited By
Lightweight rice disease prediction method based on SCL-YOLOv8n
CN119625543A
Knowledge distillation-based tea processing state intelligent detection method and system
CN119888717A
Bitter gourd withering monitoring method based on image recognition
CN119963997A
Strip steel surface defect detection method and system based on feature extraction network
CN120298305A
Pavement disease identification decision method based on AI and related device
CN120374511A
