Tea disease and insect pest identification method
By adopting lightweight convolution technology and attention mechanism in tea pest identification, combined with Wise-IoU loss function, the problems of low identification accuracy and simple model structure in the existing technology are solved, efficient and accurate tea pest identification is achieved, and intelligent tea management is supported.
Patent Information
- Application Number
- CN202411722831.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art has problems in the recognition of tea pests and diseases with low recognition accuracy, simple model structure and inability to capture complex features, insufficient subtle feature recognition of YOLO series models, rich transfer learning depends on training data, and insufficient recognition accuracy of mobile applications.
Lightweight convolution technology is used in combination with attention mechanism and based on Wise-IoU loss function, precise positioning and identification of tea diseases and pests are achieved. The specific steps include obtaining tea leaves images, inputting them into the pre-trained model, using the YOLOv8 network and GhostConv module for feature extraction, introducing coordinate attention mechanism and Wise-IoU v2 loss function, and optimizing the accuracy of object detection.
It significantly reduces the computational complexity and number of parameters, enhances the application performance in resource-constrained environments, improves the ability to identify subtle pest and disease characteristics, optimizes the accuracy of target detection, shows strong robustness and adaptability, and supports intelligent tea management and pest control.
Smart Images

Figure CN119904740A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of pest identification, and in particular to a method for identifying pests and diseases in tea. Background Art
[0002] Tea plays an important role in my country, but pests and diseases have always been a headache for tea growers. Pests and diseases not only affect the yield and quality of tea, but also threaten the ecological environment of tea gardens. Therefore, it is very important to understand and identify the types of tea pests and diseases and take timely prevention and control measures.
[0003] Existing technologies have multiple shortcomings in identifying tea pests and diseases: traditional image processing methods have poor adaptability to complex backgrounds and changes in lighting, resulting in low recognition accuracy. Although convolutional neural networks (CNNs) have introduced deep learning, the model structure is relatively simple and cannot fully capture complex features. The YOLO series of models have improved in speed and accuracy, but are still insufficient in recognizing subtle features. Although transfer learning can improve accuracy, it usually relies on the richness of training data, and insufficient data will limit its effectiveness. Mobile applications based on image recognition are still insufficient in recognition accuracy and intelligence level, and fail to fully meet actual needs. These limitations make it difficult for existing technologies to effectively support the intelligent management of tea production. Summary of the invention
[0004] In order to solve or partially solve the problems existing in the related technologies, the present application provides a method for identifying tea pests and diseases, which adopts lightweight convolution technology and introduces an attention mechanism to achieve accurate positioning and identification of tea pests and diseases based on the Wise-IoU loss function.
[0005] The first aspect of the present application provides a method for identifying tea pests and diseases, comprising the following steps:
[0006] Get tea leaf images;
[0007] Input the tea image into the pre-trained model to obtain the prediction result output by the pre-trained model, where the pre-trained model includes a YOLOv8 network and a lightweight convolution module that uses half of the feature channels for 5×5 depthwise separable convolution. The pre-trained model includes a coordinate attention mechanism and a Wise-IoU v2 loss function.
[0008] The expression of Wise-IoU v2 loss function is:
[0009]
[0010] Determine the IoU value and weight value between the predicted box and the true box of the prediction result, obtain the weighted IoU value based on the IoU value and weight value, and select the predicted box with the highest weighted IoU value as the target predicted box;
[0011] Output the disease type and recognition probability corresponding to the target prediction box.
[0012] Among them, the disease types include tea white star disease, gray blight, oil tea broad shield bug and tea ring spot disease.
[0013] Among them, the attention mechanism includes coordinate information embedding and coordinate attention generation, which is used to improve the ability to recognize subtle pest and disease characteristics by capturing spatial position and channel information.
[0014] The coordinate information embedding includes:
[0015] Input X, encode each channel along the horizontal and vertical coordinates respectively based on two spatially extended pooling kernels (H,1) or (1,W);
[0016] The output of the c channel at height h is expressed as: The output at width ω is expressed as:
[0017] The two transformations aggregate features along two spatial directions respectively, generating a pair of direction-aware feature maps.
[0018] The coordinate information embedding includes:
[0019] Get the equations separately and The generated aggregate feature map;
[0020] After the connection, it is sent to the convolution transformation function F1, and we get: f = δ (F1 [z h ,z ω ]), where [.,.] represents the connection operation along the spatial dimension, δ is a nonlinear activation function, f∈R C / r×(H+W) is the intermediate feature map that encodes the spatial information in the horizontal and vertical directions, and r is the reduction ratio of the control block size;
[0021] Split f into two separate tensors f∈R along the spatial dimension C / r×H and f∈R C / r×W ;
[0022] Based on the additional convolution transformation F h and F ω Convert f respectively h and f ω For a tensor with the same number of channels as the input X, we get: h =σ(F h (f h )) and g ω =σ(F ω (f ω )), where σ is the s function, g h and gω is the attention weight;
[0023] The output Y of the coordinate attention module is obtained, expressed as:
[0024] Among them, the Wise-IoU v2 loss function is based on the monotonic focusing mechanism and introduces L IoU The mean of is used as the normalization factor, and its gradient changes to:
[0025]
[0026] The gradient gain is:
[0027]
[0028] The tea image is obtained by preprocessing the original image, and the preprocessing of the original image includes:
[0029] Open the original image and adjust the image size and format to get the input image;
[0030] Rotate the input image to obtain extended images at different angles and perform image enhancement, including brightness and contrast adjustment and Gaussian blur;
[0031] The enhanced images are saved according to specific naming rules to obtain a structured data set, which includes multiple tea images.
[0032] The technical solution provided by this application may have the following beneficial effects:
[0033] This application provides a method for identifying tea pests and diseases. The lightweight convolution technology is used to significantly reduce the computational complexity and the number of parameters, and enhance the application performance in resource-constrained environments. The introduction of the attention mechanism enables the model to capture key features more effectively and improves the ability to identify subtle pests and diseases. The Wise-IoU loss function is used to optimize the accuracy of target detection, and it performs well in locating and identifying tea pests and diseases. The model shows strong robustness and adaptability, providing strong technical support for intelligent tea management and pest and disease control.
[0034] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above and other objects, features and advantages of the present application will become more apparent through a more detailed description of exemplary embodiments of the present application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the present application.
[0036] Figure 1 It is a schematic diagram of the process of the tea pest identification method of the present application;
[0037] Figure 2 This is a schematic diagram of the lightweight convolution technology structure of the tea pest and disease identification method of the present application;
[0038] Figure 3 It is a schematic diagram of the YOLOv8n-GCW model structure of the tea pest and disease identification method of this application;
[0039] Figure 4 This is a schematic diagram of the YOLOv8n model structure;
[0040] Figure 5 This is a schematic diagram of the YOLOv8n-ghost model structure;
[0041] Figure 6 This is a schematic diagram of the identification results of the tea pest identification method of the present application when running on Windows 11;
[0042] Figure 7 It is a schematic diagram of the identification results of the mobile phone operation of the tea pest identification method of the present application. DETAILED DESCRIPTION
[0043] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0044] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0045] In the description of the present application, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0046] Unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0047] The technical solution of the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0048] like Figure 1 The tea plant pest identification method shown comprises the following steps:
[0049] S1. Acquire tea leaves image.
[0050] The tea image is obtained by preprocessing the original image, and the preprocessing of the original image includes:
[0051] S101, opening the original image and adjusting the image size and format to obtain an input image.
[0052] The original images are taken from photos of tea gardens taken on site. During the shooting process, a high-resolution camera was used to capture the details of the tea leaves. The resolution of the original images includes two sizes: 3060x3060 and 3060x4080 (according to the ratio of 1:1 and 3:4 of mobile phone cameras).
[0053] In order to unify the processing and improve the efficiency of model training, all collected images are pre-processed and resized to a fixed size of 640x640. This process is completed using an Adobe Photoshop automation script, which traverses the specified input folder, reads each image and performs the following steps:
[0054] ① Open the image: Open each original image through Photoshop.
[0055] ② Adjust image size: Resize the image to 640x640 to meet the model input requirements.
[0056] ③ Save the processed image: Save the adjusted image in JPEG format with the highest quality setting to ensure that as many image details as possible are preserved. Each image will be renamed, for example, "c_x.jpg", where c refers to the broad shield bug of the oil tea tree and x is the serial number of the image for subsequent processing.
[0057] The processed images will be stored in the specified output folder to form a structured data set, laying the foundation for subsequent model training and verification. This method ensures the high quality and consistency of the data set and improves the model's ability to identify and detect tea pests and diseases.
[0058] S102, rotating the input image to obtain extended images at different angles and performing image enhancement, where the image enhancement includes brightness and contrast adjustment and Gaussian blur;
[0059] To enhance and expand the dataset for tea pest and disease detection, a series of image processing techniques were employed.
[0060] ① Image rotation:
[0061] For each image in the input directory, the OpenCV library is used to implement image rotation processing. Each image will be randomly rotated 90 degrees, 180 degrees, and 270 degrees and saved as a new file. This can increase the diversity of the data set and enable the model to effectively identify targets at different angles. The original image is also saved as one of them.
[0062] The process is implemented through an automated script, ensuring efficient and consistent image processing.
[0063] ②Image enhancement:
[0064] After the rotation process is completed, the image is further enhanced. The following techniques are used to improve image quality and diversity:
[0065] Brightness enhancement: By adjusting the brightness of the image, decreasing it to 30% and increasing it to 130%, images with different brightness levels are generated, thus simulating the lighting changes under natural conditions.
[0066] Contrast adjustment: Increase the contrast of the image, specifically by 30%. This adjustment can enhance the details of the image and enable the model to better adapt to different lighting conditions and image quality.
[0067] Gaussian Blur: Applies a Gaussian blur with a kernel size of 5. This process simulates the blurring of images during the capture process and makes the model more robust to blurry images.
[0068] S103, saving the enhanced image according to a specific naming rule to obtain a structured data set, wherein the data set includes a plurality of tea leaves images.
[0069] All processed images are saved according to a specific naming rule for easy tracking and use. For example, the name format of a rotated image is "original file name_rotation angle.jpg", the name format of an image after brightness enhancement is "original file name_b_xx.jpg", and the name format of an image after contrast adjustment is "original file name_c_xx.jpg". This naming rule effectively organizes the dataset, making it easy to identify the images generated by different processing methods.
[0070] The images collected from the tea garden were classified and appropriate original data sets were selected, including 100 images of tea white spot disease, 120 images of gray blight, 200 images of broad shield bugs on oil tea, and 120 images of tea ring spot disease. After random rotation and image enhancement, 1,000 images of each category were obtained, forming a total of 4,000 data sets that can be used in the next step.
[0071] Use the X-AnyLabeling annotation tool to annotate the processed dataset and generate a JSON file with the same name as the image. Next, use a Python script to convert the JSON file to an XML file, and then convert the XML file to a TXT file that the YOLO model can recognize. Finally, we divide the training set and validation set into a ratio of 8:2.
[0072] S2. Input the tea image into the pre-trained model to obtain the prediction result output by the pre-trained model, wherein the pre-trained model includes a YOLOv8 network and a lightweight convolution module that uses half of the feature channels for 5×5 depth-separable convolution. The pre-trained model includes a coordinate attention mechanism and a Wise-IoU v2 loss function.
[0073] In the YOLOv8 network, the C2f module is used as the backbone network. The C2f (Cross Stage Partial) module enhances the flow and utilization efficiency of feature information through cross-stage connections and partial feature reuse. It only selects some features for processing at each stage, reducing computational complexity and model parameters while improving network performance. By effectively integrating low-level and high-level features, the C2f module significantly improves the accuracy and robustness of target detection tasks and optimizes overall computational efficiency. This makes C2f a key component in YOLOv8, especially suitable for application scenarios that require high performance and low computational burden.
[0074] Although this module performs well in optimizing model structure and improving parameter efficiency, the network size is still too large for drone object detection applications. To address this issue, research on compression and pruning of deep learning networks has shown that there are a large number of redundant features in the feature maps generated by many mainstream convolutional neural networks (CNNs), some of which are similar. To this end, GhostNet proposed the key role of redundant features in achieving excellent detection results and introduced the GhostConv module.
[0075] The structure of GhostConv lightweight convolution technology is as follows Figure 2 As shown in the figure, the GhostConv module uses half of the feature channels to perform 5×5 depthwise separable convolution (DSConv) to expand the receptive field, and then concatenates the convolution result with the original feature to reuse the original information. This low-overhead operation can generate more redundant feature maps and improve detection performance. Inspired by the advantages of the GhostConv module, it is introduced into the YOLOv8 network to reduce parameters and computation. Specifically, the GhostConv module effectively generates redundant features by convolving half of the features and connecting them with the original features, while significantly reducing the parameters and computational burden of the model. After introducing the GhostConv module, the YOLOv8 network not only improves the detection effect, but also further optimizes the computational efficiency while maintaining high performance, which is especially suitable for application scenarios such as drone object detection, mobile device detection, and embedded device detection.
[0076] The CoordinateAttention module aims to enhance the expressiveness of convolutional features in mobile networks. Compared with the traditional Squeeze and Excitation (SE) attention mechanism, CoordinateAttention can not only consider the relationship between channels, but also effectively integrate spatial location information. This module is implemented through two main steps: coordinate information embedding and coordinate attention generation, which can simultaneously capture long-distance dependencies and precise location information, thereby more accurately locating the target object.
[0077] The CoordinateAttention module can be viewed as a computational unit designed to enhance the expressiveness of learned features in mobile networks. It can receive any intermediate feature tensor X = [x1, x2, x3, x4, …, x C ]∈R C ×H×W As input, and output a transformed tensor Y = [y1, y2, y3, y4, ..., y C ], which is the same size as X.
[0078] Coordinate attention encodes channel relationships and long-distance dependencies while having precise location information. It is performed in two steps: coordinate information embedding and coordinate attention generation.
[0079] Coordinate information embedding:
[0080] Global pooling is commonly used for channel attention to globally encode spatial information, but it compresses the global spatial information into one channel descriptor, making it difficult to preserve the position information, which is crucial for capturing spatial structures in visual tasks. To encourage the attention module to capture long-range interactions in space with precise position information, we decompose global pooling into a one-to-one one-dimensional feature encoding operation. Specifically, given an input X, we use two spatially extended pooling kernels (H, 1) or (1, W) to encode each channel along the horizontal and vertical coordinates, respectively. Therefore, the output of the c-channel at height h can be expressed as:
[0081]
[0082] 77 Similarly, the output of the c channel at width ω can be expressed as:
[0083]
[0084] These two transformations aggregate features along two spatial directions respectively, producing a pair of direction-aware feature maps. This is very different from the compression operation in the channel attention method that produces a single feature vector. These two transformations also allow the attention module to capture long-range dependencies along one spatial direction and retain precise location information in another spatial direction, which helps the network locate objects of interest more accurately.
[0085] Coordinate Attention Generation:
[0086] As mentioned above, the two equations achieve a global receptive field and encode precise location information. To exploit the resulting expressive power, a second transformation, called coordinate attention generation, is proposed. The design follows the following three criteria. First, the application of the new transformation in mobile environments should be as simple and low-cost as possible. Second, it should make full use of the captured location information so that the region of interest is accurately highlighted. Finally, and most importantly, it should also be able to effectively capture the relationship between channels, which has been shown to be crucial in existing studies.
[0087] Specifically, given by the equation:
[0088]
[0089] The generated aggregate feature maps are first concatenated and then sent to a shared 1×1 convolution transformation function F1, resulting in: f = δ(F1[z h ,zω ]), where [.,.] represents the connection operation along the spatial dimension, δ is a nonlinear activation function, f∈R C / r×(H+W) is an intermediate feature map that encodes spatial information in the horizontal and vertical directions. Here, r is the reduction ratio that controls the block size. For example, 32. We then split f into two separate tensors f∈R along the spatial dimension C / r×H and f∈R C / r×W Next, we use two additional 1×1 convolution transformations F h and F ω Convert f respectively h and f ω For a tensor with the same number of channels as the input X, we get:
[0090] g h =σ(F h (f h )) and g ω =σ(F ω (f ω )).
[0091] σ is the s function. In order to reduce the complexity of the model, the number of channels of f is usually reduced by an appropriate reduction ratio r (for example, 32). Output g h and g ω are expanded and used as attention weights respectively. Finally, the output Y of the coordinate attention module can be expressed as:
[0092] Wise-IoU loss function
[0093] The Wise-IoU loss function (Weighted Intersection over Union Loss) is a loss function used in target detection and segmentation tasks. It is based on the traditional intersection-over-union (IoU) metric, but introduces weights to enhance its response to samples of different categories or difficulty levels.
[0094] Wise-IoU introduces a weight mechanism to give different attention to samples of different categories and different difficulties. For example, samples of small target categories may be given higher weights, thereby encouraging the model to pay more attention to these difficult-to-detect targets.
[0095] Loss calculation:
[0096] The calculation process of Wise-IoU usually includes the following steps:
[0097] Calculate the IoU value for each sample.
[0098] Assign weights to each sample based on the IoU value and preset strategies (such as category distribution, sample difficulty, etc.).
[0099] Use the weighted IoU value to calculate the loss. For example, you can use the weighted 1-IoU as the loss.
[0100] The form of Wise-IoU loss function
[0101]
[0102] N is the total number of samples
[0103] p i is the prediction box of the i-th sample
[0104] g i is the true box of the i-th sample
[0105] ω i is the weight of the i-th sample, which can be dynamically adjusted according to the difficulty of the category or sample.
[0106] The Wise-IoU loss function is suitable for the following scenarios:
[0107] Object detection: used to improve the model's ability to recognize small or difficult-to-detect objects.
[0108] Semantic segmentation: In the case of category imbalance, applying Wise-IoU can significantly improve the performance of the model.
[0109] Instance segmentation: Improve the detection capability of specific targets by adjusting the weights of different instances.
[0110] Due to the high complexity of the dataset to be processed, we chose to use Wise-IoU v2, which has further improved performance and computational efficiency.
[0111] Wise-IoU v1 constructs an attention-based bounding box loss, and Wise-IoU v2 adds a focusing mechanism by constructing a gradient gain (focusing coefficient) calculation method based on this.
[0112] Since low-quality examples are inevitable in the training data, geometric factors (such as distance and aspect ratio) tend to impose greater penalties on these examples, thus affecting the generalization ability of the model. An ideal loss function should be able to reduce the penalty caused by geometric factors when the anchor box and the target box overlap well, while reducing the intervention on the model during training to enhance the generalization performance of the model. Based on this concept, Wise-IoU v1 with a dual-layer attention mechanism was developed:
[0113] R WIoU ∈[1,e): significantly enlarges the L of the normal quality anchor box IoU
[0114] L IoU ∈[0,1]: significantly reduce the R of high-quality anchorbox WIoU , and when the anchorbox coincides well with the target box, it pays more attention to the distance between the center points.
[0115] L WIoUv1 =R WIoU L IoU
[0116]
[0117] Among them, W g , H g is the size of the smallest enclosing box. WIoU Produces gradients that hinder convergence, W g , H g It is separated from the computation graph (superscript * denotes this operation). Because it effectively removes factors that hinder convergence, no new metrics such as aspect ratio are introduced.
[0118] Wise-IoUv2 loss function:
[0119]
[0120] Gradient changes:
[0121] Gradient gain:
[0122]
[0123] Normalization factor introduction:
[0124] Exponential Moving Average of Momentum:
[0125] Wise-IoU v2 is an enhanced loss function based on the monotone focusing mechanism designed by Focal Loss, which aims to reduce the contribution of simple examples to the loss value, thereby improving the model's focusing ability and classification performance on difficult examples. The form of its loss function is shown above, and after the introduction of the focusing coefficient, the gradient of back propagation also changes accordingly. The focusing coefficient of the gradient increase increases with L IoU The decrease of L may lead to a slow convergence in the later stage of training. IoU The mean of is used as the normalization factor, and the updated loss function is:
[0126]
[0127] This keeps the gradient gain at a high level and solves the convergence speed problem.
[0128] S3. Determine the IoU value and weight value between the predicted box and the true box of the prediction result, obtain the weighted IoU value according to the IoU value and the weight value, and select the predicted box with the highest weighted IoU value as the target predicted box.
[0129] The IoU value is a commonly used evaluation indicator in target detection tasks, which is used to measure the degree of overlap between the bounding box predicted by the model and the true bounding box.
[0130] Calculate the Intersection over Union (IoU) value between each predicted box and the true box. The IoU value represents the degree of overlap between the predicted box and the true box, ranging from 0 to 1, where 1 represents a perfect match. Assign a weight value to each predicted box. The weight value is based on different criteria, such as category distribution, sample difficulty, etc. In general, higher weight values can be assigned to targets that are difficult to detect or in cases of category imbalance.
[0131] The weighted IoU value is calculated based on the IoU value of each prediction box and its corresponding weight value. The weighted IoU value takes into account the IoU value and its corresponding weight, and is used to comprehensively evaluate the matching degree of the target. The prediction box with the highest weighted IoU value is selected as the target prediction box to more accurately determine the position and bounding box of the target object, thereby improving the performance and accuracy of the target detection model.
[0132] S4. Output the disease type and recognition probability corresponding to the target prediction box.
[0133] The output is as follows Figure 6 and Figure 7 As shown, the tea image is finally identified to obtain the disease type and detection probability, where the disease types include tea white star disease, gray blight, broad shield bug on oil tea, and tea ring spot disease.
[0134] like Figure 3 The YOLOv8n-GCW model shown can realize automatic detection of tea pests and diseases. The specific steps are as follows:
[0135] (1) Model architecture design:
[0136] YOLOv8n-GCW is used as the basic architecture, combined with GhostConv lightweight convolution technology, to achieve efficient operation of the model in a resource-constrained environment.
[0137] (2) Dataset collection:
[0138] A high-resolution camera was used to photograph tea leaves in the tea garden to obtain original images with a resolution of 3060x3060 and 3060x4080. All images were resized to a fixed size of 640x640 through an Adobe Photoshop automation script to meet the model input requirements.
[0139] (3) Dataset expansion:
[0140] OpenCV is used to randomly rotate the processed images (90 degrees, 180 degrees, and 270 degrees), and brightness and contrast adjustment, Gaussian blur and other techniques are used to enhance them to generate diverse training samples and ensure the coverage and robustness of the dataset.
[0141] (4) Data annotation:
[0142] The enhanced images were annotated using the X-AnyLabeling tool to generate a JSON file. Then, a Python script was used to convert it into a TXT file that can be recognized by the YOLO model, and the training set and validation set were divided into a ratio of 8:2.
[0143] (5) Model training:
[0144] Use custom model configuration files (yolov8.yaml) and dataset configuration files (data.yaml), and load pre-trained model weights (yolov8n.pt). During the training process, we set 150 training rounds, the input image size was 640, the batch size was 12, and the first GPU device was specified for training. The optimizer selected SGD, and weight decay (0.0005) was performed to suppress overfitting. In order to improve training efficiency, 6 parallel threads were set, and image caching and automatic mixed precision were not enabled to avoid external factors. Finally, the training results will be saved in the specified path and named "YOLOV8N-GCW". Exception handling is added throughout the process so that error information can be captured and output in time when problems occur during model loading and training.
[0145] (6) Model evaluation:
[0146] Evaluate model performance based on the training results of different models, and conduct comprehensive performance analysis using standard metrics (such as mAP, Precision, Recall, etc.). Based on the evaluation results, continue to optimize the model architecture and training strategy.
[0147] (7) Application deployment:
[0148] The optimized YOLOv8n-GCW model was deployed in actual scenarios, and combined with mobile devices and drones for real-time monitoring and automatic identification of tea pests and diseases. At the same time, a Windows 11 software based on Pyside6 and an Android 14 platform APP based on CMake and OpenCV were designed to achieve cross-platform application of the model.
[0149] Combine this preset model YOLOv8n-GCW with Figure 4 The YOLOv8n model shown and Figure 5 The YOLOv8n-ghost model shown is trained on the same dataset and the results are as follows:
[0150] yolov8n BOX(P R map50 map50-95) all 0.888 0.906 0.932 0.713 Tea white star disease 0.891 0.901 0.936 0.546 Gray blight 0.952 0.958 0.965 0.787 Oleophora oleifera 0.856 0.864 0.9 0.744 Tea ring spot 0.852 0.902 0.93 0.775 yolov8n-ghost BOX(P R map50 map50-95) all 0.9 0.897 0.932 0.678 Tea white star disease 0.913 0.88 0.937 0.538 Gray blight 0.934 0.944 0.957 0.738 Oleophora oleifera 0.885 0.887 0.914 0.72 Tea ring spot 0.866 0.877 0.921 0.717 yolov8n-gcw BOX(P R map50 map50-95) all 0.956 0.957 0.972 0.717 Tea white star disease 0.962 0.934 0.971 0.617 Gray blight 0.948 0.972 0.98 0.782 Oleophora oleifera 0.943 0.95 0.965 0.785 Tea ring spot 0.973 0.971 0.971 0.683
[0151] By comparing the F1-score, the F1-score of YOLOv8n and YOLOv8n-ghost reached 0.90, while that of YOLOv8n-GCW reached 0.96. The corresponding IoU thresholds are 0.416, 0.525, and 0.516, respectively. These data show that YOLOv8n-GCW is significantly better than YOLOv8n and YOLOv8n-ghost in terms of F1-score. Although YOLOv8n-GCW is not as good as YOLOv8n-ghost in terms of IoU threshold, it is also significantly better than YOLOv8n.
[0152] Based on the above analysis, it can be inferred that the YOLOv8n-GCW model is superior to the YOLOv8n model and the YOLOv8n-ghost model in terms of stability and detection accuracy.
[0153] Overall performance comparison
[0154]
[0155] YOLOv8n and YOLOv8n-ghost:
[0156] Both models have the same mAP@0.50 of 0.932, which indicates that they perform comparably in terms of accuracy and recall of detecting objects.
[0157] YOLOv8n-gcw:
[0158] The mAP@0.50 of this model is 0.972, which is significantly higher than the previous two models. This shows that YOLOv8n-gcw has better overall detection performance and can identify targets more accurately.
[0159] Category performance analysis
[0160] Analyze the map50 performance of each model in different categories:
[0161]
[0162] Category Analysis:
[0163] 1. Tea white star disease:
[0164] The map50 of YOLOv8n is 0.936, YOLOv8n-ghost is slightly higher at 0.937, and YOLOv8n-gcw is 0.971, showing that YOLOv8n-gcw has better detection ability in this category.
[0165] 2. Gray blight:
[0166] YOLOv8n and YOLOv8n-ghost achieve 0.965 and 0.957 respectively, while YOLOv8n-gcw reaches 0.980, indicating that YOLOv8n-gcw performs best in this category.
[0167] 3. Camellia oleifera:
[0168] The map50 of YOLOv8n is 0.900, YOLOv8n-ghost performs better at 0.914, and YOLOv8n-gcw is improved to 0.965, showing stronger detection capabilities.
[0169] 4. Tea ring spot:
[0170] In this category, YOLOv8n’s map50 is 0.930, YOLOv8n-ghost’s is 0.921, and YOLOv8n-gcw reaches 0.971, further demonstrating the overall advantage of YOLOv8n-gcw.
[0171] In summary, the YOLOv8n-gcw model shows significant advantages in target detection tasks, especially in the map50 indicator, where its overall performance is significantly higher than that of YOLOv8n and YOLOv8n-ghost. In addition, YOLOv8n-gcw also outperforms other models in various categories, indicating that it is more accurate in identifying and locating specific targets. In summary, the YOLOv8n-gcw model is an ideal choice for tea pest and disease detection tasks, providing higher detection accuracy and more reliable performance.
[0172]
[0173] In terms of the .pt file size of the model, the file size of the YOLOv8n model is 5.37MB, which is significantly larger than the other two models. In contrast, the file sizes of YOLOv8n-ghost and YOLOv8n-gcw are 2.99MB and 3.01MB, respectively, which are similar and significantly smaller. This shows that YOLOv8n may be higher in model complexity and parameter quantity, while YOLOv8n-ghost and YOLOv8n-gcw can still achieve good detection performance while maintaining a relatively small file size, which makes the latter more advantageous in environments with limited storage and computing resources.
[0174] From the above, we can see that YOLOv8n-gcw has the advantages of high recognition and detection performance and small space compared to the other two models, which is especially important for resource-constrained devices or application scenarios. For example, in edge computing environments or mobile devices, smaller model file sizes can reduce memory usage and loading time while ensuring real-time detection requirements. In addition, the high recognition performance of YOLOv8n-gcw enables it to provide more accurate detection results in practical applications, improving the overall efficiency and effectiveness of the task. Therefore, YOLOv8n-gcw has become an ideal choice for finding a good balance between performance and resource utilization, and is suitable for various target detection tasks with high requirements for real-time and accuracy.
[0175] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0176] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0177] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for identifying tea pests and diseases, characterized in that: The following steps are involved: Get tea leaf images; Inputting the tea image into a pre-trained model to obtain a prediction result output by the pre-trained model, wherein the pre-trained model includes a YOLOv8 network and a lightweight convolution module that uses half of the feature channels for 5×5 depth-separable convolution, and the pre-trained model includes a coordinate attention mechanism and a Wise-IoU v2 loss function; The expression of the Wise-IoU v2 loss function is: Determine the IoU value and weight value between the prediction box of the prediction result and the real box, obtain a weighted IoU value according to the IoU value and the weight value, and select the prediction box with the highest weighted IoU value as the target prediction box; Output the disease type and recognition probability corresponding to the target prediction box.
2. The method for identifying tea pests and diseases according to claim 1, characterized in that: The disease types include tea white star disease, gray blight, broad shield bug on oil-tea and tea ring spot disease.
3. The method for identifying tea pests and diseases according to claim 1, characterized in that: The attention mechanism includes coordinate information embedding and coordinate attention generation, which is used to improve the recognition ability of subtle pest and disease characteristics by capturing spatial position and channel information.
4. The method for identifying tea pests and diseases according to claim 3, characterized in that: The embedding of coordinate information includes: Input X, encode each channel along the horizontal and vertical coordinates respectively based on two spatially extended pooling kernels (H,1) or (1,W); The output of the c channel at height h is expressed as: The output at width ω is expressed as: The two transformations aggregate features along two spatial directions respectively, generating a pair of direction-aware feature maps.
5. The method for identifying tea pests and diseases according to claim 3, characterized in that: The embedding of coordinate information includes: Get the equations separately and The generated aggregate feature map; After the connection, it is sent to the convolution transformation function F1, and we get: f = δ (F1 [z h ,z ω ]), where [.,.] represents the connection operation along the spatial dimension, δ is a nonlinear activation function, f∈R C / r×(H+W) is the intermediate feature map that encodes the spatial information in the horizontal and vertical directions, and r is the reduction ratio of the control block size; Split f into two separate tensors f∈R along the spatial dimension C / r ×H and f∈R C / r×W ; Based on the additional convolution transformation F h and F ω Convert f respectively h and f ω For a tensor with the same number of channels as the input X, we get: h =σ(F h (f h )) and g ω =σ(F ω (f ω )), where σ is the s function, g h and g ω is the attention weight; The output Y of the coordinate attention module is obtained, expressed as:
6. The method for identifying tea pests and diseases according to claim 1, characterized in that: The Wise-IoU v2 loss function is based on the monotonic focusing mechanism and introduces L IoU The mean of is used as the normalization factor, and its gradient changes to: The gradient gain is:
7. The method for identifying tea pests and diseases according to claim 1, characterized in that: The tea leaf image is obtained by preprocessing the original image, and the preprocessing original image includes: Open the original image and adjust the image size and format to obtain an input image; Rotate the input image to obtain extended images at different angles and perform image enhancement, wherein the image enhancement includes brightness and contrast adjustment and Gaussian blur; The enhanced image is saved according to a specific naming rule to obtain a structured data set, wherein the data set includes a plurality of the tea leaves images.
Citation Information
Cited By
Grain pile surface pest detection model training method, detection method and equipment
CN121074541A