Tea disease identification method based on improved YOLOv7

By improving the YOLOv7 network, combining MobileNeXt and the double-layer routing attention network, and using the SIoU loss function, the problem of low identification accuracy and large computational load of tea disease identification methods in complex scenarios has been solved, and efficient and accurate tea disease identification has been achieved. Identify.

CN118537642AInactive Publication Date: 2024-08-23YUNNAN AGRICULTURAL UNIVERSITY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410645101.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing tea disease identification methods have low identification accuracy, large amount of calculation, and slow response speed in complex scenarios, making it difficult to meet the needs for accurate identification of tea diseases.

Method used

Based on the improved YOLOv7 network, combined with the MobileNeXt network and the double-layer routing attention network, the SIoU loss function is used to train and optimize the tea disease recognition model, reduce the number of parameters, extract global and local features, and improve recognition efficiency and accuracy.

Benefits of technology

It significantly improves the accuracy and speed of tea disease identification, reduces the computational burden, and improves the model's generalization ability and recognition performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537642A
    Figure CN118537642A
Patent Text Reader

Abstract

The invention provides a tea disease identification method based on improved YOLOv7 in the technical field of tea disease identification, and the method comprises the steps: S1, obtaining a large number of tea image construction data sets under different illumination intensities and different weather conditions; s2, creating a YOLOv7 network based on the MobileNeXt network, creating a tea disease recognition model based on the YOLOv7 network and the double-layer routing attention network, and setting a loss function of the tea disease recognition model as an SIoU function; s3, dividing the data set into a training set, a verification set and a test set, training the tea disease recognition model based on the training set, continuously optimizing an SIoU function in the training process, verifying the trained tea disease recognition model based on the verification set, and testing the verified tea disease recognition model based on the test set; and S4, performing tea disease identification by using the tested tea disease identification model. The method has the advantages that the tea disease identification precision and speed are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of tea disease identification, and in particular to a tea disease identification method based on improved YOLOv7. Background Art

[0002] Tea cultivation requires specific climate and soil conditions, that is, only a part of the area is suitable for tea cultivation, and many planting areas are in a warm and humid environment for a long time, which provides the environment and conditions for the infection of tea diseases, presenting a wide variety of characteristics and difficult prevention and control, resulting in a decline in tea production and quality. In order to reduce tea losses, tea diseases need to be identified in a timely and accurate manner.

[0003] For the identification of tea diseases, traditional target detection algorithms mainly rely on analysis of features such as color and texture. They can only express shallow features but cannot effectively extract deep features. In complex scenarios, they have problems such as low robustness and poor generalization, making it difficult to meet the needs of accurate identification of tea diseases.

[0004] In recent years, neural network models have been widely used in crop disease identification. Yu Wensen et al. used the VGG-16 model to identify tea tree diseases in complex scenes through transfer learning and other methods, with an accuracy rate of 85.29%; Shen Jia et al. completed the recognition of tea tree disease images by optimizing parameters and improving the EfficientNet model, with an average accuracy value of 93.31%; Sun Daozong et al. proposed an improved YOLOv4 model that reduces the number of parameters of the MobileNetv2 and deep separable convolution model to identify tea diseases, with an average accuracy value of 93.85%; Qiu Jing et al. established a rice disease recognition model using a deep convolutional network to classify and identify common rice diseases, with an accuracy rate of over 90%; Wu et al. used the YOLOv7 network to detect the target of tea fruit in complex scenes, with an accuracy rate of 94.76%; Wang Zewei et al. replaced part of the ELAN layer with the C3 network layer, and added the SimAM attention mechanism to the Head layer to improve the classification ability of the network, with an average accuracy of 92%. Although the above method has acceptable recognition accuracy, it still has problems such as large amount of calculation, slow response speed, and difficulty in recognition under complex backgrounds.

[0005] Therefore, how to provide a tea disease recognition method based on improved YOLOv7 to improve the accuracy and speed of tea disease recognition has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] The technical problem to be solved by the present invention is to provide a tea disease identification method based on improved YOLOv7, so as to improve the accuracy and speed of tea disease identification.

