Mountain tea garden tea tree pest identification and counting method based on YOLOv7
By applying the YOLOv7 target detection network model in the mountain tea garden environment, the identification and quantity statistics of tea tree pests were solved, and the problem of difficulty in identifying and counting tea tree pests in the tea garden environment was achieved, and high-accuracy automated identification and counting were achieved, which promoted the intelligent management of tea gardens.
Patent Information
- Application Number
- CN202311801642.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art is difficult to achieve rapid and accurate identification and counting of tea tree pests in mountain tea garden environments, especially when the tea garden is remote and the environment is complex.
The deep learning object detection network model based on YOLOv7 is used to train and identify tea tree pest images, and the data set is constructed through data augmentation and labeling to realize the identification and quantity statistics of tea tree pests.
The accurate identification and quantity statistics of tea tree pests were achieved, with the recognition accuracy, recall rate, F1_Score and accuracy mean values: 84.68%, 81.73%, 83.18% and 88.82%, respectively, and the counting accuracy was 91.22%, which greatly reduced the time and labor of manual identification and improved the efficiency of pest monitoring and control in tea gardens.
Smart Images

Figure CN120219906A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of identifying and counting tea tree pests in mountain tea gardens, and particularly relates to a method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7. Background Art
[0002] China is one of the largest countries in the world in terms of tea production, consumption, and trade. The growth of tea trees is extremely vulnerable to pest infestations. There are up to hundreds of known tea tree pests, which seriously affect the growth and development of tea trees and reduce the tea yield. To ensure the normal growth of tea trees and produce high-quality tea, the prevention and control of tea tree pests are particularly important, and detecting tea tree pests is the prerequisite for prevention and control. Completing the accurate and rapid automatic identification of tea tree pests is the key to the prevention and control of tea tree pests.
[0003] At present, the identification of tea tree pests mainly adopts manual experience observation and digital image processing methods. For the manual experience observation method, most pests are small in size and move fast, making it difficult to observe their traces with the naked eye. At the same time, affected by factors such as eyesight, observation environment, and weather, it may lead to the inability to identify or detect tea tree pests. Therefore, designing an automatic, rapid, and accurate method for identifying and counting tea tree pests in mountain tea gardens, realizing the automatic identification of tea garden pests, reducing labor costs, promoting the intelligent development of agriculture, and achieving convenient, fast, low-cost, intelligent monitoring of the occurrence of tea garden pests and precise prevention and control. Summary of the Invention
[0004] The purpose of the present invention is to propose a method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7. By using the deep learning method, through the training of the YOLOv7 object detection network model on the images of tea tree pests in mountain tea gardens, different tea tree pest image features are extracted. After deep learning, the types of tea tree pests are identified, and the number of detected bounding boxes is counted to complete the statistics of the specific pest quantity.
[0005] To achieve the above purpose, the present invention proposes a method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7, including the following steps: S1: Collect images of tea tree pests in mountain tea gardens, perform data augmentation on the images, and construct a data set; S2: Label the data set and divide it into a training set, a validation set, and a test set; S3: Construct a YOLOv7 object detection network model, train the YOLOv7 object detection network model based on the constructed training set, and obtain a tea tree pest identification and counting model; S4: Use the trained YOLOv7 model to identify and count tea tree pests; S5: Verification and testing of the tea tree pest recognition and counting model for mountain tea gardens based on YOLOv7.
[0006] As a further aspect of the present invention, the step S1 specifically includes the following steps: S11: Collect images of tea tree pests in different poses in mountain tea gardens, and take original images of tea tree pests through multi-angle shooting in front-light and back-light environments; S12: Perform data augmentation on the collected original images, including randomly selecting one or more of the following image enhancement methods for the annotated image files: image blurring, brightness change, aspect ratio change, color jitter, random cropping, transparency change, horizontal flipping, adding mosaics, converting to grayscale, adding noise, and mirror image enhancement.
[0007] As a further aspect of the present invention, the step S2 specifically includes the following steps: S21: Annotate the preprocessed images to obtain image label files to be recognized, and save them in the.txt format that can be trained and recognized by YOLO; S22: Divide the tea tree pest dataset into a training set, a validation set, and a test set according to the ratio of 7:2:1.
[0008] As a further aspect of the present invention, in the step S3, the overall structure of the YOLOv7 object detection network model: an input end for inputting images, a Backbone for feature extraction, a Neck for feature fusion, and an output end for result prediction and output; the Backbone part mainly includes convolution and pooling operations for extracting feature information of tea tree pests in images; the Neck part is used for fusing different-scale tea tree pest feature information of the extracted different features; the output end is used for predicting and outputting tea tree pests in images.
[0009] As a further aspect of the present invention, the step S4 specifically includes the following steps: S41: Input the image of the tea tree pest to be detected into the trained YOLOv7 network model to obtain the output pest detection results and quantity information; S42: Output the visualization result, and mark the pest category, confidence level, target area Box, and the number of target boxes in the output image.
[0010] As a further aspect of the present invention, in step S5, the validation set is used to evaluate the model performance with Precision, Recall, F1_Score, and AP (Average Precision) as evaluation metrics; the test set and the accuracy rate (Average) are used as evaluation metrics to evaluate the recognition accuracy of the identified pests. Precision represents the proportion of correctly identified tea tree pests by the model, Recall represents the completeness of identifying tea tree pests in the image, F1_Score represents the harmonic mean of precision and recall, and Average Precision represents the precision of each type of target recognition.
[0011] In the above calculation formulas, TP represents the number of true positive samples; FP represents the number of false positive samples; FN represents the number of false negative samples; Numerror represents the difference between the number of true tea tree pests and the number of predicted tea tree pests; Num represents the number of true tea tree pests.
[0012] The beneficial effects of the present invention are as follows: The present invention discloses a method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7. Only by inputting images of tea tree pests, the network model autonomously learns the characteristics of pests, and through the trained target detection network model, the identification of pests and the counting of pest numbers are realized. Finally, the recognition accuracy, recall rate, F1_Score, and average precision of tea tree pests are 84.68%, 81.73%, 83.18%, and 88.82% respectively, and the counting accuracy is 91.22%. For the manual method of identifying and counting tea tree pests, in the mountain tea garden environment, not only is the tea garden remote and it is difficult for people to walk in the mountain environment, and experts are needed to distinguish tea tree pests, but also the pests are small and flexible and not easy to detect, which requires a lot of time and labor; for the digital image processing method, in the mountain tea garden environment, most of the tea tree pests are small in size, and some colors are similar to the color of tea leaves, resulting in difficulties in pest identification, which is not conducive to the management of ecological tea gardens and the early prevention of tea tree pests. The method for identifying and counting tea tree pests proposed by the present invention can identify and count the tea tree pests in mountain tea gardens, and can complete the identification and counting of tea tree pests through the network model without the help of experts, and has high accuracy, which is beneficial to the monitoring and prevention of the occurrence of tea garden pests. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings forming a part of this application are used to provide a further understanding of this application. The schematic embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation of this application. In the drawings: Figure 1 It is a schematic flow diagram of the method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to an embodiment of the present invention; Figure 2 It is a diagram of the data set acquisition environment adopted in an embodiment of the present invention; Figure 3 It is a schematic diagram of the data set annotation adopted in an embodiment of the present invention; Figure 4 It is an effect diagram of data augmentation adopted in an embodiment of the present invention; Figure 5 It is a model structure diagram adopted in an embodiment of the present invention; Figure 6 It is a diagram of the model training result adopted in an embodiment of the present invention; Figure 7 It is an effect diagram of tea tree pest identification and counting adopted in an embodiment of the present invention; DETAILED DESCRIPTION OF THE EMBODIMENTS
[0014] The following describes the specific embodiments of the present invention. It should be noted that the features in the embodiments of this application can be combined with each other. The following will detail this application with reference to the drawings and embodiments.
[0015] It should be noted that although the logical order is shown in the flowchart of the drawings, in some cases, the steps shown or described can be executed in a different order than here.
[0016] As Figure 1-7 shown, in this embodiment, a method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 is provided, including the following steps: S1: Collect images of tea tree pests in mountain tea gardens, perform data augmentation on the images, and construct a data set; S2: Annotate the data set and divide it into a training set, a validation set, and a test set; S3: Construct a YOLOv7 object detection network model, and train the YOLOv7 object detection network model based on the constructed training set to obtain a tea tree pest identification and counting model; S4: Use the trained YOLOv7 model to identify and count tea tree pests; S5: Verification and testing of the tea tree pest identification and counting model based on YOLOv7 in mountain tea gardens.
[0017] For a further optimized solution, in step S1, it specifically includes the following steps: S1.1: Collect images of tea tree pests in different postures in mountain tea gardens, and take original images of tea tree pests from multiple angles under different lighting conditions, including front light and back light; preprocess the collected original images. First, remove images with blurred targets, low contrast, and incomplete pest features to obtain clear-featured and high-quality images of tea tree pests. S1.2: Perform data augmentation on the collected images of tea tree pests, including randomly selecting one or more of the following image enhancement methods: image blurring, brightness change, aspect ratio change, color jitter, random cropping, transparency change, horizontal flipping, adding mosaics, converting to grayscale, adding noise, and mirror image enhancement to enhance the labeled image files.
[0018] For a further optimized solution, in step S2, use the LabelImg tool to label the processed images, label the category information and detection area data for each detection object in each image to obtain an image label file to be recognized, and save it in the.txt format that can be trained and recognized by YOLO; divide the tea tree pest dataset into a training set, a validation set, and a test set according to the ratio of 7:2:1.
[0019] For a further optimized solution, the overall structure of the YOLOv7 object detection network model built in step S3: an input end for inputting images, a Backbone for feature extraction, a Neck for feature fusion, and an output end for result prediction and output; the Backbone part mainly includes convolution and pooling operations for extracting feature information of tea tree pests in the image; the Neck part is used to fuse the tea tree pest feature information of different scales of the extracted different features; the output end is used to predict and output the tea tree pests in the image.
[0020] For a further optimized solution, in step S4, it specifically includes the following steps: S4.1: Input the image of the tea tree pest to be detected into the trained YOLOv7 network model to obtain the output pest detection results and quantity information. S4.2: Output the visualization result, and mark the pest classification, confidence level, target area Box, and the number of target boxes in the output image.
[0021] For a further optimized solution, after recognizing the image of the tea tree pest to be recognized based on the YOLOv7 network model, count the tea tree pests by statistically counting the number of recognized target boxes.
[0022] Further optimization solution. In step S5, verification and testing of the recognition model for tea tree pests in mountain tea gardens based on YOLOv7: For model verification, use the validation set to evaluate the model performance with Precision, Recall, F1_Score, and AP (Average precision) as evaluation indicators; for model testing, use the test set and the accuracy rate (Average) as the evaluation indicator to evaluate the recognition accuracy of the identified pests.
[0023] Through the above steps, the recognition and counting of tea tree pests in mountain tea gardens are achieved, and then the test set can be used for testing.
[0024] The present invention first collects pictures of tea tree pests in mountain tea gardens and selects pictures of tea tree pests with clear features and good quality; secondly, performs data augmentation on the images, completes data annotation, and obtains a recognition dataset for tea tree pests in mountain tea gardens; then divides the tea tree pest recognition dataset into a training set, a validation set, and a test set according to the ratio of 7:2:1; finally, trains the dataset through the YOLOv7 network model to achieve the recognition of tea tree pests and count the number of recognized target boxes, realizing the counting of tea tree pests.
[0025] The accuracy rate, recall rate, F1_Score, and mean precision of the present invention for the recognition of tea tree pests in mountain tea gardens are respectively: 84.68%, 81.73%, 83.18%, and 88.82%, and the counting accuracy rate is 91.22%. It well solves the problems of difficult recognition due to the remote location of the tea garden, difficult walking in the mountain environment, small size of most tea tree pests, and similar colors between some pests and tea leaves. The method for recognizing and counting tea tree pests proposed by the present invention can recognize and count the tea tree pests in mountain tea gardens, and can complete the recognition and quantity statistics of tea tree pests through a network model without the help of experts, and has high accuracy, which is beneficial to the monitoring and control of the occurrence of tea garden pests.
[0026] Figure 1 This is the flow chart adopted by the present invention. First, collect images of tea tree pests in mountain tea gardens to establish a dataset; then perform data augmentation and annotation on the images; secondly, divide the entire dataset into a training set, a validation set, and a test set; finally, use the network model to train the training set, use the validation set to evaluate the model performance, and use the test set for testing and result analysis.
[0027] Figure 2 This is the environmental map for dataset collection. The tea tree pests in the image are small and dense, and affected by the environment and light, which brings difficulties to the recognition and counting of tea tree pests.
[0028] Figure 3Schematic diagram of dataset annotation adopted by the present invention. The LabelImg annotation tool is used to annotate each tea tree pest and named "cicada".
[0029] Figure 4 Effect diagram of data augmentation adopted by the present invention.
[0030] Figure 5 Model structure diagram adopted by the present invention. The entire model structure can be divided into four parts: input end, Backbone, Neck, and output end.
[0031] Figure 6 Model training result diagram adopted by the present invention. It can be seen from the visualization structure that the model fitting effect is good.
[0032] Figure 7 Effect diagram of tea tree pest recognition and counting. The counting result of tea tree pests is shown at the upper left corner of the image.
[0033] The present invention discloses a method for identifying and counting tea tree pests in the mountain tea garden environment based on YOLOv7. Only by inputting the image of tea tree pests, the network model can autonomously learn the pest characteristics, and through the trained target detection network model, the identification of pests and the statistics of pest numbers can be realized. Finally, the recognition accuracy, recall rate, F1_Score and mean precision of tea tree pests are 84.68%, 81.73%, 83.18% and 88.82% respectively, and the counting accuracy is 91.22%. For the artificial method of identifying and counting tea tree pests, in the mountain tea garden environment, not only is the tea garden located in a remote place, it is difficult for people to walk in the mountain environment, and experts are needed to identify tea tree pests, but also the pests are small and flexible and not easy to be found and detected, which requires a lot of time and labor; for the digital image processing method, in the mountain tea garden environment, most of the tea tree pests are small in size, and some of their colors are similar to those of tea leaves, resulting in difficulties in pest identification, which is not conducive to the management of ecological tea gardens and the early prevention of tea tree pests. The method for identifying and counting tea tree pests proposed by the present invention can identify and count the tea tree pests in the mountain tea garden. Without the help of experts, the identification and counting of tea tree pests can be completed through the network model, and it has a high accuracy, which is beneficial to the monitoring and control of the occurrence of tea garden pests.
Claims
1. A method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7, characterized in that, It includes the following steps: Collect images of tea tree pests in mountain tea gardens, perform data augmentation on the images, and construct a dataset; Annotate the dataset and divide it into a training set, a validation set, and a test set; Construct a YOLOv7 object detection network model, train the YOLOv7 object detection network model based on the constructed training set, and obtain a tea tree pest recognition and counting model; Use the trained YOLOv7 model for tea tree pest recognition and counting; Verification and testing of the tea tree pest recognition and counting model for mountain tea gardens based on YOLOv7.
2. The method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to claim 1, characterized in that, The tea tree pest recognition dataset for mountain tea gardens captures pest images with front light and back light to enhance the diversity of the dataset; the data augmentation of the original tea tree pest dataset includes a series of data augmentations such as image blurring, brightness change, aspect ratio change, color jitter, random cropping, transparency change, horizontal flipping, transparency change, adding mosaics, and converting to grayscale for the images.
3. The method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to claim 1, wherein, The annotation of the preprocessed dataset is to perform data annotation on the dataset through the LabelImg tool and save it in the.txt format; the dataset is divided into a training set, a validation set, and a test set according to the ratio of 7:2:
1.
4. The method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to claim 1, characterized in that, The YOLOv7 network model specifically includes: an input end for inputting images, a Backbone for feature extraction, a Neck for feature fusion, and an output end for result prediction and output; the Backbone part mainly includes convolution and pooling operations for extracting feature information of tea tree pests in the images; the Neck part is used for fusing different scale tea tree pest feature information of the extracted different features; the output end is used for predicting and outputting tea tree pests in the images.
5. The method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to claim 1, characterized in that, Based on the dataset, train the network model, use the validation set to verify the performance of the YOLOv7 network model, use the test set to test the YOLOv7 network model, and complete the recognition and counting of tea tree pests in mountain tea gardens. The specific method includes: Use the YOLOv7 network model to train the dataset and learn the features of tea tree pests; obtain a tea tree pest recognition model for mountain tea gardens, input the tea tree pest image to be recognized into the YOLOv7 network model for testing, and realize the recognition of tea tree pests.
6. The method for identifying and counting tea tree pests in mountain tea gardens based on YOLOv7 according to claim 1, wherein, Based on the counting of the tea tree pests, after using the YOLOv7 network model to recognize the tea tree pests, the counting of the tea tree pests is realized by counting the number of target boxes of the recognized tea tree pests.