Tea disease detection method based on attention mechanism
By introducing the SE attention mechanism and coordinate attention mechanism in the tea disease detection model, the problem of insufficient feature representation ability and insufficient feature selection is solved, and the detection accuracy and efficiency are significantly improved.
Patent Information
- Application Number
- CN202411629725.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-15
AI Technical Summary
In the tea disease detection, the prior art problems of insufficient model feature representation ability, insufficient feature selection, and poor response ability to fine-grained features, resulting in low detection accuracy and efficiency.
The YOLOv5-SE model based on the attention mechanism is adopted. By replacing the C3 module in the YOLOv5 model with the SE attention mechanism, the weighted processing capability of each channel of the feature map is enhanced.
The feature representation ability and feature selection optimization degree of the tea disease detection model are improved, and the response ability to fine-grained features is enhanced, thereby improving detection accuracy and efficiency.
Smart Images

Figure CN119579527A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of computer vision and agricultural information technology, and specifically relates to a tea disease detection method based on an attention mechanism. Background Art
[0002] Timely detection and identification of tea diseases is an important part of tea pest control, providing a basis for formulating reasonable prevention and control measures. Traditional tea disease identification methods mainly rely on manual observation and empirical judgment, with low accuracy and efficiency, and prone to misdiagnosis and missed diagnosis. Professional diagnosis can improve the accuracy of detection, but this increases production investment, and the limited number of professionals makes it impossible to reach all tea gardens for detection. With the development of automation technology, the method of detecting diseases through multi-sensor fusion has been applied in practice very early, and crop diseases and pests are detected through model establishment, information collection, feature extraction, information fusion and detection and discrimination. Drones are also frequently used in pest and disease monitoring. It provides efficient, accurate and comprehensive monitoring capabilities in crop disease monitoring. However, the images and information obtained by the above methods are still too complex, and there is still a distance to accurately and efficiently identify crop diseases and pests.
[0003] At present, with the development of computer vision and deep learning technology, using these technologies to detect and identify tea diseases has become a new trend. By using deep learning models, features can be automatically extracted from images of tea diseases, the diseases can be classified and located, and the accuracy and efficiency of detection and identification can be improved. Li Wujie et al. used an improved YOLOv5s model with a Van Block module to detect citrus diseases and pests. Compared with the original model, the detection accuracy was improved and the size of the model was well controlled. However, the sample size covered by the model was small, and diseases outside the sample still needed to be manually identified. Chen Yu et al. proposed an improved YOLOv5-CBM model based on YOLOv5s. This method not only improved the detection speed, but also optimized the model size and reduced the computer cost. It was optimized in terms of feature extraction, feature fusion and small target detection. However, the model still had shortcomings in terms of detection rate and real-time performance. Yang Xiaowei and others proposed a tea disease recognition system based on a convolutional neural network. The system can detect 18 kinds of diseases in tea images and can help tea farmers quickly identify tea diseases. However, it requires too much computing power from the equipment. The above deep learning model cannot accurately extract key information for detecting and identifying tea diseases and pests when faced with massive amounts of information, resulting in information overload that affects the accuracy and efficiency of recognition. In addition, due to the complex background of tea disease data, traditional CNN networks cannot efficiently identify them. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] Aiming at the above problems, the present invention proposes a tea disease detection method based on attention mechanism, which aims to solve technical problems such as insufficient model feature representation ability, insufficient feature selection optimization and weak response ability to fine-grained features, thereby improving the overall performance of the tea disease detection model.
[0006] (II) Technical solution
[0007] To achieve the above object, the first aspect of the present invention provides a tea disease detection method based on an attention mechanism, using a YOLOv5-SE model to detect tea diseases, and the construction method of the YOLOv5-SE model includes: replacing the C3 module in the YOLOv5 model with a seC3 module that integrates the SE attention mechanism; adding a coordinate attention mechanism at the end of the YOLOv5 model;
[0008] The SE attention mechanism includes the following steps:
[0009] Perform convolution calculation on the given feature map to form a feature map;
[0010] Perform global average pooling on the feature map to generate a feature vector;
[0011] The feature vector is processed through two fully connected layers and a nonlinear activation function to generate channel weight values;
[0012] Apply the channel weight value to each channel on the original feature map to perform feature weighting processing;
[0013] The detection method comprises:
[0014] Collect tea disease image data, and pre-process the collected tea disease image data;
[0015] Use annotation tools to calibrate the diseased area of the preprocessed tea disease image data to generate an annotation data set;
[0016] The constructed YOLOv5-SE model is trained using the labeled data set to obtain the trained model weights;
[0017] The trained YOLOv5-SE model was applied to unlabeled tea disease images for disease detection and identification.
[0018] Furthermore, the convolution calculation is performed on the given feature map, and the calculation formula of the feature map is:
[0019]
[0020] In the formula, * represents the convolution operation, U c Given a feature map X, through convolution Frt And the feature map obtained by global average pooling; V c represents a single filter used in the convolution operation; V represents a filter collection; X c Represents a channel of the original input feature map; s and c′ represent the range mark of the summary operation, indicating the summation range;
[0021] Perform global average pooling on the output feature map to generate a feature vector:
[0022]
[0023] In the formula, Z c represents the feature vector obtained after global average pooling; F sq Represents the convolution operation; H and W are the height and width of the feature map; U(i,j) represents the feature map U c The pixel value at position (i, j) in ;
[0024] The feature vector is processed by two fully connected layers and a nonlinear activation function to generate the channel weight value:
[0025] s=F ex (z,W)=σ(g(z,W))=σW2δ(W1z);
[0026] Where s represents the channel weight value obtained by processing the feature vector Z by two fully connected layers W1 and W2 and the activation function; z is the feature vector Z obtained c ;δ represents the activation function Relu;σ represents the activation function Sigmoid;F ex Represents the convolution operation;
[0027] The channel weight value is applied to each channel on the original feature map, and the calculation formula for feature weighting processing is as follows:
[0028] X~ c =F scale (U c ,s c )=s c U c ;
[0029] In the formula, X~ c is the obtained feature atlas; F scale is the convolution operation; s c is the calculated weight vector.
[0030] Furthermore, the steps of integrating the SE module into the specific layer of YOLOv5 include:
[0031] Provide an object detection model using SE attention mechanism, including a backbone network, a neck network and a head network;
[0032] Select at least one convolutional layer in the backbone network, which is used for feature extraction;
[0033] A SE module is integrated after the selected convolutional layer, and the SE module includes a squeezing step and an excitation step;
[0034] Perform the squeezing step to compress the feature map output by the convolutional layer through global average pooling to form a global feature descriptor;
[0035] Perform the excitation step, process the global feature descriptor using two fully connected layers to generate weights for each channel;
[0036] Apply the generated weights to the feature map output by the convolutional layer to adjust the feature response of each channel to form a weighted feature map;
[0037] The weighted feature map is passed to the neck network for feature fusion and scale adjustment;
[0038] The feature map after feature fusion and scale adjustment is output to the head network for target detection and classification.
[0039] Furthermore, the detection method further includes adding a multi-scale feature fusion module between the backbone network and the neck network of the YOLOv5 model; the multi-scale feature fusion module includes the following steps:
[0040] Upsample and downsample feature maps of different scales to generate feature maps of the same scale;
[0041] Add the feature maps of the same scale element by element to form a fused feature map;
[0042] Perform convolution operation on the fused feature map to generate a new feature map.
[0043] Furthermore, the steps of upsampling feature maps of different scales include:
[0044] Get the original feature map from the input feature map;
[0045] The original feature map is enlarged by bilinear interpolation to generate a feature map with the same scale as the target;
[0046] Perform convolution calculation on the enlarged feature map to generate a new feature map;
[0047] The steps of downsampling feature maps of different scales include:
[0048] Get the original feature map from the input feature map;
[0049] The original feature map is reduced by the average pooling operation to generate a feature map with the same scale as the target;
[0050] Perform convolution calculation on the reduced feature map to generate a new feature map.
[0051] Furthermore, in the process of model evaluation, four indicators, namely precision, recall, F1 score and average precision mean, are used to evaluate the model effect.
[0052] Furthermore, the dataset includes 6558 images, including eight different types of tea diseases: diseased leaves eaten by tea mosquitoes, diseased leaves eaten by red spiders, tea black sooty disease, tea rust, tea white star disease, algae leaf spot disease, gray blight and brown blight.
[0053] Furthermore, the acquired images are preprocessed, including cropping, rotating, stretching, and adjusting contrast and brightness.
[0054] Furthermore, the preprocessed images were calibrated using annotation tools and divided into training set, validation set and test set in a ratio of 6:3:1.
[0055] Furthermore, the training process of the YOLOv5-SE model includes training the data set using the initial training weights, and the number of iterative training times reaches 150 times, so that the training accuracy of the model reaches 90.4%, the recall rate reaches 92.1%, and the average precision means reaches 87.6%.
[0056] (III) Beneficial effects
[0057] Compared with the prior art, the present invention provides a tea disease detection method based on an attention mechanism, which introduces the SE (Squeeze-and-Excitation) attention mechanism to perform weighted processing on each channel of the feature map, so as to enhance important features and suppress unimportant features. This processing helps the model to better capture and represent the key features in the tea disease image, thereby improving the accuracy and reliability of disease detection; the SE attention mechanism generates a global feature vector through global average pooling, and then generates channel weight values through two fully connected layers and a nonlinear excitation function. This process can effectively select the feature channels that are most useful for disease detection, thereby optimizing the feature selection ability of the model and improving the robustness of the model in complex backgrounds; by weighted processing of the feature map, the model can dynamically adjust the degree of response to different features, so that the disease area and category can be more accurately identified in tea disease detection. This dynamic weighting method can significantly improve the model's ability to capture fine-grained features, thereby improving detection performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 This is a structural diagram of the SE attention mechanism disclosed in this application.
[0059] Figure 2 This is a SE attention mechanism process disclosed in this application.
[0060] Figure 3 This is a YOLOv5-SE structure diagram disclosed in this application.
[0061] Figure 4 This is a distribution diagram of the number of disease images disclosed in this application.
[0062] Figure 5 This is a single sample example of a different disease image disclosed in this application.
[0063] Figure 6 This is a curve chart of the mean changes in accuracy, recall rate, F1 score and average accuracy of a training result disclosed in this application.
[0064] Figure 7 This is a loss change curve diagram disclosed in this application.
[0065] Figure 8 This is an average F1 change curve disclosed in this application.
[0066] Fig. 9 This is a PR curve diagram disclosed in this application. DETAILED DESCRIPTION
[0067] The present invention will be described in detail below in conjunction with the accompanying drawings, and the technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0068] The network structure of YOLOv5 mainly includes a backbone network and some detection heads. The backbone network uses the CSPDarknet structure based on the Darknet extractor. YOLOv5 uses an anchor-free detection method to reduce the visible frame and the amount of calculation, and its feature fusion mechanism allows it to adjust according to image features to better adapt to size changes. The main components of the YOLOv5 model include: background network (Backbone), neck network (Neck) and head network (Head).
[0069] Backbone: A pre-trained network used to extract rich feature representations for images. It helps reduce the spatial resolution of images and increase their feature (channel) resolution. YOLOv5 uses CSP-Darknet53 as its backbone network. CSP-Darknet53 is a convolutional network of Darknet53 that YOLOv3 uses as a backbone network, on which the Cross Stage Partial (CSP) network strategy is applied.
[0070] Neck network (Neck): used to extract feature pyramids. It helps the model generalize well to objects of different sizes and scales. The neck network of YOLOv5 combines the architectures of feature pyramid networks (FPNs) and pixel aggregation networks (PAN), essentially extending the concepts of feature pyramids and pixel aggregation.
[0071] Head network (Head): The head network is used to perform the operations in the final stage. It applies anchor boxes on the feature map and presents the final output: category, object score, and bounding box. YOLOv5 uses the same head network as YOLOv3 and YOLOv4. It consists of three convolutional layers that predict the position (x, y, height, width), score, and object category of the bounding box. There are four main versions of the YOLOv5 model: small (s), medium (m), large (l), and extra (x), with different sizes and performance indicators. The method of this embodiment is improved by YOLOv5s, which is more convenient and fast than other versions, and has real-time performance, which is convenient for future deployment on mobile devices such as mobile phones for detection.
[0072] In order to achieve more efficient and accurate tea disease location, this embodiment improves the backbone network of the YOLOv5 model and constructs the YOLOv5-SE model. First, all C3 modules in the backbone network are replaced with seC3 modules that integrate the SE attention mechanism, and then coordinate attention is added at the end. The improved structural model is as follows Figure 3 shown.
[0073] The attention mechanism imitates the attention characteristics of humans to achieve more efficient resource allocation. By introducing the attention mechanism, deep learning networks can focus on important information, which helps improve network performance and has been widely used in the field of computer vision. The SE attention mechanism is an attention mechanism introduced in convolutional neural networks (CNN) (see Figure 1 ). The SE module uses the weight matrix to assign different weights to channels at different positions in the image, thereby extracting important feature information.
[0074] The main operations of the SE module include squeeze and excitation. The squeeze operation compresses the feature map into a feature vector through global average pooling. The function of the excitation mechanism is to learn to generate a channel weight vector through two levels of fully connected layers and nonlinear excitation functions. This weight vector will be applied to each channel on the original feature map for feature weighting processing. The structure of the SE attention mechanism is detailed in Figure 2 , the flow chart is shown as Figure 3 The specific implementation steps are as follows:
[0075] 1) For a given feature map X (size is X×W×C), let it pass through the convolution operator F rt Perform global average pooling to form the feature map U:
[0076]
[0077] In the formula, * represents the convolution operation, U c Given a feature map X, through convolution F rt And the feature map obtained by global average pooling; V c represents a single filter used in the convolution operation; V represents a filter collection; X c represents a channel of the original input feature map; s and c′ represent the range markers of the summary operation, indicating the summation range.
[0078] 2) Further perform global average pooling on the feature map U to generate a 1×1×C feature vector Z c , to obtain a value with the global receptive field of channel C; it can be understood that the information of each channel is compressed into one value, so that the global information of the entire image can be extracted:
[0079]
[0080] In the formula, Z c represents the feature vector obtained after global average pooling; F sq Represents the convolution operation; H and W are the height and width of the feature map; U(i,j) represents the feature map U c The pixel value at position (i, j) in .
[0081] 3) The vector Z obtained in the previous step is processed through two fully connected layers W1 and W2 c Further processing is performed to obtain the required channel weight value s; specifically, U is first mapped to a low-dimensional space through the first fully connected layer W1, then activated by ReLU, and then mapped back to the original size through the second fully connected layer W2. This process generates a new channel weight vector s:
[0082] s=F ex (z,W)=σ(g(z,W))=σW2δ(W1z)
[0083] Where s represents the channel weight value obtained by processing the feature vector Z by two fully connected layers W1 and W2 and the activation function; z is the feature vector Z obtained c ;δ represents the activation function Relu;σ represents the activation function Sigmoid;F ex Represents a convolution operation.
[0084] 4) The weight vector s generated in the previous step is used to assign weights to the feature map U to obtain the required feature map, which has the same size as the feature map. In this way, by adjusting the importance of each channel, the key features are enhanced and the unimportant features are suppressed:
[0085] X~ c =F scale (U c ,s c )=s c U c
[0086] In the formula, X~ c is the obtained feature atlas; F scale is the convolution operation; s c is the calculated weight vector.
[0087] Through these improvements, the YOLOv5-SE model can perform tea disease detection tasks more effectively. The detection method includes:
[0088] Collect tea disease image data, and pre-process the collected tea disease image data;
[0089] Use annotation tools to calibrate the diseased area of the preprocessed tea disease image data to generate an annotation data set;
[0090] The constructed YOLOv5-SE model is trained using the labeled data set to obtain the trained model weights;
[0091] The trained YOLOv5-SE model was applied to unlabeled tea disease images for disease detection and identification.
[0092] In a preferred embodiment, the steps of integrating the SE module into a specific layer of YOLOv5 include:
[0093] This technical solution describes an object detection model using the SE attention mechanism, including a backbone network, a neck network, and a head network. First, at least one convolutional layer for feature extraction is selected in the backbone network, and the SE module is integrated thereafter. The SE module includes two steps: a squeezing step and an excitation step. The squeezing step compresses the feature map output by the convolutional layer through global average pooling to form a global feature descriptor; the excitation step processes the feature descriptor using two fully connected layers to generate weights for each channel. These weights are applied to the feature map output by the convolutional layer to adjust the feature response of each channel to form a weighted feature map. Then, the weighted feature map is passed to the neck network for feature fusion and scale adjustment, and finally the adjusted feature map is output to the head network for object detection and classification; the whole process enhances the model's attention to important features and improves the accuracy and efficiency of object detection.
[0094] In the tea disease detection method based on the attention mechanism, a multi-scale feature fusion module is added between the backbone network and the neck network of the YOLOv5 model to further improve the model's ability to detect disease features of different scales. Specifically, the module first upsamples and downsamples feature maps of different scales, adjusts feature maps of different scales to the same scale, so that features at different levels can be effectively fused; then, these feature maps of the same scale are added element by element to form a fused feature map, which enhances the diversity and robustness of feature representation; finally, a convolution operation is performed on the fused feature map to generate a new feature map, which helps to extract richer and more accurate features. This process enables the model to better capture and identify the multi-scale features of tea diseases, improving the accuracy and stability of detection.
[0095] The upsampling and downsampling process is as follows:
[0096] The upsampling step enlarges the original feature map through bilinear interpolation and generates a new feature map through convolution calculation, ensuring that the feature map retains important detail information and semantic features during the enlargement process; the downsampling step reduces the original feature map through average pooling operation and generates a new feature map through convolution calculation, ensuring that the feature map reduces information loss and extracts useful features during the reduction process. Through these specific steps, the multi-scale feature fusion module can effectively adjust feature maps of different scales to the same scale, thereby achieving effective fusion of multi-scale features, enhancing the model's ability to detect disease features of different scales, and improving the accuracy and robustness of detection.
[0097] The above solution can be explained through a specific example below:
[0098] Specifically, data can be collected through Google Image Search. For example, a total of 6558 pictures were found, including 8 diseases: Tea Mosquito bug infested leaf, Red Spider infested tea leaf, Black rot of tea, Leaf rust of tea, White spot of tea, algal leaf spot, grey blight, and brown blight. The specific distribution is shown in Figure 4 , a single sample example is shown in Figure 5 .
[0099] The images were preprocessed and cropped into 256×256 pixel images. Due to different disease development, inconsistent number of photos, and different shooting angles, in order to avoid overfitting or underfitting and improve the accuracy of model detection, the specific images were rotated, stretched, contrast increased, and brightness increased or decreased. The image diseases were calibrated using the labeling tool (LabelImg). The images were divided into training set, validation set, and test set in a ratio of 6:3:1.
[0100] The following is an example for analysis and statistics:
[0101] The experimental equipment uses a 64-bit Windows 11 operating system, equipped with an Intel Core i7-12700H processor, 16GB of RAM, and an RTX3060 graphics card with a memory capacity of 6GB. The model python version is 3.11, and the pytorch version is 2.2.1. According to the hardware conditions, the parameters are as follows Table 1:
[0102] Table 1 Model parameter settings
[0103]
[0104] After the model is established and run, the model is evaluated to measure the performance and effect of the model. According to the evaluation results, the model parameters can be optimized, the advantages and disadvantages of the model can be analyzed, and the advantages and disadvantages of different models can be compared. When evaluating the model, this article uses four indicators: precision, recall, F1 score, and mean average precision (mAP).
[0105] Precision: Also known as accuracy, it is used to predict the proportion of samples that are actually positive examples among samples that are positive examples. The calculation formula for precision is:
[0106]
[0107] Recall: Also known as recall rate or hit rate, it indicates the proportion of all positive samples that are correctly predicted, reflecting the detection coverage of the model for positive samples. The calculation formula of recall rate is:
[0108]
[0109] In the formula, TP is the number of positive samples predicted by the model as positive, FP is the number of negative samples predicted as positive, and FN is the number of positive samples predicted as negative.
[0110] F1 score: The F1 score is the harmonic mean of precision and recall. It takes into account both the model's prediction accuracy and coverage of positive examples. The F1 score ranges from 0 to 1. The higher the F1 score, the better the model classification. The calculation formula for the F1 score is:
[0111]
[0112] Mean Average Precision (mAP): is the average of the average precision (AP) of all categories. AP is the area under the PR curve. The PR curve is a curve of precision (Precision) and recall (Recall) calculated based on different thresholds. mAP reflects the detection performance and generalization ability of the model for different categories. The higher the mAP, the better the detection effect of the model. The calculation formula is as follows:
[0113]
[0114] Where ρ is used to calculate the area enclosed by the PR curve and the coordinate axis, ρ(r) is the accuracy function of the PR curve, and dr is the differential element of the PR curve.
[0115] Use YOLOv5 to initialize the training weights and train the data set. The results are as follows Figure 6 Indicates that the accuracy training performance is as follows Figure 6, where the mean average precision (mAP_)0.5 represents the mAP when the intersection over union (IoU) between the true bounding box and the predicted bounding box is 0.5. Observing the chart, when the number of iterations approaches 150, the curve gradually flattens out, showing no signs of overfitting or underfitting. In the end, the training accuracy of the model reached 90.4%. The recall rate was 92.1%, and the mAP_0.5 was 87.6%. Figure 7 The changing curves of training and validation losses are shown. The smaller the classification loss, the better the classification effect, and the smaller the confidence loss, the more accurate the target judgment ability.
[0116] It can be seen from the figure that after 150 rounds of training, the loss tends to be stable, and the loss is less than 0.05, indicating that the model has good classification and positioning capabilities. Figure 8 is the average F1 accuracy curve, which indicates the prediction accuracy and coverage of the model for positive examples. It can be seen from the table that the F1 accuracy tends to be stable after 200 rounds, and the final F1 accuracy is close to 0.9, indicating that the classification effect of the model is good. Fig. 9 This is the PR curve, from which we can see that the areas of the curves for different types of diseases are close to 1, indicating that the recognition effect of this model is good.
[0117] In order to further evaluate the effect of SE attention mechanism on improving model performance, a control experiment was conducted, and the experimental results are shown in Table 2. It can be concluded from the table that compared with other models, the YOLOv5-SE model has higher mAP, recall rate and precision than other models. It can be concluded that the YOLOv5-SE model has better effect, especially compared with the traditional CNN model.
[0118] Table 2 Comparison of the effects of different models
[0119]
[0120]
[0121] In order to solve the problem of difficulty in identifying tea diseases in complex backgrounds and low detection efficiency, a detection model based on SE attention mechanism to improve YOLOv5 is proposed. Experiments have shown that this model can effectively detect diseases. Adding SE attention mechanism to the backbone network can effectively suppress irrelevant information and improve recognition accuracy. A multi-scale feature fusion module is added between the backbone network and the neck network of the YOLOv5 model. Through upsampling and downsampling steps, feature maps of different scales are adjusted to the same scale, and convolution calculation and fusion are performed, which can improve the model's detection ability and overall detection accuracy for disease features of different scales. Compared with traditional neural models, the recognition accuracy has been greatly improved.
[0122] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present application is limited by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by the same unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0123] The above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person skilled in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. A tea disease detection method based on attention mechanism, using YOLOv5-SE model to detect tea diseases, characterized by: The method for constructing the YOLOv5-SE model includes: replacing the C3 module in the YOLOv5 model with the seC3 module that integrates the SE attention mechanism; adding a coordinate attention mechanism at the end of the YOLOv5 model; The SE attention mechanism includes the following steps: Perform convolution calculation on the given feature map to form a feature map; Perform global average pooling on the feature map to generate a feature vector; The feature vector is processed through two fully connected layers and a nonlinear activation function to generate channel weight values; Apply the channel weight value to each channel on the original feature map to perform feature weighting processing; The detection method comprises: Collect tea disease image data, and pre-process the collected tea disease image data; Use annotation tools to calibrate the diseased area of the preprocessed tea disease image data to generate an annotation data set; The constructed YOLOv5-SE model is trained using the labeled data set to obtain the trained model weights; The trained YOLOv5-SE model was applied to unlabeled tea disease images for disease detection and identification.
2. A tea disease detection method based on attention mechanism according to claim 1, characterized in that: The convolution calculation is performed on the given feature map, and the calculation formula for the feature map is: In the formula, * represents the convolution operation, U c Given a feature map X, through convolution F rt And the feature map obtained by global average pooling; V c represents a single filter used in the convolution operation; V represents a filter collection; X c Represents a channel of the original input feature map; s and c′ represent the range mark of the summary operation, indicating the summation range; Perform global average pooling on the output feature map to generate a feature vector: In the formula, Z c represents the feature vector obtained after global average pooling; F sq Represents the convolution operation; H and W are the height and width of the feature map; U(i,j) represents the feature map U c The pixel value at position (i, j) in ; The feature vector is processed by two fully connected layers and a nonlinear activation function to generate the channel weight value: s=F ex (z,W)=σ(g(z,W))=σW2δ(W1z); Where s represents the channel weight value obtained by processing the feature vector Z by two fully connected layers W1 and W2 and the activation function; z is the feature vector Z obtained c ;δ represents the activation function Relu;σ represents the activation function Sigmoid;F ex Represents the convolution operation; The channel weight value is applied to each channel on the original feature map, and the calculation formula for feature weighting processing is as follows: X~ c =F scale (U c ,s c )=s c U c ; In the formula, X~ c is the obtained feature atlas; F scale is the convolution operation; s c is the calculated weight vector.
3. The tea disease detection method based on attention mechanism according to claim 1, characterized in that: The steps to integrate the SE module into the specific layer of YOLOv5 include: Provide an object detection model using SE attention mechanism, including a backbone network, a neck network and a head network; Select at least one convolutional layer in the backbone network, which is used for feature extraction; A SE module is integrated after the selected convolutional layer, and the SE module includes a squeezing step and an excitation step; Perform the squeezing step to compress the feature map output by the convolutional layer through global average pooling to form a global feature descriptor; Perform the excitation step, process the global feature descriptor using two fully connected layers to generate weights for each channel; Apply the generated weights to the feature map output by the convolutional layer to adjust the feature response of each channel to form a weighted feature map; The weighted feature map is passed to the neck network for feature fusion and scale adjustment; The feature map after feature fusion and scale adjustment is output to the head network for target detection and classification.
4. The method for detecting tea diseases based on the attention mechanism according to claim 1, characterized in that: The detection method further includes adding a multi-scale feature fusion module between the backbone network and the neck network of the YOLOv5 model; the multi-scale feature fusion module includes the following steps: Upsample and downsample feature maps of different scales to generate feature maps of the same scale; Add the feature maps of the same scale element by element to form a fused feature map; Perform convolution operation on the fused feature map to generate a new feature map.
5. The method for detecting tea diseases based on the attention mechanism according to claim 4, characterized in that: The steps of upsampling feature maps of different scales include: Get the original feature map from the input feature map; The original feature map is enlarged by bilinear interpolation to generate a feature map with the same scale as the target; Perform convolution calculation on the enlarged feature map to generate a new feature map; The steps of downsampling feature maps of different scales include: Get the original feature map from the input feature map; The original feature map is reduced by the average pooling operation to generate a feature map with the same scale as the target; Perform convolution calculation on the reduced feature map to generate a new feature map.
6. The method for detecting tea diseases based on attention mechanism according to claim 1, characterized in that: During the model evaluation process, four indicators, namely precision, recall, F1 score and average precision, are used to evaluate the model effect.
7. The method for detecting tea diseases based on attention mechanism according to claim 1, characterized in that: The dataset includes 6558 images, covering eight different types of tea diseases: diseased leaves eaten by tea mosquitoes, diseased leaves eaten by red spiders, tea black sooty disease, tea rust, tea white star disease, algal leaf spot disease, gray blight and brown blight.
8. The method for detecting tea diseases based on attention mechanism according to claim 1, characterized in that: The acquired images are preprocessed, including cropping, rotating, stretching, and adjusting contrast and brightness.
9. The method for detecting tea diseases based on attention mechanism according to claim 1, characterized in that: The preprocessed images are calibrated using annotation tools and divided into training set, validation set and test set in a ratio of 6:3:
1.
10. The method for detecting tea diseases based on attention mechanism according to claim 1, characterized in that: The training process of the YOLOv5-SE model includes training the data set using the initial training weights, and the number of iterative training reaches 150 times, so that the training accuracy of the model reaches 90.4%, the recall rate reaches 92.1%, and the average precision means reaches 87.6%.
Citation Information
Patent Citations
SAR image aircraft target detection method based on improved YOLOv5
CN116630798A
Improved YOLOv7-based mango diseased leaf detection and identification method
CN117671500A
Cited By
Unmanned aerial vehicle part automatic identification method based on angular point detection
CN120976811A
An unmanned aerial vehicle part automatic identification method based on corner detection
CN120976811B
Wheat stripe rust grading identification method based on improved YOLOv11 and ConvNeXtV2 models
CN121236543A