[0007] The present invention is implemented as follows: a tea disease identification method based on improved YOLOv7 comprises the following steps:

[0008] Step S1, obtaining a large number of tea images under different light intensities and weather conditions, and constructing a data set after preprocessing each of the tea images;

[0009] Step S2, creating a YOLOv7 network based on the MobileNeXt network, creating a tea disease recognition model based on the YOLOv7 network and the double-layer routing attention network, and setting the loss function of the tea disease recognition model to the SIoU function;

[0010] Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, training the tea disease recognition model based on the training set, continuously optimizing the SIoU function during the training process, validating the trained tea disease recognition model based on the validation set, and testing the validated tea disease recognition model based on the test set;

[0011] Step S4: using the tested tea disease identification model to identify tea diseases.

[0012] Furthermore, in step S1, the data set is constructed after preprocessing each tea image as follows:

[0013] After grouping, disease marking and redundant image deletion of each tea image, data expansion operations are performed through brightness adjustment, contrast adjustment, random flipping and random rotation to complete the preprocessing of each tea image, and a data set is constructed based on the preprocessed tea images.

[0014] Furthermore, the disease marking of tea leaves images is specifically as follows:

[0015] LabelImg is used to annotate the disease location and disease type of tea images, and file datasets in xml and txt formats are generated based on the annotation results.

[0016] Furthermore, in step S2, the MobileNeXt network is composed of a 3*3 first convolutional layer, eight SandGlassBlock modules, an average pooling layer, and a 1*1 second convolutional layer arranged in sequence;

[0017] The first convolution layer is used to extract shallow features from the tea image; the SandGlass Block module is used to extract deep features from the tea image; the average pooling layer is used to compress the two-dimensional shallow features and deep features into one-dimensional features; the second convolution layer is used to fuse and output each one-dimensional feature.

[0018] Furthermore, the formula of the SandGlass Block module is:

[0019]

[0020] in, Represents deep features; φ 1,p and φ 2,p Both represent 1*1 convolutional layers; φ 1,d represents depth convolution; F represents input tensor; G represents output tensor; Represents an output module description expression.

[0021] Furthermore, the formula of the average pooling layer is:

[0022]

[0023] Among them, Y i,j Represents one-dimensional features; i∈[0,H'),j∈[0,W'), i represents the i-th row, j represents the j-th column, H' represents the true box height, W' represents the true box width, H represents height; W represents width, k represents the size of the pooling kernel, s represents the step size; pool() represents the average pooling function; x represents the tea image; m represents the variable in the pooling process; n represents the variable in the pooling process; X represents the data set, X∈R H*W , R represents a real number; X i*s+m,j*s+n Represents the value before average pooling.

[0024] Furthermore, in step S2, the two-layer routing attention network is used to extract global features and local features from the tea image, and the formula is:

[0025] O=Attention(Q,K g ,V g )+LCE(V);

[0026] K g =gather(K,I r );

[0027] V g =gather(V,I r );

[0028] I r=topkIndex(A r );

[0029] A r =Q r (K r ) T ;

[0030] Q=X r W q ;

[0031] K=X r W k ;

[0032] V=X r W v ;

[0033] Where O represents the output of the two-layer routing attention network; Attention() represents the attention function; LCE(V) represents the local context enhancement term; gather() represents aggregation; topkIndex() represents applying the top-k operation to each row to generate a routing index matrix to retain the top k connections between each region and other regions; X r W represents the tea sub-image obtained by dividing the tea image into S×S non-overlapping regions; q , W k , W v All represent linear matrices; Q, K, and V all represent embedded features obtained after linear mapping of the linear matrix; K g Indicates the key after aggregation; V g represents the aggregated value; K represents the embedded feature obtained after linear mapping of the linear matrix; I r A represents the routing index matrix; r represents the adjacency matrix; Q r represents the average value of each region of Q; K r represents the mean of each region of K; T represents the transpose.

