Tea disease detection method based on lightweight YOLOv8 model
By using a lightweight YOLOv8 model and an improved data preprocessing method, the problems of high computational complexity and insufficient adaptability of the YOLOv8 model in tea garden pest and disease monitoring were solved, and efficient and accurate tea disease detection on edge devices was achieved.
Patent Information
- Application Number
- CN202510977015.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-07-16
AI Technical Summary
The existing YOLOv8 model has high computational complexity in tea garden pest and disease monitoring, making it difficult to deploy on edge devices. It also lacks adaptability to the diversity of tea diseases and complex environments, especially when there are changes in lighting and occlusion, where detection performance decreases.
A lightweight YOLOv8 model is adopted, combined with the Ghost-CBAM module and the CSPDNet backbone network. The Ghost-CBAM module enhances the attention of the target area, and CSPDNet reduces redundant calculations. Dynamic resolution adaptation and multi-task collaborative optimization are introduced, and data preprocessing methods are improved to enhance the generalization ability of the model in complex environments.
It significantly reduces computing resource consumption, improves small target detection accuracy and the model's generalization ability in complex environments, adapts to the diversity of tea gardens and lighting changes, and achieves faster response speed and higher detection accuracy.
Smart Images

Figure CN120472325B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of tea disease detection, and in particular to a tea disease detection method based on a lightweight YOLOv8 model. Background Art
[0002] Early tea garden pest and disease monitoring mostly still relied on manual inspections, which was not only inefficient and costly, but also had problems such as delayed warning, insufficient coverage, and limited accuracy. It was difficult to meet the actual needs of the modern tea industry for refined management and green prevention and control.
[0003] In recent years, the development of computer vision object detection technology, particularly the YOLO series of models, has gained widespread application in agricultural pest and disease monitoring due to its high efficiency and real-time performance. YOLOv8, the latest generation model, introduces a reversible residual module and a dynamic label assignment strategy, further improving average precision while maintaining a high frame rate, providing a technical foundation for intelligent plant pest and disease detection.
[0004] But the following problems still exist:
[0005] 1. In the actual application of tea garden pest and disease monitoring, although the YOLOv8 model performs well in terms of accuracy, its model complexity still poses a challenge to deployment on edge devices.
[0006] 2. Tea disease spots have high morphological diversity and regional differences. Existing models lack the ability to adapt to such heterogeneous characteristics, resulting in poor generalization performance.
[0007] 3. The ability to extract features of early-stage tiny lesions of tea leaves is reduced, which in turn leads to degradation of detection performance. The reasons for the degradation of detection performance include severe loss of shallow features, quantization error amplifying blurred edge features, and lack of attention mechanism guidance.
[0008] Furthermore, tea gardens are complex and dynamic, with factors such as leaf reflections, dust accumulation, and shadows cast by shade nets interfering with lesion detection. Existing data processing methods often rely on simple geometric transformations (such as rotations and flips), which fail to adequately simulate common lighting noise in agricultural scenes, such as morning dew reflections and dappled shadows. This results in reduced model generalization in real-world environments. Summary of the Invention
[0009] The purpose of the present invention is to overcome the shortcomings of the existing technology and provide a tea disease detection method based on the lightweight YOLOv8 model, which reduces the computational complexity of the model while improving the small target detection accuracy and multi-scene generalization ability.
[0010] The present invention adopts the following technical solutions to achieve the above-mentioned purpose. The present invention provides a tea disease detection method based on a lightweight YOLOv8 model, comprising:
[0011] S1. Collect various types of tea disease images;
[0012] S2. Preprocessing the collected images of various types of tea diseases and marking the diseased areas in the images of different types of tea diseases to obtain a training data set;
[0013] S3. Build a lightweight YOLOv8 model;
[0014] Ghost-CBAM module embeds:
[0015] In the FPN-PAN multi-scale feature fusion network of YOLOv8, the Ghost-CBAM module is used to replace the traditional convolution block;
[0016] The Ghost-CBAM module combines the Ghost module with CBAM. The Ghost module uses cheap linear operations to generate redundant feature maps, while CBAM adaptively emphasizes useful channels and spatial positions through sequential channel attention and spatial attention mechanisms.
[0017] The Ghost-CBAM module adopts a two-stage processing flow. In the first stage, redundant feature representation is constructed through the feature generation layer of the Ghost module. In the second stage, the features are dynamically calibrated through a cascaded channel-spatial attention mechanism. Finally, feature enhancement is achieved by element-wise multiplication of the attention weights with the input features.
[0018] Channel Attention Mechanism:
[0019] For the multi-channel features output by the Ghost module, a dual-path feature compression channel is constructed:
[0020] Channel statistical descriptors are generated through global average pooling and global maximum pooling respectively. After nonlinear mapping by a parameter-sharing multi-layer perceptron, two-way feature fusion is achieved by element-by-element addition. Finally, a channel attention mask is generated through the Sigmoid function.
[0021] Spatial Attention Mechanism:
[0022] Based on the channel-calibrated features, dual-mode compression is performed along the channel dimension, and a local-global spatial correlation model is constructed through the convolution kernel to generate a pixel-level spatial attention distribution map.
[0023] Multi-task collaborative optimization:
[0024] A feature reuse architecture is constructed to feed attention-modulated multi-scale features into both the classification and regression branches. By introducing a gradient sharing mechanism and a joint loss function based on knowledge distillation, the coordinated optimization of target localization accuracy and classification confidence is achieved.
[0025] Backbone network replacement:
[0026] The original YOLOv8 backbone network Darknet was completely replaced with CSPDNet, retaining the three-layer multi-scale feature output structure. DSCBlock modules were embedded in each stage. Deformable convolution kernels were used to enhance spatial deformation modeling capabilities. A channel weighting mechanism was used to replace traditional 1×1 convolutions, achieving lightweight cross-channel information interaction.
[0027] CSPDNet is based on the idea of deformable depthwise separable convolution and cross-stage partial connections. By introducing the DSCBlock module and channel weighting module within each stage, it reduces redundant calculations while enhancing the ability to express deformable and multi-scale objects.
[0028] Cross-stage partial connection fusion:
[0029] Adhering to the native CSP architecture design, the features of each stage are split into a basic path and a DSCBlock module processing path. Through feature splicing and 1×1 convolution fusion strategy, the advantages of shallow texture features and deep semantic features are complemented.
[0030] Dynamic resolution adaptation:
[0031] Dynamically adjust the sampling offset range and channel compression ratio of the deformable convolution in DSCBlock according to the input resolution;
[0032] S4. Use the training dataset to train the lightweight YOLOv8 model;
[0033] S5. Input the collected tea disease images into the trained lightweight YOLOv8 model, and output the tea disease type through the trained lightweight YOLOv8 model.
[0034] Furthermore, in step S1, the tea disease images include tea ring spot images, tea algae spot images, tea white star disease images, tea anthracnose images, and tea sooty disease images.
[0035] Furthermore, step S1 specifically includes:
[0036] Before collecting images, a structured record template is first designed, which contains the collection time, collection location, environmental parameters and collection object status information;
[0037] When collecting images, the collected tea disease images are associated with the information in the corresponding record template, and a two-person on-site verification mechanism is implemented. The first collector collects the records, and the second collector reviews the data collected by the first collector.
[0038] Furthermore, in step S2, the preprocessing includes illumination normalization processing:
[0039] For each pixel value in the tea disease image, the mean and standard deviation of the entire image are calculated and normalized according to the following formula:
[0040] ;
[0041] Where, represents the normalized pixel value, represents the mean of the image, , represents the standard deviation of the image, , Represents the pixel value of the image at the coordinate (x, y), where x represents the horizontal coordinate of the pixel in the image, y represents the vertical coordinate of the pixel in the image, and N is the total number of pixels.
[0042] Furthermore, in step S2, the preprocessing also includes adaptive histogram equalization:
[0043] By dividing the image into several sub-regions, the local histogram is calculated independently in each sub-region and a grayscale mapping function is constructed to enhance the local contrast. For each sub-block, the cumulative distribution function of its grayscale is:
[0044] ;
[0045] Where, Represents the grayscale mapping function calculated for sub-block B, Represents the cumulative distribution of gray levels, L is the total number of gray levels (such as 256), B represents the sub-block, is the gray level in the sub-block The number of pixels, is the total number of pixels in the sub-block, k represents the current gray level;
[0046] The final grayscale value of each pixel is obtained by bilinear interpolation and fusing the mapping results of the four adjacent sub-blocks:
[0047] ;
[0048] Where, ∈[0,1] is the normalized distance weight from the pixel to the center of the adjacent sub-block, 、 、 、 are the four adjacent sub-blocks of sub-block B, represents the gray level, Represents the final grayscale value of each pixel;
[0049] The improved CLAHE imposes a contrast limit on the local histogram: if the number of pixels at a certain gray level exceeds a threshold, the excess is cropped and evenly redistributed to all gray levels. The formula is:
[0050] ;
[0051] Where, represents the number of pixels of the i-th gray level in the original image, represents the number of new pixels of the i-th gray level after CLAHE processing, Indicates the threshold value.
[0052] Furthermore, in step S2, the preprocessing also includes a multi-scale Retinex algorithm:
[0053] The tea disease image is decomposed into reflection component and illumination component, and Gaussian filtering of different scales is used to perform multi-scale estimation of the illumination component as follows:
[0054] Single-scale Retinex:
[0055] The observed image is decomposed into reflection component and illumination component in the logarithmic domain, namely:
[0056] ;
[0057] Where, represents the logarithmic intensity distribution of the observed image, represents the logarithmic intensity distribution of the reflected component, is the Gaussian filter kernel, To control the scale, S(x,y) represents the observed image, R(x,y) represents the reflection component, x represents the horizontal coordinate of the pixel in the image, and y represents the vertical coordinate of the pixel in the image;
[0058] Multi-scale fusion:
[0059] By weighted averaging the Retinex results of multiple different scales, the local contrast and global illumination consistency are balanced, that is:
[0060] ;
[0061] in is the weight, M is the total number of scales, and K is the current scale number.
[0062] Furthermore, in step S2, the preprocessing also includes dynamic Gamma correction:
[0063] Dynamically adjust the Gamma value based on the local or global brightness distribution of the tea disease image as follows:
[0064] Brightness statistics, calculate the average brightness of the global or local area of the image:
[0065] , represents the average brightness, Represents the pixel value of the image at the coordinate (x, y), where x represents the horizontal coordinate of the pixel in the image, y represents the vertical coordinate of the pixel in the image, and N represents the total number of pixels;
[0066] Dynamic Gamma value generation, adaptively generating Gamma value based on statistical average brightness:
[0067] , represents the Gamma value, is the preset maximum value. is the preset minimum value, a and b are linear coefficients, , are the minimum and maximum brightness thresholds respectively;
[0068] Pixel-level correction, applying Gamma transformation to each pixel, or calculating it separately for local areas After interpolation fusion, the Gamma transformation is as follows:
[0069] , Represents the output pixel after Gamma transformation.
[0070] Furthermore, in step S4, during training, the AdamW optimizer is used to set the initial learning rate, and the simulated annealing strategy is used to dynamically adjust the learning rate, and then a period is set to decay the learning rate to a preset target;
[0071] A joint loss function is used to alleviate category imbalance, and regression loss is used to enhance bounding box localization accuracy.
[0072] The beneficial effects of the present invention are:
[0073] By integrating CSPDNet, the model significantly reduces computing resource consumption while maintaining high accuracy, making it more suitable for running on resource-constrained devices.
[0074] The present invention introduces Ghost-CBAM, which enables the model to pay more attention to the target area and effectively improves the detection accuracy of small targets.
[0075] The lightweight design of the model and the optimization of the attention mechanism enable the model to have a faster response speed in real-time target detection tasks.
[0076] The improved model of the present invention shows better generalization ability under different lighting conditions and occlusion situations, and can adapt to more complex practical application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 This is a flow chart of a tea disease detection method based on a lightweight YOLOv8 model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0078] To make the objectives, technical solutions and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0079] The present invention provides a tea disease detection method based on a lightweight YOLOv8 model, comprising:
[0080] S1. Collect various types of tea disease images;
[0081] Tea disease images include tea ring spot images, tea algae spot images, tea white star disease images, tea anthracnose images and tea sooty disease images.
[0082] Tea ring spot is a fungal disease that primarily harms mature and older leaves. It usually occurs in spring under suitable temperature and high humidity conditions, producing conidia that invade through leaf wounds or epidermis. After 7 to 14 days, new lesions form and produce conidia, which are then spread by wind and rain, leading to a second infection. The pathogen is a weak parasite that often infects weak tea trees. High temperature and high humidity favor the occurrence of this disease, which generally occurs severely in summer and autumn. Poor drainage, cutting nurseries, or densely planted tea gardens are prone to the disease when humidity is high. The disease often begins at the tip or margin of the leaves, gradually expanding into large, round, oval, or irregular brown lesions. The lesions on mature and older leaves have distinct concentric rings. In the later stages of the disease, the center of the lesion turns grayish white, and when the humidity is high, small black particles arranged in rings appear, which are the fruiting bodies of the pathogen. When young leaves are infected, they gradually turn dark brown from the tip to the edge. The lesions are irregular and scorched, with small sooty spots scattered on the front and no whorls on the lesions. Multiple lesions often merge together, resulting in most of the leaf being covered with brown spots.
[0083] Tea algal spot is caused by a parasitic green algae and typically only affects weak tea bushes. Because humid environments favor the formation, shedding, spread, and germination of sporangia, it often occurs in shaded, damp tea trees with poor ventilation and light transmission, as well as those experiencing poor growth potential. It primarily affects the middle and lower leaves of older leaves. When infected, yellowish-brown, pinhead-sized circular or cross-shaped spots, measuring 0.5-1.0 mm, appear on both the front and back of leaves. In later stages, the spots become circular or nearly circular, slightly raised, dark brown, and have irregular edges.
[0084] Tea star disease is a fungal disease. Spores form in spring when temperatures exceed 10°C and humidity is moderate. Mature spores germinate from the stomata or base of the hairs, infecting young tissues. New lesions appear after 1-2 days. Small black spots then form at the lesions, producing new spores that are spread by wind and rain for further infection. Tea star disease is a low-temperature, high-humidity disease. High humidity, fog, and low temperatures favor its development. It primarily affects young leaves and new shoots of tea plants. In the early stages, the lesions appear as small, pinhead-sized brown spots, gradually expanding into circular lesions 0.3-1.0 mm in diameter, reaching a maximum diameter of 2 mm. The lesions have dark purple-brown edges, with gray-brown to off-white centers and scattered black spots. A yellow halo surrounds the lesions, forming a black eye-like appearance, and sometimes cracks form in the center, forming a hole. In severe cases, multiple lesions on the same leaf can fuse together to form a large lesion, causing extensive leaf drop.
[0085] Tea anthracnose is a fungal disease that begins in spring when temperatures rise and humidity is favorable, causing conidia to form on leaf lesions. These conidia are spread by wind and rain, invading leaf tissue from the base of the hairs on the underside of the leaf. It typically takes 8 to 14 days for the conidia to attach to the hairs, for small, round lesions to appear on the leaf surface, and 15 to 30 days for large, reddish-brown patches to form. Therefore, the anthracnose pathogen has a long incubation period, typically invading young leaves and only showing symptoms in mature leaves. Temperature and humidity are the most important climatic factors influencing anthracnose's development. Heavy rainfall during the transition between spring and summer and autumn results in more severe anthracnose. Tea anthracnose primarily occurs on mature leaves, but occasionally on older and younger leaves. Lesions typically develop on leaf margins or tips. Initially, they appear dark green and water-soaked. They often spread and expand along the veins, turning brown or reddish-brown, and later, grayish-white. The lesions vary in size, but generally appear as large, reddish-brown spots near the petiole, sometimes extending over half the leaf. They have yellowish-brown raised lines along their edges, clearly demarcating them from healthy areas. Numerous small, black, protruding dots, representing the conidiophores of the pathogen, may be scattered on the surface. Tea leaves infected with anthracnose become brittle, easily broken, and prone to falling off. Severe cases can cause extensive leaf drop.
[0086] Tea sooty disease is a fungal disease. The pathogens of tea sooty disease are a large group, primarily belonging to the Ascomycota and Deuteromycota subdivisions. They can be divided into parasitic and saprophytic types. Parasitic sooty disease pathogens have a narrow host range, invading tea leaves and stems, obtaining nutrition directly from the plant. Saprophytic sooty disease pathogens have a wider host range, primarily deriving nutrition from the honeydew secreted by clams, whiteflies, and aphids that damage tea plants. They do not invade the interior of tea plants and are epiphytic microorganisms. Poorly managed tea gardens, shaded and damp, often lead to severe infestations of clams and whiteflies, which favor the development of tea sooty disease. Tea sooty disease occurs on tea branches and leaves, primarily on the leaves. Initial symptoms include small, black, circular or irregular spots on the upper surface of the leaves. These spots gradually expand, eventually covering the entire leaf surface in severe cases. In some species, the black mold layer on the leaf surface can be peeled or wiped off. Sooty disease is generally confined to the lower and middle parts of the tea leaves, but in severe cases, it can spread from there to the crown surface. Sooty disease is often caused by pests such as clams, whiteflies, and maggots.
[0087] For the above-mentioned tea disease image collection, we first designed a structured record template, which includes fields such as time (accurate to the minute), location, environmental parameters (preset lighting, temperature and humidity options), and image subject status. Images are captured using a mobile phone, camera, or camcorder, and fixed naming rules (such as "20250305_1430_sample x_young leaves without damage.jpg") are used to achieve data-image association.
[0088] During image collection, a two-person on-site verification mechanism is implemented: Collector A collects and records the data, while Collector B reviews the data for plausibility, marks any abnormal data, and records the reasons. Logical verification rules (such as temperature and humidity threshold alarms and temporal continuity detection) are also implemented to prevent obvious errors. Finally, data diversity is introduced through balanced collection over multiple time periods (morning, noon, and evening), artificially simulated interference (angle offset, partial occlusion), and multi-state labeling (normal, insect bite, withered). Combined with metadata version control (recording the person who modified the data, when, and why) and Excel index table management, this provides a high-generalization foundation for subsequent model training.
[0089] S2. Preprocessing the collected images of various types of tea diseases and marking the diseased areas in the images of different types of tea diseases to obtain a training data set;
[0090] Uneven illumination, a key interfering factor in computer vision, significantly impacts image color reproduction and detail representation. In agricultural scenarios, dynamic changes in field lighting conditions (such as cloud cover, equipment shadows, and multi-angle solar radiation) can lead to regional color casts (e.g., yellowing or whitish appearance of green vegetation), local contrast distortion (loss of detail in dark areas or overexposure in bright areas), and texture degradation. This, in turn, impacts the robustness of algorithms used for subsequent object detection, disease identification, and yield prediction.
[0091] Illumination normalization aims to eliminate the effects of varying lighting conditions in an image, ensuring that images in different environments have a consistent brightness distribution, thereby improving the robustness of subsequent tasks. Its core principle is to adjust the statistical properties of the image, typically normalizing pixel values to zero mean and unit variance. Specifically, for each pixel value in the image, the mean and standard deviation of the entire image are calculated and normalized according to the following formula:
[0092] ;
[0093] Where, represents the normalized pixel value, represents the mean of the image, , represents the standard deviation of the image, , Represents the pixel value of the image at the coordinate (x, y), where x represents the horizontal coordinate of the pixel in the image, y represents the vertical coordinate of the pixel in the image, and N is the total number of pixels.
[0094] This illumination normalization method assumes that illumination variations are linear and mitigates their effects through global normalization. For color images, it can be performed independently between channels or by converting to a brightness-dependent color space (such as YUV) and processing only the brightness component.
[0095] Geometric enhancement in data augmentation changes the geometric structure of an image or target through spatial transformation to simulate the diversity of object poses, perspectives, and scales in real scenes, improving the model's adaptability to deformation, occlusion, and position changes. Its core principle is to apply affine or nonlinear transformations (such as rotation, translation, scaling, flipping, cropping, affine distortion, etc.) to the image while simultaneously adjusting the corresponding annotation information. Translation transformation can be expressed as:
[0096] ;
[0097] Where x and y are the original coordinates, is the translation amount, 、 is the coordinate after translation. Flipping can be done by horizontal mirroring ( For image width). Scaling adjusts the target size by the scale factor s ,This type of operation generates diverse training samples through random parameter combinations,,forcing the model to learn geometric invariant features,,alleviate overfitting and enhance generalization.
[0098] During the illumination enhancement stage, a technology chain for illumination robustness enhancement is designed: first, adaptive histogram equalization is used to enhance the contrast difference between diseased areas and healthy tissues. Then, the multi-scale Retinex algorithm is used to decompose the incident light and reflected light components to achieve detail enhancement and color consistency correction in low-illuminance areas. Dynamic gamma correction is used to compensate for nonlinear brightness distribution.
[0099] Adaptive Histogram Equalization (AHE) divides the image into several sub-regions (such as blocks of size M×M), independently calculates the local histogram in each sub-region and constructs a grayscale mapping function to enhance local contrast. Specifically, for each sub-block B, the cumulative distribution function of its grayscale level is:
[0100] ;
[0101] Where, Represents the grayscale mapping function calculated for sub-block B, Represents the cumulative distribution of gray levels, L is the total number of gray levels (such as 256), B represents the sub-block, is the gray level in the sub-block The number of pixels, is the total number of pixels in the sub-block, k represents the current gray level;
[0102] To avoid discontinuity between blocks, the final grayscale value of each pixel is obtained by fusing the mapping results of the four adjacent sub-blocks through bilinear interpolation:
[0103] ;
[0104] Where, ∈[0,1] is the normalized distance weight from the pixel to the center of the adjacent sub-block, 、 、 、 are the four adjacent sub-blocks of sub-block B, represents the gray level, Represents the final grayscale value of each pixel;
[0105] The improved CLAHE (Contrast Limited Adaptive Histogram Equalization) imposes contrast limits on local histograms:
[0106] If the number of pixels at a certain gray level exceeds the threshold, the excess is cropped and evenly redistributed to all gray levels. The formula is:
[0107] ;
[0108] Where, represents the number of pixels of the i-th gray level in the original image, represents the number of new pixels of the i-th gray level after CLAHE processing, Indicates the threshold value.
[0109] Adaptive histogram equalization can enhance local details while suppressing noise, and is suitable for image enhancement with uneven illumination or complex texture.
[0110] The multi-scale Retinex algorithm is based on the Retinex theory. By simulating the color constancy of the human visual system, it decomposes the image into a reflectance component (intrinsic properties of the object) and an illumination component (ambient lighting). It then uses Gaussian filters of different scales to perform multi-scale estimation of the illumination component, and finally fuses them to enhance image details and color fidelity. The method is as follows:
[0111] Single-scale Retinex:
[0112] The observed image is decomposed into reflection component and illumination component in the logarithmic domain, namely:
[0113] ;
[0114] Where, represents the logarithmic intensity distribution of the observed image, represents the logarithmic intensity distribution of the reflected component, is the Gaussian filter kernel, To control the scale, S(x,y) represents the observed image and R(x,y) represents the reflected component;
[0115] Multi-scale fusion:
[0116] By weighted averaging the Retinex results of multiple different scales, the local contrast and global illumination consistency are balanced, that is:
[0117] ;
[0118] Where M is the total number of scales, K is the current scale number, Represents the coordinates of the processed image, is the weight (usually ), typically choose 3 scales (such as: ).
[0119] Dynamic Gamma Correction is an adaptive brightness enhancement technology. Its core idea is to dynamically adjust the Gamma value based on the local or global brightness distribution of the image, using nonlinear mapping to enhance dark area details while avoiding overexposure in bright areas. Its principles can be summarized as follows:
[0120] Brightness statistics, calculate the average brightness of an image or local area:
[0121] , Indicates the average brightness;
[0122] Dynamic Gamma value generation, adaptively generating Gamma value based on statistical average brightness:
[0123] , represents the Gamma value, is the preset maximum value. is the preset minimum value, a and b are linear coefficients, , are the minimum and maximum brightness thresholds respectively;
[0124] Pixel-level correction, applying Gamma transformation to each pixel, or calculating it separately for local areas Post-interpolation fusion avoids blocking artifacts. The gamma correction algorithm can effectively enhance low-light images and has high computational efficiency in hardware implementation.
[0125] The Gamma transformation is as follows:
[0126] , Represents the output pixel after Gamma transformation.
[0127] Image noise removal:
[0128] Image noise removal is achieved by modeling the noise distribution and designing filtering algorithms to suppress interfering signals. Common methods include spatial domain filtering (such as Gaussian filtering to smooth noise) and frequency domain filtering (such as wavelet thresholding to separate high-frequency noise). Take Gaussian filtering and median filtering as examples:
[0129] Gaussian filtering uses a two-dimensional Gaussian kernel Convolve the image to reduce noise:
[0130] ;
[0131] The kernel size and standard deviation Controls the smoothing strength, large Results in stronger blur and possible loss of detail.
[0132] Median filtering targets salt and pepper noise and eliminates outliers by taking the median of the neighborhood. Sort the pixels in the window and take the median value:
[0133] ;
[0134] Its advantage is that it preserves edge sharpness, but its effect on large-area continuous noise is limited.
[0135] S3. Build a lightweight YOLOv8 model;
[0136] Ghost-CBAM module embeds:
[0137] In the FPN-PAN multi-scale feature fusion network of YOLOv8, the Ghost-CBAM module is used to replace the traditional convolution block;
[0138] The Ghost-CBAM module combines the Ghost module with the CBAM. The Ghost module uses inexpensive linear operations to generate redundant feature maps, while the CBAM adaptively emphasizes useful channels and spatial locations through sequential channel attention and spatial attention mechanisms. This fusion of the two not only obtains sufficient features with fewer parameters, but also focuses on small objects and their key areas, making it ideal for detecting small objects in tea plant diseases and pests.
[0139] The Ghost-CBAM module adopts a two-stage processing flow. In the first stage, redundant feature representation is constructed through the feature generation layer of the Ghost module. In the second stage, the features are dynamically calibrated through a cascaded channel-spatial attention mechanism. Finally, feature enhancement is achieved by element-wise multiplication of the attention weights with the input features.
[0140] Channel Attention Mechanism:
[0141] For the multi-channel features output by the Ghost module, a dual-path feature compression channel is constructed:
[0142] Channel statistical descriptors are generated respectively through global average pooling and global maximum pooling. After nonlinear mapping by a parameter-sharing multi-layer perceptron, two-way feature fusion is achieved by element-by-element addition, and finally a channel attention mask is generated through the Sigmoid function.
[0143] Spatial Attention Mechanism:
[0144] Based on the features after channel calibration, dual-mode compression is performed along the channel dimension, and a local-global spatial association model is constructed through the convolution kernel to generate a pixel-level spatial attention distribution map, effectively enhancing the spatial response intensity of small target areas.
[0145] Multi-task collaborative optimization:
[0146] A feature reuse architecture is constructed to feed attention-modulated multi-scale features into the classification and regression branches simultaneously. By introducing a gradient sharing mechanism and a joint loss function based on knowledge distillation, the coordinated optimization of target positioning accuracy and classification confidence is achieved, thereby improving the network's joint discrimination ability for small targets.
[0147] Backbone network replacement:
[0148] The original YOLOv8 backbone network Darknet was completely replaced with CSPDNet (Cross-Stage Partially Deformable Network). The three-layer multi-scale feature output structure was retained, and a DSCBlock module was embedded in each stage. The deformable convolution kernel was used to enhance the spatial deformation modeling capability. The channel weighting mechanism was used to replace the traditional 1×1 convolution to achieve lightweight cross-channel information interaction.
[0149] CSPDNet is based on the idea of deformable depthwise separable convolution and cross-stage partial connections. By introducing the DSCBlock module and channel weighting module within each stage, it significantly reduces redundant calculations while enhancing the ability to express deformable and multi-scale targets. Compared with the native YOLOv8 backbone network Darknet, CSPDNet can reduce the number of parameters by about 15% to 20% and 20% to 30% of FLOPs while maintaining similar feature extraction performance, significantly improving deployment efficiency on resource-constrained edge devices.
[0150] Cross-stage partial connection fusion:
[0151] Adhering to the native CSP (Cross-Stage Partially) architecture design, the features of each stage are split into the basic path and the DSCBlock module processing path. Through feature splicing and 1×1 convolution fusion strategy, the advantages of shallow texture features and deep semantic features are complementary, further improving the sensitivity to small targets.
[0152] Dynamic resolution adaptation:
[0153] The sampling offset range and channel compression ratio of the deformable convolution in DSCBlock are dynamically adjusted according to the input resolution, and the number of repetitions of certain lightweight modules is automatically reduced at higher resolutions to balance detection accuracy and inference speed.
[0154] S4. Use the training dataset to train the lightweight YOLOv8 model;
[0155] During training, the AdamW optimizer was used, and the initial learning rate was set to 0.01. The simulated annealing strategy was used to dynamically adjust the learning rate, with a cycle of 50 epochs, until the learning rate decayed to 0.0001.
[0156] The joint loss function (Focal Loss) is used to alleviate category imbalance and the regression loss (CIoU Loss) is used to enhance the bounding box positioning accuracy.
[0157] S5. Input the collected tea disease images into the trained lightweight YOLOv8 model, and output the tea disease type through the trained lightweight YOLOv8 model.
[0158] Finally, under the same hardware environment and software dependencies, the improved lightweight YOLOv8 model was compared and evaluated with the native YOLOv8 model. Compared with the original model, the improved lightweight YOLOv8 model has fewer parameters and faster inference speed. In addition, while ensuring real-time performance, it performs better on small targets of tea pests and diseases.
[0159] The foregoing description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the form disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments and can be modified within the scope of the concept described herein through the above teachings or techniques or knowledge in the relevant field. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention are intended to be protected by the appended claims.
Claims
1. A tea disease detection method based on a lightweight YOLOv8 model, characterized in that: include: S1. Collect various types of tea disease images; S2. Preprocessing the collected images of various types of tea diseases and marking the diseased areas in the images of different types of tea diseases to obtain a training data set; S3. Build a lightweight YOLOv8 model; Ghost-CBAM module embeds: In the FPN-PAN multi-scale feature fusion network of YOLOv8, the Ghost-CBAM module is used to replace the traditional convolution block; The Ghost-CBAM module combines the Ghost module with CBAM. The Ghost module uses cheap linear operations to generate redundant feature maps, while CBAM adaptively emphasizes useful channels and spatial positions through sequential channel attention and spatial attention mechanisms. The Ghost-CBAM module adopts a two-stage processing flow. In the first stage, redundant feature representation is constructed through the feature generation layer of the Ghost module. In the second stage, the features are dynamically calibrated through a cascaded channel-spatial attention mechanism. Finally, feature enhancement is achieved by element-wise multiplication of the attention weights with the input features. Channel Attention Mechanism: For the multi-channel features output by the Ghost module, a dual-path feature compression channel is constructed: Channel statistical descriptors are generated through global average pooling and global maximum pooling respectively. After nonlinear mapping by a parameter-sharing multi-layer perceptron, two-way feature fusion is achieved by element-by-element addition. Finally, a channel attention mask is generated through the Sigmoid function. Spatial Attention Mechanism: Based on the channel-calibrated features, dual-mode compression is performed along the channel dimension, and a local-global spatial correlation model is constructed through the convolution kernel to generate a pixel-level spatial attention distribution map. Multi-task collaborative optimization: A feature reuse architecture is constructed to feed attention-modulated multi-scale features into both the classification and regression branches. By introducing a gradient sharing mechanism and a joint loss function based on knowledge distillation, the coordinated optimization of target localization accuracy and classification confidence is achieved. Backbone network replacement: The original YOLOv8 backbone network Darknet was completely replaced with CSPDNet, retaining the three-layer multi-scale feature output structure. DSCBlock modules were embedded in each stage. Deformable convolution kernels were used to enhance spatial deformation modeling capabilities. A channel weighting mechanism was used to replace traditional 1×1 convolutions, achieving lightweight cross-channel information interaction. CSPDNet is based on the idea of deformable depthwise separable convolution and cross-stage partial connections. By introducing the DSCBlock module and channel weighting module within each stage, it reduces redundant calculations while enhancing the ability to express deformable and multi-scale objects. Cross-stage partial connection fusion: Adhering to the native CSP architecture design, the features of each stage are split into a basic path and a DSCBlock module processing path. Through feature splicing and 1×1 convolution fusion strategy, the advantages of shallow texture features and deep semantic features are complemented. Dynamic resolution adaptation: Dynamically adjust the sampling offset range and channel compression ratio of the deformable convolution in DSCBlock according to the input resolution; S4. Use the training dataset to train the lightweight YOLOv8 model; S5. Input the collected tea disease images into the trained lightweight YOLOv8 model, and output the tea disease type through the trained lightweight YOLOv8 model.
2. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S1, the tea disease images include tea ring spot disease images, tea algae spot disease images, tea white star disease images, tea anthracnose disease images, and tea sooty disease images.
3. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: Step S1 specifically includes: Before collecting images, a structured record template is first designed, which contains the collection time, collection location, environmental parameters and collection object status information; When collecting images, the collected tea disease images are associated with the information in the corresponding record template, and a two-person on-site verification mechanism is implemented. The first collector collects the records, and the second collector reviews the data collected by the first collector.
4. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S2, preprocessing includes illumination normalization: For each pixel value in the tea disease image, the mean and standard deviation of the entire image are calculated and normalized according to the following formula: ; Where, represents the normalized pixel value, represents the mean of the image, , represents the standard deviation of the image, , Represents the pixel value of the image at the coordinate (x, y), where x represents the horizontal coordinate of the pixel in the image, y represents the vertical coordinate of the pixel in the image, and N is the total number of pixels.
5. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S2, the preprocessing also includes adaptive histogram equalization: By dividing the image into several sub-regions, the local histogram is calculated independently in each sub-region and a grayscale mapping function is constructed to enhance the local contrast. For each sub-block, the cumulative distribution function of its grayscale is: ; Where, Represents the cumulative distribution of gray levels, L is the total number of gray levels, B represents the sub-block, is the gray level in the sub-block The number of pixels, is the total number of pixels in the sub-block, represents the grayscale mapping function calculated for sub-block B, and k represents the current grayscale level; The final grayscale value of each pixel is obtained by bilinear interpolation and fusing the mapping results of the four adjacent sub-blocks: ; Where, ∈[0,1] is the normalized distance weight from the pixel to the center of the adjacent sub-block, 、 、 、 are the four adjacent sub-blocks of sub-block B, represents the gray level, Represents the final grayscale value of each pixel; The improved CLAHE imposes a contrast limit on the local histogram: if the number of pixels at a certain gray level exceeds a threshold, the excess is cropped and evenly redistributed to all gray levels. The formula is: ; Where, represents the number of pixels of the i-th gray level in the original image, represents the number of new pixels of the i-th gray level after CLAHE processing, Indicates the threshold value.
6. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S2, preprocessing also includes a multi-scale Retinex algorithm: The tea disease image is decomposed into reflection component and illumination component, and Gaussian filtering of different scales is used to perform multi-scale estimation of the illumination component as follows: Single-scale Retinex: The observed image is decomposed into reflection component and illumination component in the logarithmic domain, namely: ; Where, represents the logarithmic intensity distribution of the observed image, represents the logarithmic intensity distribution of the reflected component, is the Gaussian filter kernel, To control the scale, S(x,y) represents the observed image, R(x,y) represents the reflection component, x represents the horizontal coordinate of the pixel in the image, and y represents the vertical coordinate of the pixel in the image; Multi-scale fusion: By weighted averaging the Retinex results of multiple different scales, the local contrast and global illumination consistency are balanced, that is: ; in is the weight, M is the total number of scales, and K is the current scale number.
7. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S2, the preprocessing also includes dynamic gamma correction: Dynamically adjust the Gamma value based on the local or global brightness distribution of the tea disease image as follows: Brightness statistics, calculate the average brightness of the global or local area of the image: , represents the average brightness, Represents the pixel value of the image at the coordinate (x, y), where x represents the horizontal coordinate of the pixel in the image, y represents the vertical coordinate of the pixel in the image, and N represents the total number of pixels; Dynamic Gamma value generation, adaptively generating Gamma value based on statistical average brightness: , represents the Gamma value, is the preset maximum value. is the preset minimum value, a and b are linear coefficients, , are the minimum and maximum brightness thresholds respectively; Pixel-level correction, applying Gamma transformation to each pixel, or calculating it separately for local areas After interpolation fusion, the Gamma transformation is as follows: , Represents the output pixel after Gamma transformation.
8. The tea disease detection method based on the lightweight YOLOv8 model according to claim 1 is characterized in that: In step S4, during training, the AdamW optimizer is used to set the initial learning rate, and the simulated annealing strategy is used to dynamically adjust the learning rate. Then, a period is set to decay the learning rate to the preset target. A joint loss function is used to alleviate category imbalance, and regression loss is used to enhance bounding box localization accuracy.
Citation Information
Patent Citations
Rice disease detection method, product, medium and equipment
CN118072147A
Light-weight tea disease target detection method based on TeaDisease LiteNet
CN120047818A