A tea disease detection method and system based on improved YOLOv11
By improving the YOLOv11 model and integrating stochastic multi-scale pooling attention mechanism and data augmentation technology in tea disease detection, the adaptability and computational efficiency of tea disease identification models in complex backgrounds were solved, achieving high-precision and low-cost real-time detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI POLYTECHNIC UNIV MECHANICAL & ELECTRICAL COLLEGE
- Filing Date
- 2026-05-14
- Publication Date
- 2026-07-21
AI Technical Summary
Existing tea disease identification models are not adaptable enough to natural tea garden scenarios. The difficulty of extracting disease features increases under complex backgrounds. In addition, the models have a large number of parameters and run slowly, making them unsuitable for deployment on mobile terminals and drones in tea gardens.
An improved tea disease detection method based on YOLOv11 was adopted. By integrating a random multi-scale pooling attention mechanism at the end of the second branch of the C3k2 module, an attention map was generated and the features were reweighted. Combined with adaptive anchor box clustering, cosine annealing strategy and data augmentation technology, the target detection model was optimized.
It improves the ability to distinguish diseased areas in complex backgrounds, reduces the false detection rate, reduces the amount of computation, meets the real-time detection needs of mobile devices, and improves detection accuracy and speed.
Smart Images

Figure CN122435461A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition and machine learning, and in particular relates to a method and system for detecting tea diseases based on an improved YOLOv11. Background Technology
[0002] Tea leaves are highly susceptible to diseases during their growth, which can reduce yield, damage quality, and increase prevention and control costs. Traditional tea disease identification mainly relies on manual experience, but different diseases exhibit significant differences at different stages of development, and some disease lesions are fine and scattered. Manual identification often suffers from strong subjectivity, high misjudgment rate, high risk of missed diagnosis, and untimely response, making it difficult to meet the needs of modern agricultural precision management.
[0003] In recent years, with the development of deep learning and computer vision technologies, crop disease identification models have emerged continuously. For example, methods based on CNN, Faster R-CNN, and SSD have improved the accuracy of disease identification to some extent. However, most existing studies are based on single background and single leaf images, lacking adaptability to the complex backgrounds in natural tea garden scenes. In real tea garden environments, acquired images often contain interference factors such as background weeds, branches, and withered leaves; overlapping and occlusion of multiple leaves; changes in lighting; and the influence of shadow textures, making small lesions easy to overlook. These factors directly increase the difficulty of disease feature extraction, causing traditional models to significantly deteriorate in real-world scenarios. In addition, existing high-precision models usually have a large number of parameters and slow running speed, which is not conducive to deployment in tea garden mobile terminals, drones, harvesting robots, and other equipment.
[0004] Therefore, this invention designs a method and system for detecting tea diseases based on the improved YOLOv11. Summary of the Invention
[0005] The purpose of this invention is to solve the problems in the prior art and to propose a tea disease detection method based on an improved YOLOv11.
[0006] This invention first discloses a method for detecting tea diseases based on an improved YOLOv11, comprising the following steps: Acquire an image of the tea leaves to be detected; The tea leaf image is input into a pre-trained target detection model, which is built based on the YOLOv11 framework and includes at least a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module, which processes the input feature map in the following manner: Receive input feature map F; Perform a first convolution operation on the input feature map F to obtain the first branch feature. ; For the first branch feature Perform the second convolution operation to obtain the intermediate features of the second branch. ; The middle feature of the second branch The input is fed into a randomized multi-scale pooling attention mechanism, which is used to: Multiple pooling operations at different spatial scales are performed, and attention maps are generated from the pooling results using random sampling. These attention maps are then used to... Element-wise feature reweighting is performed to obtain enhanced second-branch features. ; The first branch feature With the enhanced second branch feature The output features of the C3k2_attention module are obtained by concatenating the features. ; The neck network performs cross-scale fusion of the multi-scale features output by the backbone network, and the detection head outputs the category and location information of tea diseases based on the fused features.
[0007] In the above method, the random multi-scale pooling attention mechanism generates the attention map in the following manner: For input features Pooling operations of three scales—1×1, 2×2, and 3×3—were used to obtain pooling outputs of three different scales. , and Represented as:
[0008]
[0009]
[0010] Through correlation probability distribution The attention map is obtained by randomly selecting and weighting the three pooling outputs:
[0011] in, This corresponds to three different output scales; Representing the Seed pooling method; It is the first The association probability of the pooling results of each scale, and satisfying:
[0012]
[0013] The input features are reweighted using the attention map:
[0014] in, This indicates element-wise weighting.
[0015] In the above method, the C3k2_attention module is used to replace one or more C3k2 modules in the original YOLOv11 backbone network; The YOLOv11 original backbone network includes multiple C3k2 modules connected in sequence, each C3k2 module having multiple input channels and multiple output channels; When the C3k2 attention module is replaced, its number of input channels and output channels remain consistent with those of the original C3k2 module being replaced, in order to ensure the continuity of feature dimensions in the backbone network.
[0016] In the above method, the training process of the target detection model includes: using an adaptive anchor box clustering algorithm to determine the prior anchor box size; using a cosine annealing strategy to adjust the learning rate; and using Mosaic data augmentation and MixUp data augmentation to perform online enhancement on the training images.
[0017] In the above method, the loss function of the target detection model is:
[0018] in The generalized intersection-union loss is used to address the gradient vanishing problem caused by inconsistent bounding box overlap, and it is defined as follows:
[0019] Using BCE loss, it is defined as:
[0020] The BCE loss form is used to supervise whether the model has detected the target region.
[0021] Secondly, the present invention provides a tea disease detection system based on an improved YOLOv11, used to implement the above method, comprising: The image acquisition module is used to acquire images of the tea leaves to be detected. The model storage module is used to store pre-trained object detection models, which are built based on the YOLOv11 framework and include a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module, which is configured as follows: Receive input feature map F; Perform a first convolution operation on the input feature map F to obtain the first branch feature. ; For the first branch feature Perform the second convolution operation to obtain the intermediate features of the second branch. ; The middle feature of the second branch The input is fed into a stochastic multi-scale pooling attention mechanism, which generates an attention map through stochastic multi-scale pooling and then processes it. By reweighting the features, we obtain the enhanced second-branch features. ; The first branch feature With the enhanced second branch feature Output after splicing.
[0022] The detection execution module is used to input the tea image into the target detection model and obtain the tea disease category and location information output by the detection head.
[0023] In the above system, the random multi-scale pooling attention mechanism specifically adopts the Monte Carlo attention mechanism, whose pooling scales include 1×1, 2×2 and 3×3, and the multi-scale pooling results are randomly combined by a probability distribution that satisfies the normalization and mutual exclusion conditions.
[0024] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method.
[0025] Fourthly, the present invention provides an electronic device, comprising: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it causes the at least one processor to perform the above-described method.
[0026] The beneficial effects of this invention are as follows: 1. This application integrates a random multi-scale pooling attention mechanism at the end of the second branch of the C3k2 module in YOLOv11, forming a dual-path concatenation structure in which the first branch retains the original convolutional features and the second branch is reweighted by attention. Compared with mechanisms such as SE and CBAM that only add attention at the output of the module or use global average pooling, this scheme enables the model to obtain both undisturbed low-level detail features and cross-scale enhanced semantic features. In particular, for lesions of small pixels and weak texture regions with blurred edges, the feature response intensity is improved and the false negative rate of small targets is reduced.
[0027] 2. This application utilizes random multi-scale pooling to generate attention maps and achieves random sampling of scales through probabilistic conditions, enabling the model to adaptively learn the contribution weights of pooling at different scales during training. Compared with the attention mechanism of fixed single-scale pooling, it has a stronger ability to distinguish interferences such as leaf overlap, light and shadow, and background weeds. In the complex background of natural tea gardens, the distinction between diseased areas and background is improved, and the false detection rate is reduced.
[0028] 3. This application embeds the attention mechanism only at the end of the second branch of the C3k2 module, rather than stacking it throughout the entire network. Compared to schemes that directly connect multiple attention modules or introduce additional detection layers, the increased computational load and number of parameters in the backbone network are controlled within 15% of the original C3k2 module, resulting in higher inference speed, meeting the real-time detection requirements of mobile and edge devices, and lower deployment costs. Attached Figure Description
[0029] Fig. 1 This is a flowchart of a tea disease detection method based on an improved YOLOv11 disclosed in this invention.
[0030] Fig. 2 This is a structural diagram of the Monte Carlo attention mechanism used in this invention.
[0031] Fig. 3 This is a structural design diagram of the C3k2_ module in a tea disease detection method based on an improved YOLOv11 disclosed in this invention. Detailed Implementation
[0032] To facilitate understanding of this application and to make the aforementioned objectives, features, and advantages of this application more apparent, a detailed description of specific embodiments of this application is provided below in conjunction with the accompanying drawings. Numerous specific details are set forth in the following description to provide a thorough understanding of this application, and preferred embodiments are shown in the accompanying drawings. However, this application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of this application. This application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. In the description of this application, "several" means at least one, such as one, two, etc., unless otherwise explicitly specified. It should be noted that when an element is referred to as being "fixed to" another element, it can be directly attached to the other element or there may be an intervening element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "left," "right," and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementations. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is only for describing particular implementations and is not intended to limit the scope of this application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0033] Reference Figs. 1-3 This invention discloses a method for detecting tea diseases based on an improved YOLOv11, comprising the following steps: S1: Obtain the image of the tea leaves to be detected, and then input the image into a pre-trained object detection model. This object detection model is built on the YOLOv11 framework and includes at least a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module. The C3k2 attention module processes the input feature map in the following manner: Receive the input feature map F, perform the first convolution operation on F to obtain the first branch feature F1; Perform a second convolution operation on the first branch feature F1 to obtain the second branch intermediate feature F2; F2 is input into a stochastic multi-scale pooling attention mechanism, which performs pooling on F2 at multiple different spatial scales. An attention map is generated from the pooling results using random sampling, and this attention map is used to reweight F2 element-wise to obtain the enhanced second-branch features. ; Combine the first branch feature F1 with the enhanced second branch feature The features are concatenated to obtain the output features of the C3k2_attention module.
[0034] Subsequently, the neck network performs cross-scale fusion of the multi-scale features output by the backbone network. The detection head outputs the category and location information of tea diseases based on the fused features. In actual implementation, it is first necessary to construct a YOLOv11 network structure that includes the aforementioned C3k2_attention module. In this embodiment, a deep learning framework is used for construction. For an input tea image, the model passes through each convolutional layer of the backbone network and the C3k2_attention module in the forward propagation order. Within each C3k2_attention module, the input feature F is first copied into two branches: branch one passes through a convolutional layer to obtain F1, and branch two first passes through a convolutional layer to obtain intermediate features, and then passes through a second convolutional layer to obtain F2. Then, F2 is fed into a random multi-scale pooling attention mechanism for feature enhancement to obtain the enhanced second branch feature. Finally, F1 and the enhanced The core of this approach, which stitches the output along the channel dimension, lies in the fact that the attention mechanism only applies to the end of the second branch, rather than the entire module's output. This enhances the response to small lesions and weakly textured regions while avoiding excessive parameter increases. Compared to directly applying attention to the module's output, this scheme preserves an unperturbed original feature path F1, allowing the module to simultaneously transmit unfiltered low-level detail information and attention-enhanced semantic information. These complementary elements facilitate stable detection of small-scale diseases in complex backgrounds. This improves the model's accuracy in detecting small lesions, blurred-edge diseases, and background-affected areas in tea images without significantly increasing computational burden, making it suitable for real-time detection tasks in natural tea garden scenarios.
[0035] Furthermore, in a preferred embodiment, the above-mentioned random multi-scale pooling attention mechanism is specifically defined. Specifically, this attention mechanism generates an attention map as follows: for the input feature x, pooling operations of three scales—1×1, 2×2, and 3×3—are applied respectively to obtain pooling outputs of three different scales. 、 , is represented as:
[0036]
[0037]
[0038] Then through the correlation probability distribution By randomly selecting and weighting the three pooling outputs, we obtain the attention map:
[0039] in, This corresponds to three different output scales; Representing the Seed pooling method; It is the first The association probability of the pooling results of each scale, and satisfying:
[0040]
[0041] Finally, the attention map is used to reweight the input features:
[0042] in, This indicates element-wise weighting.
[0043] In implementation, the attention mechanism is inserted as a separate module at the end of the second branch of the C3k2 module. For the intermediate feature F2 of the input second branch, three average pooling or max pooling operations at different scales are first performed in parallel to obtain global or local descriptors at three scales. Then, a small fully connected network or convolutional layer is used to calculate the probability of each pooling result being selected. This probability distribution satisfies the normalization condition (summing to 1) and at least one scale has a probability of zero, ensuring that the actual calculation during each forward propagation involves a combination of scales that are not all scales. This random sampling method allows the model to implicitly learn the importance of pooling at different scales for the current disease feature during training, thereby obtaining scale-insensitive representation capabilities. Compared to the traditional channel attention method that only uses a single global average pooling, this attention mechanism can capture both local details and global context simultaneously. Furthermore, random sampling avoids overfitting to a fixed scale, making it suitable for mixed scenarios in tea diseases that include both large-area lesions and ultra-small dot-like lesions.
[0044] Furthermore, the specific deployment method of the C3k2 attention module in the backbone network is described in detail. The C3k2 attention module mentioned in this solution is used to replace one or more C3k2 modules in the original YOLOv11 backbone network. The original YOLOv11 backbone network includes multiple C3k2 modules connected in sequence, each with a specific number of input and output channels. During replacement, the number of input and output channels of the C3k2 attention module must be consistent with the number of input and output channels of the replaced original C3k2 module to ensure the continuity of feature dimensions in the backbone network. There is at least one C3k2 attention module. When there are multiple modules, they are connected in sequence in the backbone network. In actual implementation, designers can select which layers of C3k2 modules to replace based on the accuracy and speed requirements of target detection. For example, replacing only the deep C3k2 modules allows for greater focus on semantic information, while replacing shallow modules is more beneficial for preserving details of small targets. A typical configuration is to replace the 2nd, 4th, and 6th C3k2 modules in the backbone network, as the feature map sizes at these locations are moderate, preserving both sufficient spatial resolution and a certain level of semantic abstraction. The replacement operation simply requires changing the original C3k2 class name to C3k2_attention module class name in the model definition file, ensuring that the input channel parameters are the same. This provides a flexible module replacement strategy, allowing users to select different numbers of attention enhancement modules based on actual hardware resources and detection needs, achieving a balance between accuracy and speed. Simultaneously, since the number of channels remains unchanged, the entire backbone network can reuse YOLOv11 pre-trained weights, thereby accelerating model convergence.
[0045] In another preferred embodiment, the training strategy for the object detection model is defined. The training process includes: determining the prior anchor box size using an adaptive anchor box clustering algorithm; adjusting the learning rate using a cosine annealing strategy; and performing online enhancement of the training images using Mosaic data augmentation and MixUp data augmentation. The implementation steps are as follows: Adaptive anchor box clustering (k-means + IoU distance) includes the following steps: 1. Data extraction: Extract the width (w) and height (h) of all ground truth bounding boxes from the training set annotation file.
[0046] 2. Define the distance function: Standard K-means uses Euclidean distance, which is sensitive to size and unsuitable for box clustering. The core approach is to use IoU distance instead, focusing on the degree of overlap between two boxes, regardless of their specific pixel values.
[0047] 3. Perform clustering: Use the K-means algorithm to cluster all (w, h) data extracted in the previous step. YOLOv11 usually clusters into 9 anchor boxes. The value of k can be adjusted according to the complexity of the task.
[0048] 4. Generation and Application: The algorithm outputs k cluster centers, i.e., "custom anchor boxes". These are sorted by area from smallest to largest, and the anchors parameter in the YOLOv11 configuration file (.yaml) is directly replaced. Adaptive anchor box clustering (k-means + IoU distance) can improve the detection box matching accuracy; The cosine annealing learning rate strategy includes the following implementation steps: 1. Warm-up: In the first few epochs of training, the learning rate starts from a very small value and increases linearly to the set initial learning rate (e.g., lr0=0.01).
[0049] 2. Cosine annealing scheduling: After the warm-up is complete, the learning rate will smoothly decrease from the initial value to the minimum value (usually 0) according to the curve of the cosine function.
[0050] 3. Periodic Restart (Optional): After one period, the learning rate can be reset, and a new cosine annealing process can begin. The cosine annealing learning rate strategy can improve convergence stability; The Mosaic + MixUp combination enhancement includes the following specific implementation steps: 1. Mosaic Enhancement: In each iteration, four images are randomly selected from the dataset, and then they are randomly scaled, cropped, and rearranged to create a new, larger image.
[0051] 2. MixUp Augmentation: Randomly select two images and linearly overlay them pixel-wise using a weight coefficient λ that follows a Beta distribution. Simultaneously, their corresponding labels (bounding boxes and categories) are merged using the same λ. Data augmentation is key to improving the model's generalization ability.
[0052] The results are as follows: In the task of detecting tea diseases, the improved model used in this invention, compared with the YOLOv11 model, has improved precision by 6.6%, recall by 0.8%, F1-score by 3.5%, and mAP@0.5 by 3.5%.
[0053] Furthermore, in a specific loss function configuration, the loss function of the object detection model is defined as:
[0054] Wherein, λ1 is the total weight of the bounding box loss, with a default value of 7.5, and the supervised object is the position and size of the predicted bounding box, i.e., the regression task. λ2 is the weight of the classification loss, with a default value of 0.5, and the supervised object is the category of the object within the bounding box. λ3 is the weight of the confidence loss, with a default value of 1.0, and the supervised object is whether an object exists within the predicted bounding box (Objectness). The generalized intersection-union loss is used to address the gradient vanishing problem caused by inconsistent bounding box overlap, and it is defined as follows:
[0055] Where C is the smallest bounding box, the smallest rectangle (closure box) that can simultaneously contain both the predicted box A and the ground truth box B; U is the union, which is the area of the union of the predicted box A and the ground truth box B; IoU is the intersection-union ratio, which is the area of the intersection of the predicted box and the ground truth box divided by the area of the union.
[0056] Using BCE loss, it is defined as:
[0057] Where: K is the total number of categories, the total number of categories the model needs to classify (e.g., K=80 in the COCO dataset); i: category index, the i-th category among the K categories; These are the real labels, representing whether an object exists in the i-th category (multi-label annotation); It is the predicted probability, which is the probability that the model predicts the existence of the i-th category.
[0058] During implementation: The generalized intersection-comparison loss includes the following specific implementation steps: 1. First, calculate IoU, which is the ratio of the intersection to the union of the predicted bounding box A and the ground truth bounding box B (IoU = |A∩B| / |A∪B|). 2. Calculate the minimum bounding box to find the minimum closure box C that can simultaneously enclose the predicted box A and the ground truth box B.
[0059] 3. Calculate GIoU: GIoU = IoU - |C \ (A∪B)| / |C|, where |C \ (A∪B)| is the area of the blank region in the closure box C that does not belong to the union A∪B.
[0060] 4. Calculate the loss: L_GIoU = 1 - GIoU. The loss value ranges between [0, 2].
[0061] BCE loss includes the following specific implementation steps: 1. Obtaining the predicted probability: The model outputs a raw score (logit) for each category, and then maps this score to the interval [0, 1] using the Sigmoid function to obtain the predicted probability. , =1 / (1+e zi), where z i It is the model's original output for the i-th class.
[0062] 2. Obtain the real tags: y i It is a true annotation in the form of multiple labels. If the image / boundary contains an object of type i, then... =1; otherwise =0. Unlike single-label classification, multiple... Both can be 1.
[0063] 3. Calculate individual losses ( (Represents the individual loss value for the i-th category): For each category i, calculate its loss value. When When =1 (positive sample): = log( );when When =0 (negative samples): = log(1 ).
[0064] 4. Finally, sum the total loss: sum the individual losses of all K categories to obtain the total classification loss of the sample.
[0065] In the generalized intersection-union loss, the original LIoU (Limited Income of Unified Values) results in zero gradients of the loss function with respect to all parameters when the predicted box A and the ground truth box B do not overlap at all. The model cannot move the predicted box using gradient descent. In contrast, LGIoU offers the following advantages: 1. Solved the gradient vanishing problem: Provided non-zero gradients in scenarios where bounding boxes do not overlap, enabling the model to continuously optimize.
[0066] 2. Faster convergence speed: Since the gradient always exists, the model starts optimizing the position of the bounding box from the early stage of training, and can learn reasonable bounding boxes more quickly.
[0067] 3. mAP@0.5:0.95 can improve performance by about 2%, and it works even better for targets that are overlapping or adhered.
[0068] In the BCE loss function, each class is judged independently, allowing a bounding box to belong to multiple classes simultaneously, decoupling the relationship between classes and enabling each class to optimize independently. The gradient is close to 0 when the prediction matches the truth, and larger when the prediction is incorrect, providing an effective optimization signal. On a dense small object dataset, mAP@0.5 is improved by about 3%, and the false detection rate is reduced by more than 20%. When small and large objects coexist, it can effectively improve the recall rate of small object detection. The gradient range of the BCE loss is always between [-1, 1], exhibiting better convergence stability.
[0069] In a scalable application, the above method can also be applied to the detection of other crop diseases or minute lesions in medical images. In practice, simply replace the training data with labeled images from the corresponding domain, while maintaining the same network structure and training process. Since the stochastic multi-scale pooling attention mechanism itself enhances small targets and weakly textured regions, this method can be transferred to any task requiring the detection of small anomalies, exhibiting good domain adaptability. It requires no redesign of the network structure and has high practical value and potential for widespread application.
[0070] Corresponding to the above methods, this solution also provides a tea disease detection system based on an improved YOLOv11. This system includes: The image acquisition module is used to acquire images of the tea leaves to be detected. The model storage module stores a pre-trained object detection model built on the YOLOv11 framework, comprising a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module, configured as follows: Receive the input feature map F, and perform a first convolution on F to obtain the first branch feature F1; Perform a second convolution on the first branch feature F1 to obtain the second branch intermediate feature F2; The F2 value is input into a stochastic multi-scale pooling attention mechanism, which generates an attention map through stochastic multi-scale pooling and reweights the features of F2 to obtain enhanced second-branch features. ; F1 and Output after splicing; The detection execution module is used to input tea leaf images into the target detection model and obtain the tea disease category and location information output by the detection head. When implementing this system, it can be deployed on a mobile terminal with a camera or a tea garden monitoring drone. The image acquisition module calls the camera to acquire images in real time or reads local image files; the model storage module saves the trained model weights and network structure; the detection execution module calls the deep learning inference engine to perform forward computation, and finally draws the detection box on the image and outputs the disease type. This realizes a complete automated process from image input to detection result output, which can replace manual inspection and improve the efficiency and accuracy of tea garden disease monitoring. Moreover, because the model adopts a lightweight attention ensemble method, it can achieve real-time detection speed on edge devices.
[0071] In a preferred system implementation, the above-mentioned random multi-scale pooling attention mechanism specifically adopts the Monte Carlo attention mechanism, whose pooling scales include 1×1, 2×2 and 3×3, and the multi-scale pooling results are randomly combined by a probability distribution that satisfies the normalization and mutual exclusion conditions. This mechanism has been described in detail in the method claims and will not be repeated here.
[0072] During system deployment, this attention mechanism is embedded in the model structure as an internal submodule of the C3k2_attention module. During system runtime, for each input image, the attention mechanism adaptively selects the most favorable pooling scale combination based on the trained probability distribution parameters, thereby generating the most beneficial attention map for the current diseased area. The Monte Carlo attention mechanism enables effective detection of small targets, and integrating it into the system fully leverages its scale-insensitive characteristics, ensuring stable detection performance across tea leaf images captured at different resolutions and distances.
[0073] Finally, this solution also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the methods described above. It also provides an electronic device comprising at least one processor and a memory communicatively connected to the processor, the memory storing a computer program executable by the at least one processor, which, when executed by the processor, causes the processor to perform any of the methods described above. In practical implementation, the storage medium can be any medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory, random access memory, magnetic disk, or optical disk. The electronic device can be a smartphone, tablet computer, embedded industrial control computer, server, or drone flight control board, etc. When the program is loaded and executed, the device can perform defect detection on the input tea leaf image according to the method of this solution.
[0074] As is known from common technical knowledge, this invention can be implemented through other embodiments that do not depart from its spirit or essential characteristics. Therefore, the disclosed embodiments described above are merely illustrative and not exhaustive. All modifications within the scope of this invention or its equivalents are included in this invention.
Claims
1. A method for detecting tea diseases based on an improved YOLOv11, characterized in that, Includes the following steps: Acquire an image of the tea leaves to be detected; The tea leaf image is input into a pre-trained target detection model, which is built based on the YOLOv11 framework and includes at least a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module, which processes the input feature map in the following manner: Receive input feature map F; Perform a first convolution operation on the input feature map F to obtain the first branch feature. ; For the first branch feature Perform the second convolution operation to obtain the intermediate features of the second branch. ; The middle feature of the second branch The input is fed into a randomized multi-scale pooling attention mechanism, which is used to: Multiple pooling operations at different spatial scales are performed, and attention maps are generated from the pooling results using random sampling. These attention maps are then used to... Element-wise feature reweighting is performed to obtain enhanced second-branch features. ; The first branch feature With the enhanced second branch feature The output features of the C3k2_attention module are obtained by concatenating the features. ; The neck network performs cross-scale fusion of the multi-scale features output by the backbone network, and the detection head outputs the category and location information of tea diseases based on the fused features.
2. The tea disease detection method based on the improved YOLOv11 according to claim 1, characterized in that, The random multi-scale pooling attention mechanism generates the attention map in the following manner: For input features Pooling operations of three scales—1×1, 2×2, and 3×3—were used to obtain pooling outputs of three different scales. , and Represented as: Through correlation probability distribution The attention map is obtained by randomly selecting and weighting the three pooling outputs: in, This corresponds to three different output scales; Representing the Seed pooling method; It is the first The association probability of the pooling results of each scale, and satisfying: The input features are reweighted using the attention map: in, This indicates element-wise weighting.
3. The tea disease detection method based on the improved YOLOv11 according to claim 1, characterized in that, The C3k2_attention module is used to replace one or more C3k2 modules in the original YOLOv11 backbone network; The YOLOv11 original backbone network includes multiple C3k2 modules connected in sequence, each C3k2 module having multiple input channels and multiple output channels; When the C3k2 attention module is replaced, its number of input channels and output channels remain consistent with those of the original C3k2 module being replaced, in order to ensure the continuity of feature dimensions in the backbone network.
4. The tea disease detection method based on the improved YOLOv11 according to claim 1, characterized in that, The training process of the target detection model includes: using an adaptive anchor box clustering algorithm to determine the prior anchor box size; using a cosine annealing strategy to adjust the learning rate; and using Mosaic data augmentation and MixUp data augmentation to perform online enhancement on the training images.
5. The tea disease detection method based on the improved YOLOv11 according to claim 1, characterized in that, The loss function of the target detection model is: in, The total weight is the border loss. For classification loss weights, For confidence loss weights, The generalized intersection-union loss is used to address the gradient vanishing problem caused by inconsistent bounding box overlap, and it is defined as follows: Where: C is the smallest bounding box, which is the smallest rectangle that can simultaneously contain the predicted box A and the ground truth box B; U is the union, which contains the area of the union of the predicted box A and the ground truth box B; and IoU is the intersection-union ratio, which is the area of the intersection of the predicted box and the ground truth box divided by the area of the union. Using the BCE loss form, it is defined as: K is the total number of categories, i is the category index, and we iterate through the i-th category out of the K categories. Given the true label, does the i-th category contain an object? To predict probabilities, the model predicts the probability of the i-th category existing; The BCE loss form is used to supervise whether the model has detected the target region.
6. A tea disease detection system based on an improved YOLOv11, characterized in that, For implementing any one of the methods as claimed in claims 1 to 5, comprising: The image acquisition module is used to acquire images of the tea leaves to be detected. The model storage module is used to store pre-trained object detection models, which are built based on the YOLOv11 framework and include a backbone network, a neck network, and a detection head. The backbone network includes at least one C3k2 attention module, which is configured as follows: Receive input feature map F; Perform a first convolution operation on the input feature map F to obtain the first branch feature. ; For the first branch feature Perform the second convolution operation to obtain the intermediate features of the second branch. ; The middle feature of the second branch The input is fed into a stochastic multi-scale pooling attention mechanism, which generates an attention map through stochastic multi-scale pooling and then processes it. By reweighting the features, we obtain the enhanced second-branch features. ; The first branch feature With the enhanced second branch feature Output after splicing. The detection execution module is used to input the tea image into the target detection model and obtain the tea disease category and location information output by the detection head.
7. The system according to claim 6, characterized in that, The random multi-scale pooling attention mechanism specifically adopts the Monte Carlo attention mechanism, with pooling scales including 1×1, 2×2, and 3×3, and randomly combines the multi-scale pooling results by using probability distributions that satisfy normalization and mutual exclusion conditions.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 5.
9. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it causes the at least one processor to perform the method according to any one of claims 1 to 5.