[0034] Furthermore, in step S2, the formula of the SIoU function is:

[0035]

[0036]

[0037] Δ=∑ t=x,y (1-e -γpt );

[0038] Λ=1-2sin 2 (arcsin(x)-π / 4);

[0039] Among them, L SIoU Represents the loss value of the SIoU function; IoU represents the intersection over union ratio between the real box and the predicted box; Δ represents the distance loss considering the angle loss; Ω represents the shape loss; Λ represents the angle loss; t represents the variable; w represents the width of the predicted box; h represents the height of the predicted box; e represents the base of the natural logarithm; θ represents the Shape cost of each data; x represents the position; y represents the position; γ represents the distance value assigned to time; p represents the Euclidean distance between the predicted box and the real box.

[0040] Furthermore, step S3 is specifically as follows:

[0041] The data set is randomly divided into a training set, a validation set, and a test set based on a ratio of 6:2:2, and a tea disease recognition model is trained based on the training set. During the training process, the SIoU function is continuously optimized until a preset convergence condition is met;

[0042] The trained tea disease recognition model is verified based on the verification set, and the verified tea disease recognition model is tested based on the test set. If the test passes, the training of the tea disease recognition model is terminated; if the test fails, the training set is expanded to continue training the tea disease recognition model.

[0043] The advantages of the present invention are:

[0044] A large number of tea images under different light intensities and weather conditions are obtained and preprocessed to construct a data set; then a YOLOv7 network is created based on the MobileNeXt network, and a tea disease recognition model is created based on the YOLOv7 network and the double-layer routing attention network, and the loss function of the tea disease recognition model is set to the SIoU function; then the data set is divided into a training set, a validation set, and a test set based on a preset ratio, and the tea disease recognition model is trained based on the training set. The SIoU function is continuously optimized during the training process, and the trained tea disease recognition model is verified based on the validation set, and the verified tea is tested based on the test set. The tea disease recognition model was tested, and finally the tested tea disease recognition model was used to identify tea diseases; that is, the traditional YOLOv7 network was improved through the MobileNeXt network to reduce the number of parameters of the tea disease recognition model and realize the lightweight improvement of the tea disease recognition model. A double-layer routing attention network was introduced to extract global features and local features from tea images to enhance the recognition efficiency of tea diseases in complex environments. The loss function was replaced by the traditional CIoU function with the SIoU function to reduce the regression loss and improve the convergence speed of the tea disease recognition model, which ultimately greatly improved the accuracy and speed of tea disease recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0046] Figure 1 It is a flow chart of a tea disease identification method based on improved YOLOv7 of the present invention.

[0047] Figure 2 It is a structural schematic diagram of the tea disease identification model of the present invention.

[0048] Figure 3 This is the loss value curve of the training set before YOLOv7 improvement.

[0049] Figure 4 It is the loss value curve of the training set after YOLOv7 improvement.

[0050] Figure 5 This is the loss value curve of the validation set before YOLOv7 improvement.

[0051] Figure 6 It is the loss value curve of the validation set after YOLOv7 improvement.

[0052] Figure 7 It is a curve graph of P value, R value and mAP@0.5 of the tea disease recognition model of the present invention.

[0053] Figure 8 This is a comparison diagram of the P value before and after the improvement of YOLOv7.

[0054] Fig. 9 This is a comparison diagram of the R value before and after the improvement of YOLOv7.

[0055] Fig.10 This is a comparison diagram of mAP@0.5 before and after the improvement of YOLOv7. DETAILED DESCRIPTION

[0056] The technical solution in the embodiment of the present application has the following overall idea: a tea disease recognition model including a YOLOv7 network and a double-layer routing attention network is created for tea disease recognition. The YOLOv7 network is created based on the MobileNeXt network, that is, the traditional YOLOv7 network is improved through the MobileNeXt network to reduce the number of parameters of the tea disease recognition model and achieve lightweight improvement of the tea disease recognition model. A double-layer routing attention network is introduced to extract global features and local features from tea images to enhance the recognition efficiency of tea diseases in complex environments. The loss function is replaced by the traditional CIoU function with the SIoU function to reduce regression loss and improve the convergence speed of the tea disease recognition model, thereby improving the accuracy and speed of tea disease recognition.

[0057] Please refer to Figures 1 to 10 As shown, a preferred embodiment of the tea disease identification method based on improved YOLOv7 of the present invention comprises the following steps:

[0058] Step S1, obtaining a large number of tea images under different light intensities and weather conditions, and constructing a data set after preprocessing each of the tea images;

[0059] By acquiring the tea images under different light intensities and weather conditions, the richness and diversity of the data set are ensured;

[0060] Step S2, creating a YOLOv7 network based on the MobileNeXt network (inverted residual block), creating a tea disease recognition model based on the YOLOv7 network and the double-layer routing attention network, and setting the loss function of the tea disease recognition model to the SIoU function;

[0061] The backbone network of the YOLOv7 network is replaced with a lightweight MobileNeXt network to provide efficient feature extraction and processing capabilities, effectively reduce the computational burden, and improve the recognition speed; at the same time, the double-layer routing attention network is introduced to improve the ability of the tea disease recognition model to capture key details and textures in tea images, and further improve the performance and computational efficiency of the tea disease recognition model; in addition, the more applicable SIoU function is used as the loss function to reduce losses, missed judgments, and misjudgments, thereby showing better recognition effects under complex image backgrounds;

[0062] Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, training the tea disease recognition model based on the training set, continuously optimizing the SIoU function during the training process, validating the trained tea disease recognition model based on the validation set, and testing the validated tea disease recognition model based on the test set;

[0063] Step S4: using the tested tea disease identification model to identify tea diseases.

[0064] In step S1, the preprocessing of each tea leaf image to construct a data set is specifically as follows:

[0065] After grouping, disease marking and redundant image deletion of each tea image, data expansion operations are performed through brightness adjustment, contrast adjustment, random flipping and random rotation to complete the preprocessing of each tea image, and a data set is constructed based on the preprocessed tea images.

[0066] For example, the tea images are classified based on four diseases: sooty mold, anthracnose, ring spot, and leaf blight. The tea disease recognition model is trained by using a dataset constructed from the preprocessed tea images, which can effectively improve the generalization ability of the tea disease recognition model.

[0067] The specific steps of marking the tea leaf images for diseases are as follows:

[0068] LabelImg is used to annotate the disease location and disease type of tea images, and file datasets in xml and txt formats are generated based on the annotation results.

[0069] In step S2, the MobileNeXt network is composed of a 3*3 first convolutional layer, eight SandGlassBlock modules, an average pooling layer and a 1*1 second convolutional layer arranged in sequence;

[0070] The first convolutional layer is used to extract shallow features from the tea image; the SandGlassBlock module is used to extract deep features from the tea image; the average pooling layer is used to compress the two-dimensional shallow features and deep features into one-dimensional features; the second convolutional layer is used to fuse and output each one-dimensional feature.

[0071] The SandGlass Block module is an hourglass residual module. Its uniqueness lies in placing depth wise convolution at the beginning and end, aiming to retain the spatial depth convolution layer of the channel, and stacking pointwise convolution between two depth convolution layers to increase the number of channels, ensuring that the depth convolution is processed in high-dimensional space and obtains richer feature expressions. At the same time, larger channel tensors are operated by deep kernels, which helps to significantly reduce the number of parameters and achieve the purpose of lightweight. The SandGlass Block module not only retains the advantage of accelerated convergence of high-dimensional networks, but also makes full use of the computational advantages brought by deep separable convolution. The deep convolution layer is processed in high-dimensional space and obtains richer feature expressions, effectively reducing the memory access requirements of high-dimensional feature maps, thereby improving hardware execution efficiency; in addition, it ensures that more information is passed from the bottom layer to the upper layer, which helps gradient backpropagation, and encodes more spatial information by introducing two deep separable convolutions.

[0072] In convolutional neural networks, pooling layers are often used to reduce the dimensions of image features, thereby improving the accuracy and speed of classification, and can improve the training speed and generalization ability of the model. The average pooling layer is used to divide the input feature map (tea image) into several regions of equal size, downsample the input feature map, and take the average of the feature values ​​in each region as the output value of the region, thereby reducing the size of the feature map and the number of parameters, so that the size of the feature map can be reduced while retaining the main feature information.

[0073] The formula of the SandGlass Block module is:

[0074]

[0075] in, Represents deep features; φ 1,p and φ 2,p Both represent 1*1 convolutional layers; φ 1,d represents depth convolution; F represents input tensor; G represents output tensor; Represents an output module description expression.

[0076] The formula for the average pooling layer is:

[0077]

[0078] Among them, Y i,j Represents one-dimensional features; i∈[0,H'),j∈[0,W'), i represents the i-th row, j represents the j-th column, H' represents the true box height, W' represents the true box width, H represents height; W represents width, k represents the size of the pooling kernel, s represents the step size; pool() represents the average pooling function; x represents the tea image; m represents the variable in the pooling process; n represents the variable in the pooling process; X represents the data set, X∈R H*W , R represents a real number; X i*s+m,j*s+n Represents the value before average pooling.

[0079] In step S2, the two-layer routing attention network is used to extract global features and local features from the tea image, and the formula is:

[0080] O=Attention(Q,K g ,V g )+LCE(V);

[0081] K g =gather(K,I r );

[0082] V g =gather(V,Ir );

[0083] I r =topkIndex(A r );

[0084] A r =Q r (K r ) T ;

[0085] Q=X r W q ;

[0086] K=X r W k ;

[0087] V=X r W v ;

[0088] Where O represents the output of the two-layer routing attention network; Attention() represents the attention function; LCE(V) represents the local context enhancement term; gather() represents aggregation; topkIndex() represents applying the top-k operation to each row to generate a routing index matrix to retain the top k connections between each region and other regions; X r W represents the tea sub-image obtained by dividing the tea image into S×S non-overlapping regions; q , W k , W v All represent linear matrices; Q, K, and V all represent embedded features obtained after linear mapping of the linear matrix; K g Indicates the key after aggregation; V g represents the aggregated value; K represents the embedded feature obtained after linear mapping of the linear matrix; I r A represents the routing index matrix; r represents the adjacency matrix; Q r represents the average value of each region of Q; K r represents the mean of each region of K; T represents the transpose.

[0089] The two-layer routing attention network combines the self-attention mechanism of Transformer and the feature pyramid network of BiFPN (Bi-directional Feature Pyramid Network) to improve the target detection performance. It has the ability of bidirectional encoding. Its main advantage lies in the ability to consider global and local information at the same time. The core idea is to select relevant key-value pairs, selectively retain a small part of the routing area, retain fine-grained information, and at the same time reduce the amount of calculation. The first stage of BiFPN's BiFormer uses overlapping patch embedding, while the second to fourth stages increase the number of channels and use patch merging blocks to reduce the input spatial resolution, followed by feature transformation, thereby effectively reducing the amount of model calculation and improving the model operation speed.

[0090] In step S2, the formula of the SIoU function is:

[0091]

[0092]

[0093] Δ=∑ t=x,y (1-e -γpt );

[0094] Λ=1-2sin 2 (arcsin(x)-π / 4);

[0095] Among them, L SIoU Represents the loss value of the SIoU function; IoU represents the intersection over union ratio between the real box and the predicted box; Δ represents the distance loss considering the angle loss; Ω represents the shape loss; Λ represents the angle loss; t represents the variable; w represents the width of the predicted box; h represents the height of the predicted box; e represents the base of the natural logarithm; θ represents the Shape cost of each data; x represents the position; y represents the position; γ represents the distance value assigned to time; p represents the Euclidean distance between the predicted box and the real box.

[0096] Although the traditional CIoU function takes into account the intersection area, center point distance and aspect ratio of the bounding box, it does not consider the problem of mismatched angles between the predicted box and the real box. In order to better complete the detection task of tea diseases, the present invention replaces the CIoU function with the SIoU function to effectively improve the regression accuracy of the predicted box. In the SIoU function, targets of different clarity levels are treated equally, and on this basis, an angle loss is added. The predicted box is adjusted through the shortest regression path, aiming to provide a smoother IoU loss, which effectively solves the problem of gradient instability.

[0097] Step S3 is specifically as follows:

[0098] The data set is randomly divided into a training set, a validation set, and a test set based on a ratio of 6:2:2, and a tea disease recognition model is trained based on the training set. During the training process, the SIoU function is continuously optimized until a preset convergence condition is met;

[0099] The trained tea disease recognition model is verified based on the verification set, and the verified tea disease recognition model is tested based on the test set. If the test passes, the training of the tea disease recognition model is terminated; if the test fails, the training set is expanded to continue training the tea disease recognition model.

[0100] Precision, recall and mean Average Precision are used to evaluate the tea disease recognition model, where AP is the area under the recall and precision curves, and mAP is the average AP of each category, which can represent a comprehensive evaluation index. The specific formula is as follows:

[0101] P = TP / (TP+FP);

[0102] R = TP / (TP+FN);

[0103]

[0104] Among them, TP (True Positives) represents the number of samples correctly judged; FP (False Positives) represents the number of samples incorrectly judged; FN (False Negatives) represents the number of samples missed.

[0105] The loss function is not only an important indicator for measuring the difference between the model prediction results and the actual results, but also one of the key criteria for evaluating the quality of the model. A smaller loss value indicates that the model prediction results are closer to the actual results, thus showing a better performance of the model. The tea disease recognition model of the present invention is trained, and the total number of training iterations is 400. Figure 3-6As shown in the figure, it can be observed that in the initial stage of the tea disease recognition model training, the gradient descent rate of the loss value shows a faster decline trend compared with the original YOLOv7 model. At the same time, as the training progresses, after 150 rounds of training, the decline rate of the loss value slows down significantly. After 300 rounds, the loss value gradually tends to a stable trend, and the loss function begins to converge. The final results show that the overall loss value of the improved model is stable at around 2.8%, while the original YOLOv7 model is stable at around 3.9%, that is, the tea disease recognition model shows obvious superiority, and its loss value is significantly lower than the unimproved model, showing good performance.

[0106] In order to further evaluate the quality of the tea disease recognition model, three indicators, namely P value, R value and mAP@0.5, were selected to comprehensively consider the classification performance of different categories of targets. AP (Average Precision) refers to the average accuracy of a certain category under different IoU thresholds. It comprehensively evaluates the location accuracy and prediction accuracy of the model. The value of AP depends on the accuracy and recall rate of the model. It is actually the area under the PR curve (Precision-Recall Curve) of a specific category, where the horizontal axis is the recall rate and the vertical axis is the precision rate; mAP is the average value of AP of each category. mAP@0.5 can evaluate the average accuracy of the target detection algorithm when the IoU threshold is 0.5. As one of the important criteria for evaluating deep learning models, it is used to comprehensively evaluate the performance of the detection model. These three indicators play a key role in evaluating the quality of the model.

[0107] like Figure 7 As shown in the figure, the tea disease recognition model shows good learning ability and recognition accuracy. The P value, R value and mAP@0.5 indicators show a significant continuous growth trend. With the increase of model training rounds, they gradually stabilize and show a steady fluctuation state. According to the model training results, the tea disease recognition model shows good recognition effect and can accurately identify 4 different types of tea diseases.

[0108] like Figure 8 , 9 As shown in the figure, the P values ​​of the tea disease recognition model for the four disease identifications are improved by 16.2%, 3.7%, 0.8% and 7.8% respectively compared with the traditional YOLOv7 model. Only the recall rate of anthracnose is slightly lower than that of the traditional YOLOv7 model, and the recall rates of the other three disease types are increased by 21.4%, 7.6% and 8.7% respectively. The tea disease recognition model can detect more disease targets and locate and classify targets more accurately.

[0109] like Fig.10As shown in the figure, only the P value of shift disease is slightly lower than the traditional YOLOv7 model, and the P values ​​of other categories are improved by 13.83%, 4.9%, and 5.8% respectively. mAP represents the value obtained by summing and averaging the average precision of all categories. The tea disease recognition model has a higher accuracy in prediction and can better identify the type of disease. Only leaf blight is slightly lower than the traditional YOLOv7 model, and the other three diseases are improved by 11.71%, 3.9%, and 0.2% respectively. Therefore, the tea disease recognition model has better learning ability.

[0110] In order to further verify the competitive advantage of the tea disease recognition model of the present invention, the detection and recognition performance of different models were compared for tea sooty mold, anthracnose, ring spot and leaf blight. To ensure the reliability of the results, the original YOLOv7, YOLOv7-tiny, Faster R-CNN and SSD network models were trained and tested on the same data set, while ensuring the consistency of the training platform configuration. The comparison results are shown in the following table:

[0111] Evaluation Metrics mAP@0.5 Detection speed / FPS Model volume / MB Tea disease identification model 91.7 41.15 59.1 YOLOv7 84.1 37.03 74.8 YOLOv7-tiny 87.3 42.02 53.2 Faster R-CNN 81.6 7.34 99.6 SSD 90.4 17.42 83.7

[0112] In summary, the advantages of the present invention are:

[0113] A large number of tea images under different light intensities and weather conditions are obtained and preprocessed to construct a data set; then a YOLOv7 network is created based on the MobileNeXt network, and a tea disease recognition model is created based on the YOLOv7 network and the double-layer routing attention network, and the loss function of the tea disease recognition model is set to the SIoU function; then the data set is divided into a training set, a validation set, and a test set based on a preset ratio, and the tea disease recognition model is trained based on the training set. The SIoU function is continuously optimized during the training process, and the trained tea disease recognition model is verified based on the validation set, and the verified tea is tested based on the test set. The tea disease recognition model was tested, and finally the tested tea disease recognition model was used to identify tea diseases; that is, the traditional YOLOv7 network was improved through the MobileNeXt network to reduce the number of parameters of the tea disease recognition model and realize the lightweight improvement of the tea disease recognition model. A double-layer routing attention network was introduced to extract global features and local features from tea images to enhance the recognition efficiency of tea diseases in complex environments. The loss function was replaced by the traditional CIoU function with the SIoU function to reduce the regression loss and improve the convergence speed of the tea disease recognition model, which ultimately greatly improved the accuracy and speed of tea disease recognition.

[0114] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A tea disease identification method based on improved YOLOv7, characterized in that: The steps include: Step S1, obtaining a large number of tea images under different light intensities and weather conditions, and constructing a data set after preprocessing each of the tea images; Step S2, creating a YOLOv7 network based on the Mobi leNeXt network, creating a tea disease recognition model based on the YOLOv7 network and the double-layer routing attention network, and setting the loss function of the tea disease recognition model to the SIoU function; Step S3, dividing the data set into a training set, a validation set and a test set based on a preset ratio, training the tea disease recognition model based on the training set, continuously optimizing the SIoU function during the training process, validating the trained tea disease recognition model based on the validation set, and testing the validated tea disease recognition model based on the test set; Step S4: using the tested tea disease identification model to identify tea diseases.

2. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: In step S1, the preprocessing of each tea leaf image to construct a data set is specifically as follows: After grouping, disease marking and redundant image deletion of each tea image, data expansion operations are performed through brightness adjustment, contrast adjustment, random flipping and random rotation to complete the preprocessing of each tea image, and a data set is constructed based on the preprocessed tea images.

3. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: The specific steps of marking the tea leaf images for diseases are as follows: The disease location and disease type of the tea images are annotated through Label Img, and file datasets in xml and txt formats are generated based on the annotation results.

4. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: In step S2, the MobileNeXt network is composed of a 3*3 first convolutional layer, eight SandGlass Block modules, an average pooling layer and a 1*1 second convolutional layer arranged in sequence; The first convolution layer is used to extract shallow features from the tea image; the SandGlass Block module is used to extract deep features from the tea image; the average pooling layer is used to compress the two-dimensional shallow features and deep features into one-dimensional features; the second convolution layer is used to fuse and output each one-dimensional feature.

5. The tea disease identification method based on improved YOLOv7 according to claim 4, characterized in that: The formula of the SandGlass Block module is: in, Represents deep features; φ 1,p and φ 2,p Both represent 1*1 convolutional layers; φ 1,d represents depth convolution; F represents input tensor; G represents output tensor; Represents an output module description expression.

6. The tea disease identification method based on improved YOLOv7 according to claim 4, characterized in that: The formula for the average pooling layer is: Among them, Y i,j Represents one-dimensional features; i∈[0,H'),j∈[0,W'), i represents the i-th row, j represents the j-th column, H' represents the true box height, W' represents the true box width, H represents height; W represents width, k represents the size of the pooling kernel, s represents the step size; pool() represents the average pooling function; x represents the tea image; m represents the variable in the pooling process; n represents the variable in the pooling process; X represents the data set, X∈R H*W , R represents a real number; X i*s+m,j*s+n Represents the value before average pooling.

7. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: In step S2, the two-layer routing attention network is used to extract global features and local features from the tea image, and the formula is: O=Attention(Q,K g ,V g )+LCE(V); K g =gather(K,I r ); V g =gather(V,I r ); I r =topkIndex(A r ); A r =Q r (K r ) T ; Q=X r W q ; K=X r W k ; V=X r W v ; Where O represents the output of the two-layer routing attention network; Attention() represents the attention function; LCE(V) represents the local context enhancement term; gather() represents aggregation; topkIndex() represents applying the top-k operation to each row to generate a routing index matrix to retain the top k connections between each region and other regions; X r W represents the tea sub-image obtained by dividing the tea image into S×S non-overlapping regions; q , W k , W v All represent linear matrices; Q, K, and V all represent embedded features obtained after linear mapping of the linear matrix; K g Indicates the key after aggregation; V g represents the aggregated value; K represents the embedded feature obtained after linear mapping of the linear matrix; I r A represents the routing index matrix; r represents the adjacency matrix; Q r represents the average value of each region of Q; K r represents the mean of each region of K; T represents the transpose.

8. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: In step S2, the formula of the SIoU function is: Δ=∑ t=x,y (1-e -γpt ); L=1-2sin 2 (arcsin(x)-π / 4); Among them, L SIoU Represents the loss value of the SIoU function; IoU represents the intersection over union ratio between the real box and the predicted box; Δ represents the distance loss considering the angle loss; Ω represents the shape loss; Λ represents the angle loss; t represents the variable; w represents the width of the predicted box; h represents the height of the predicted box; e represents the base of the natural logarithm; θ represents the Shape cost of each data; x represents the position; y represents the position; γ represents the distance value assigned to time; p represents the Euclidean distance between the predicted box and the real box.

9. The tea disease identification method based on improved YOLOv7 according to claim 1, characterized in that: Step S3 is specifically as follows: The data set is randomly divided into a training set, a validation set, and a test set based on a ratio of 6:2:2, and a tea disease recognition model is trained based on the training set. During the training process, the SIoU function is continuously optimized until a preset convergence condition is met; Verifying the trained tea disease recognition model based on the verification set, and testing the verified tea disease recognition model based on the test set, and if the test passes, ending the training of the tea disease recognition model; If the test fails, the training set is expanded to continue training the tea disease recognition model.

Citation Information

Cited By

  • Cucumber disease identification method based on deep learning

    CN118942084A

  • Tea tree fresh leaf identification method and system based on YOLOv8

    CN119723291A