A lightweight litchi disease and pest detection method fusing dual-path attention and feature compensation

By introducing a lightweight, dynamically separable convolutional module and an attention mechanism into the YOLOv8 model, the accuracy and speed of litchi leaf disease and pest detection are improved, solving the problems of low detection efficiency and high computational complexity in existing technologies, and making it suitable for rapid identification in field environments.

CN122156797APending Publication Date: 2026-06-05ANHUI UNIVERSITY OF TECHNOLOGY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI UNIVERSITY OF TECHNOLOGY
Filing Date
2026-03-23
Publication Date
2026-06-05

Smart Images

  • Figure CN122156797A_ABST
    Figure CN122156797A_ABST
Patent Text Reader

Abstract

The patent discloses a lightweight litchi disease and pest detection method fusing double-path attention and feature compensation, and belongs to the technical field of image intelligent detection and plant disease control. In view of the problem of insufficient detection accuracy of small disease and pest targets in complex agricultural scenes, systematic improvements are made from two aspects of model architecture and feature optimization. On the one hand, a dynamic separable convolution module fusing attention mechanism is designed, and a double-path attention enhancement mechanism and a small target feature compensation mechanism are innovatively combined to optimize the extraction and fusion process of multi-scale features and significantly improve the recognition performance of the model for small disease and pest targets. On the other hand, the "attention mechanism and partial convolution cooperation" structure is creatively used in the Bottleneck part of the C2f module of the YOLOv8 model to enhance the sensitivity to small targets and the feature expression ability. The method effectively solves the problems of missed detection and high false detection rate of traditional visual methods for small target disease and pests in complex natural environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent detection technology for litchi leaf diseases and pests, specifically involving a lightweight litchi disease and pest detection method that integrates dual-path attention and feature compensation, which is particularly suitable for rapid and accurate identification of small-scale disease and pest targets on the leaf surface in field environments. Background Technology

[0002] The development of the litchi industry continues to be severely constrained by various pests and diseases. Diseases and pests such as algal spot, anthracnose, and leaf gall midge directly affect litchi yield and fruit quality. Early symptoms of leaf gall midge and small lesions on leaves are typical small-scale features, making timely identification difficult using traditional manual methods. This problem leads to delays in the control window, and coupled with the short shelf life of litchi fruit and significant losses during storage and transportation, further exacerbates pre- and post-harvest economic losses. Therefore, achieving rapid and accurate detection of litchi leaf diseases and pests, especially small-scale pests, is of great significance for improving the level of orchard management and ensuring the healthy development of the industry.

[0003] Currently, the detection of litchi diseases and pests mainly relies on the following methods:

[0004] (1) Manual experience detection: Relying on the professional knowledge and experience of plant protection personnel to make visual judgments, it has inherent defects such as low detection efficiency, high labor costs, strong subjectivity, and inability to achieve large-scale routine monitoring.

[0005] (2) Methods based on precision instruments or traditional image processing: These methods have stringent requirements for hardware, operating environment and operation and maintenance, are costly and difficult to promote and apply among a wide range of growers.

[0006] (3) Deep learning-based object detection methods: Although this method has shown potential, it still faces the following key challenges in practical applications: In the field of object detection, objects with a pixel area smaller than 32×32 or occupying less than 0.12% of the total image area are generally defined as small objects. When performing deep feature extraction, existing general detection models are prone to losing semantic information and detailed features of small objects. In addition, their low resolution and complex backgrounds lead to a significant decrease in detection accuracy.

[0007] Two-stage algorithms with high detection accuracy (such as the Faster R-CNN series) have high computational complexity, making them difficult to meet real-time monitoring requirements. On the other hand, single-stage algorithms with faster inference speeds (such as the YOLO and SSD series) maintain lightweight design, but their multi-scale feature fusion capabilities, especially their ability to perceive and discriminate features of small targets, still need improvement. In addition, complex models have high requirements for computing resources and memory, which is not conducive to deployment on edge devices or mobile terminals with limited computing power, thus limiting their practical application in fields and rural areas. Summary of the Invention

[0008] 1. The technical problem that the invention aims to solve To improve the detection capability of small targets and thus enhance the accuracy of detecting minor pests and diseases on the surface of litchi leaves, this invention provides a lightweight litchi pest and disease detection method that integrates dual-path attention and feature compensation. This method has strong detection capability for small targets and overcomes the problem that single-stage detection algorithms are usually less accurate than two-stage detection algorithms. At the same time, through lightweight convolution operations, it improves the real-time detection performance of the model and saves memory consumption when embedded in relevant devices.

[0009] 2. Technical Solution To achieve the above objectives, the technical solution provided by the present invention is as follows: The present invention provides a lightweight litchi disease and pest detection method integrating dual-path attention and feature compensation, comprising the following steps: S1: Obtain image data of diseases and pests on litchi leaves and preprocess them to construct a standardized image dataset of diseases and pests, which is divided into training set, validation set and test set according to the proportion. S2: Introduce a lightweight, dynamically separable convolutional module with an attention fusion mechanism into the backbone network of the YOLOv8 model, and optimize the feature extraction process through a dual-path attention enhancement mechanism and a small target feature compensation mechanism. S3: In the neck network of the YOLOv8 model, the original C2f module is replaced by a C2fup module that combines attention mechanism with partial convolution to optimize multi-scale feature fusion; S4: Use the partitioned dataset to train and evaluate the improved YOLOv8 model to obtain a litchi pest and disease detection model. Use the trained litchi pest and disease detection model to perform actual pest and disease detection.

[0010] Furthermore, in the backbone network of the YOLOv8 model, the convolution closest to the input layer uses the aforementioned lightweight dynamic separable convolution module, and the subsequent 3rd to 5th convolution layers in the backbone network from top to bottom also use the aforementioned lightweight dynamic separable convolution module, and the standard C2f module is used to receive the extracted features.

[0011] Furthermore, the lightweight dynamic separable convolutional module is a DSConv_att module. In this DSConv_att module, the input feature map is fed into the channel attention unit, spatial attention unit, and learnable enhancement coefficient unit in parallel to generate channel-weighted features, spatial-weighted features, and original feature-weighted features, respectively. The channel-weighted features, spatial-weighted features, and original feature-weighted features are added together to obtain a fused feature map. The fused feature map is then processed by the DSConv basic convolutional unit and activation function unit to output the final feature map.

[0012] Furthermore, the channel attention unit sequentially performs global pooling, multilayer perceptron transformation, and sigmoid activation on the input feature map to generate channel attention weights, which are then multiplied by the input feature map to obtain channel-weighted features.

[0013] Furthermore, the spatial attention unit sequentially performs channel aggregation, basic convolution, and detail enhancement convolution on the input feature map to generate spatial attention weights, which are then multiplied with the input feature map to obtain spatially weighted features.

[0014] Furthermore, the learnable enhancement coefficient unit multiplies the input feature map with learnable small target enhancement coefficients to obtain the original feature weighted features.

[0015] Furthermore, the learnable small target enhancement coefficient is a trainable parameter that is updated using gradient descent during model training to dynamically control the retention ratio of the original input features during feature fusion.

[0016] Furthermore, the C2fup module first expands the number of input channels through convolutional layers, and then divides them into two parts of features along the channel dimension. The first part of the features after division maintains the identity mapping and completely preserves the original information; the second part of the features is processed sequentially through multiple Faster_Block_EMA modules.

[0017] Furthermore, the Faster_Block_EMA module divides the input features into two parts, performs a 3×3 convolution on only one part, concatenates the convolution result with the other part of the features, and then processes them sequentially through a multilayer perceptron and an EMA attention mechanism before performing residual connections.

[0018] Furthermore, the dataset contains images of litchi diseases and pests, including algal spot disease, anthracnose, leaf gall midge, sooty mold, and felt disease, both front and back. During annotation, the bounding boxes are placed close to the edges of the lesions, and lesion annotations that are heavily obscured are removed.

[0019] 3. Beneficial effects Compared with the prior art, the technical solution provided by this invention has the following advantages: (1) To address the problem of easily losing semantic information and detailed features of small targets in litchi pest and disease detection, this invention improves the convolutional structure in the backbone of YOLOv8, which plays a role in feature extraction. Channel attention is used to select channels sensitive to small targets, avoiding the loss of small target information. Spatial attention is used to perform fine-grained spatial localization, eliminating background interference and highlighting small targets in detail. Simultaneously, the Bottleneck part of the C2f function in the original YOLOv8 model's neck is improved by replacing the original structure with partial convolutions and integrating EMA attention and a multilayer perceptron (MLP). By adopting the method of "combining attention mechanisms with partial convolutions," the model's ability to extract and fuse features of small targets is enhanced, improving the accuracy of small target detection, while further reducing the overall model size, achieving a lightweight litchi pest and disease model.

[0020] (2) The existing single-stage detection algorithm YOLOv8 has a fast detection speed, but its detection accuracy is lower than that of the two-stage detection algorithm to a certain extent. This invention introduces lightweight depthwise separable convolution (DSConv) to lighten the YOLOv8 model. At the same time, to ensure that the model performance is not reduced due to lightweighting, important channels and key regions are enhanced through spatial attention and channel attention, so that the model reduces the number of model parameters and computational burden while maintaining basic performance. Attached Figure Description

[0021] Figure 1 A flowchart illustrating a lightweight litchi pest and disease detection method that integrates dual-path attention and feature compensation provided by the present invention. Figure 2 The overall structure diagram of the improved YOLOv8 model provided by this invention; Figure 3 This is a schematic diagram of the lightweight convolution DSConv_att provided by the present invention; Figure 4 This is a schematic diagram of the structure of the Faster_Block_EMA module provided by the present invention; Figure 5 This is a schematic diagram of the structure of the improved C2fup module provided by the present invention. Detailed Implementation

[0022] The following will describe in detail the specific implementation process of the attention mechanism-based litchi leaf pest and disease detection method proposed in this invention, with reference to specific embodiments. It should be noted that the described embodiments are intended to clearly demonstrate the technical solution and implementation path of this invention, and are not intended to limit the scope of protection of this invention in any way.

[0023] The implementation process of this invention mainly includes several key stages: dataset construction and preprocessing, targeted improvement of the YOLOv8 object detection model, and training and evaluation of the improved model. Each stage contains clear operational steps and technical details, which together constitute a complete and reproducible technical implementation scheme. The specific steps are as follows: S1: Obtain image data of diseases and pests on litchi leaves in the experimental field; preprocess the image data to obtain an image dataset related to diseases and pests; label the images in the dataset and divide the dataset into training set, test set and validation set in a ratio of 8:1:1 to obtain training data.

[0024] The target detection model involved in this invention relies on a high-quality, well-annotated dataset of images of litchi leaf diseases and pests for training. This dataset is the foundation for achieving a high-precision detection model. The following details the construction, annotation, encoding, and partitioning process of the dataset to ensure data format consistency and the effectiveness of model training.

[0025] S1-1: Acquire image data in the experimental field and match the corresponding types of diseases and pests on the surface of litchi leaves from the database based on relevant agricultural knowledge; including: algal spot disease, anthracnose, leaf gall midge, sooty mold, felt disease (front), and felt disease (back).

[0026] S1-2: Label all images in the dataset and organize the labeled data into two corresponding directories: the first directory stores the original image files, and the second directory stores the label files that correspond one-to-one with each original image; encode the label information according to the pest and disease category, and map each type of pest and disease to a unique numerical category code.

[0027] The following five standards must be strictly followed during image annotation: (1) When marking lesions on litchi leaves, the bounding box should be close to the edge of the lesion to avoid including the healthy leaf area.

[0028] (2) If the lesion is largely covered (e.g., completely covered by other leaves), the lesion should be omitted.

[0029] (3) If the lesion is only partially covered (such as being slightly covered by other leaves), the visible part should still be marked.

[0030] (4) The annotation box should be kept away from the edge of the image to ensure the integrity of the lesion in the image.

[0031] (5) If a large number of dense lesions appear in the image, you can choose whether to label each target according to the actual situation, and ensure that the label box is clear and does not overlap.

[0032] After obtaining the annotation files, they are reviewed by experts in the relevant field to ensure the usability and accuracy of the dataset.

[0033] S1-3: Preprocess the processed dataset and divide it into training, validation, and test sets in an 8:1:1 ratio.

[0034] S2: Targeted improvements are made to the YOLOv8 object detection model. First, a lightweight, dynamically separable convolutional module with an attention fusion mechanism is introduced into the backbone network of the YOLOv8 model. The feature extraction process of the backbone is optimized through a dual-path attention enhancement mechanism and a small target feature compensation mechanism, while taking into account both global and contextual information.

[0035] like Figure 2 As shown, in the backbone structure of the YOLOv8 model, the convolution closest to the input layer uses the lightweight depthwise separable convolution DSConv_att described in this invention. This invention applies an attention mechanism from the outset to extract and preserve details of low-level features, avoiding detail loss during downsampling. Furthermore, in the subsequent 3rd to 5th layers of the YOLOv8 model backbone structure, the lightweight depthwise separable convolution DSConv_att optimizes the quality of the extracted features. During this process, the standard C2f module accurately and correctly accepts the extracted features.

[0036] The specific structure of the lightweight depthwise separable convolution DSConv_att is as follows: Figure 3 As shown, the input feature map is fed into the channel attention unit, spatial attention unit, and learnable enhancement coefficient unit in parallel. The channel attention unit performs global pooling, multilayer perceptron transformation, and sigmoid activation on the input feature map to generate channel attention weights, which are then multiplied by the input feature map to obtain channel-weighted features. The spatial attention unit performs channel aggregation, basic convolution, and detail enhancement convolution on the input feature map to generate spatial attention weights, which are then multiplied by the input feature map to obtain spatial-weighted features. The learnable enhancement coefficient unit multiplies the input feature map with learnable small target enhancement coefficients (Γ) to obtain the original feature-weighted features. The feature fusion unit adds the three weighted features obtained above to obtain a fused feature map, which is then input into the DSConv basic convolution unit for convolution operation. Finally, the convolution result is input into the activation function unit for nonlinear transformation to output the final feature map.

[0037] It is worth noting that the learnable small target enhancement coefficient () in this embodiment The parameter is a trainable parameter used to control the proportion of original input features retained during feature fusion, enabling dynamic enhancement of small target features. In traditional attention mechanisms, when the attention weight is 0, features are severely suppressed and gradient vanishing occurs. Furthermore, the attention mechanism may incorrectly suppress important information that should be retained, especially for small targets with weak responses. This embodiment sets a learnable enhancement coefficient unit. When the attention mechanism fails, the information content of the fused features is determined by the small target enhancement coefficient. It provides that Γ≠0, ensuring that features are not completely suppressed and that gradients continue to flow.

[0038] The initial value is 0.5, which only initially works in conjunction with the attention mechanism to provide moderate preservation of original features; subsequently, gradient descent is used to update Γ, with the specific formula as follows:

[0039] in, , The learning rate. When the gradient of the attention path is small, The path provides gradient compensation and automatically searches for the optimal balance point during training.

[0040] The direction of Γ's update is determined by the following equilibrium equation: The specific formula for the output is as follows:

[0041] in, The channel enhancement features, spatial enhancement features, and original input feature map are multiplied by a learnable small target enhancement coefficient. We perform weighted fusion to obtain the fused feature map.

[0042] S3: In the neck part of the YOLOv8 model, the "attention mechanism and partial convolution" method is used to enhance the multi-scale feature fusion capability, thereby improving the model's ability to detect small targets and reducing the overall number of model parameters.

[0043] like Figure 2 As shown, the C2f structure in the neck structure of YOLOv8 is replaced with the C2fup structure. The main function of the neck structure is feature fusion and enhancement. The C2fup structure achieves the greatest benefit in the shallow feature layers where the feature computation density is highest. Although the computation density decreases in subsequent feature layers, the number of parameters remains large. The proposed structure can achieve a certain degree of lightweighting. This structure also improves the detection of small objects.

[0044] To address the issues of traditional C2f methods, such as the standard convolutional layer potentially over-smoothing small object features and the lack of attention mechanisms, which makes it difficult to highlight small objects, this embodiment features a specifically designed C2fup structure, combined with... Figure 5 The following will introduce the main process of the C2fup structure: First, the number of input channels is expanded to 2C through a convolutional layer (Conv), where... , ( (where e is the number of output channels of the preceding module and e is the expansion factor), thus obtaining and will Divide the channel along its dimension into two parts in a 3:1 ratio: For the first part of the features obtained from the segmentation Maintain the identity mapping to fully preserve the original information. For the second part of the features obtained from the segmentation... By sequentially passing through n Faster_Block_EMA modules, the computational cost is reduced to 1 / 4 of that of traditional methods while maintaining feature extraction capabilities, achieving an optimized balance between computational efficiency and expressive power. The input to the first Faster_Block_EMA is... The subsequent input is the output of the previous Faster_Block_EMA.

[0045] like Figure 4 As shown, the Faster_Block_EMA module takes the second part of the features as input sequentially, and then inputs... (The first Faster_Block_EMA input corresponds to) Divided into two parts Only for Perform a 3x3 convolution. Obtain... Afterwards, with splicing, i.e. The spatially blended features are processed using a multilayer perceptron (MLP), and then addressed through an EMA attention mechanism. Finally, the above spatial blending and channel attention are combined to obtain... and Perform residual connection.

[0046] The preprocessed dataset needs to be loaded into the improved YOLOv8 model for training. The following specific example details the environment configuration, file organization, and parameter settings required for model training to ensure the smooth execution of the training process and obtain the optimal model.

[0047] S4: Train the improved YOLOv8 network model based on the training data to obtain a disease and pest detection model for the surface of litchi leaves. Test the detection model and record the test results after the test is completed.

[0048] For example: Load the partitioned dataset into the improved YOLOv8 model, configure the environment variables and related hardware and software settings, as shown below: Operating System: Linux; Graphics Cards: 4; NVIDIA Tesla V100; Torch Version: 2.4.1+cu121; Python Version: 3.8.20.

[0049] Configure the relevant parameters for YOLOv8, set the batch size to 8, the number of training epochs to 300, the initial learning rate to 0.01, and the weight decay coefficient to 0.0005; run the train.py file to train the model and obtain the optimal model.

[0050] S5: Evaluate the accuracy of the model for detecting litchi diseases and pests based on the test results.

[0051] For example: after training is complete, the training results are recorded, including precision, recall, and mAP value, and a weight file is generated and saved; the evaluation metrics used in this invention are as follows: Average precision value:

[0052] Where P = TP / (TP+FP), R = TP / (TP+FN), classes is the number of litchi leaf surface diseases and pests identified in the training results, P represents precision, R represents recall, TP represents the number of correctly identified positive samples, FP represents the number of incorrectly identified negative samples, and FN represents the number of incorrectly identified positive samples.

[0053] The working principle of this invention is as follows: A large amount of image data on litchi leaf diseases and pests is acquired; the source image data is preprocessed and labeled to construct a litchi leaf disease and pest image dataset; a litchi leaf disease and pest detection model based on an improved YOLOv8 algorithm is constructed; the designed model is trained and the detection results on the test set are obtained; the litchi leaf disease and pest detection model improved by the YOLOv8 algorithm adds an attention mechanism to the C2f module to improve the detection ability of small targets, thereby improving the model's detection accuracy and helping to reduce manual costs; while ensuring detection progress, a more lightweight convolution DSConv is used, and an attention mechanism is added to this convolution, which not only does not affect the detection accuracy of small targets but also reduces the number of parameters, making the model lightweight.

[0054] The present invention and its embodiments have been described above illustratively. This description is not restrictive, and the figures shown are only one embodiment of the present invention; the actual structure is not limited thereto. Therefore, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the present invention, such designs should fall within the protection scope of the present invention.

Claims

1. A lightweight method for detecting litchi diseases and pests that integrates dual-path attention and feature compensation, characterized in that, Includes the following steps: S1: Obtain image data of diseases and pests on litchi leaves and preprocess them to construct a standardized image dataset of diseases and pests, which is divided into training set, validation set and test set according to the proportion. S2: Introduce a lightweight, dynamically separable convolutional module with an attention fusion mechanism into the backbone network of the YOLOv8 model, and optimize the feature extraction process through a dual-path attention enhancement mechanism and a small target feature compensation mechanism. S3: In the neck network of the YOLOv8 model, the original C2f module is replaced by a C2fup module that combines attention mechanism with partial convolution to optimize multi-scale feature fusion; S4: Use the partitioned dataset to train and evaluate the improved YOLOv8 model to obtain a litchi pest and disease detection model. Use the trained litchi pest and disease detection model to perform actual pest and disease detection.

2. The lightweight litchi disease and pest detection method integrating dual-path attention and feature compensation according to claim 1, characterized in that: In the backbone network of the YOLOv8 model, the convolution closest to the input layer uses the aforementioned lightweight dynamic separable convolution module, and the subsequent 3rd to 5th convolution layers in the backbone network from top to bottom also use the aforementioned lightweight dynamic separable convolution module, and the standard C2f module is used to receive the extracted features.

3. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 1 or 2, characterized in that: The lightweight, dynamically separable convolutional module is the DSConv_att module. In this DSConv_att module, the input feature map is fed into the channel attention unit, spatial attention unit, and learnable enhancement coefficient unit in parallel to generate channel-weighted features, spatial-weighted features, and original feature-weighted features, respectively. The channel-weighted features, spatial-weighted features, and original feature-weighted features are added together to obtain a fused feature map. The fused feature map is then processed by the DSConv basic convolutional unit and activation function unit to output the final feature map.

4. The lightweight litchi disease and pest detection method integrating dual-path attention and feature compensation according to claim 3, characterized in that: The channel attention unit sequentially performs global pooling, multilayer perceptron transformation, and sigmoid activation on the input feature map to generate channel attention weights, which are then multiplied with the input feature map to obtain channel-weighted features.

5. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 3, characterized in that: The spatial attention unit sequentially performs channel aggregation, basic convolution, and detail enhancement convolution on the input feature map to generate spatial attention weights, which are then multiplied with the input feature map to obtain spatially weighted features.

6. The lightweight litchi disease and pest detection method according to claim 3, characterized in that: The learnable enhancement coefficient unit multiplies the input feature map with learnable small target enhancement coefficients to obtain the original feature weighted features.

7. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 6, characterized in that: The learnable small target enhancement coefficient is a trainable parameter that is updated using gradient descent during model training to dynamically control the retention ratio of the original input features during feature fusion.

8. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 3, characterized in that: The C2fup module first expands the number of input channels through convolutional layers, and then divides the features into two parts along the channel dimension. The first part of the features after division maintains the identity mapping and completely preserves the original information. The second part of the features is processed by multiple Faster_Block_EMA modules in sequence.

9. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 8, characterized in that: The Faster_Block_EMA module divides the input features into two parts, performs a 3×3 convolution on only one part, concatenates the convolution result with the other part of the features, and then processes them sequentially through a multilayer perceptron and an EMA attention mechanism before performing residual connections.

10. A lightweight litchi pest and disease detection method integrating dual-path attention and feature compensation according to claim 1, characterized in that: The dataset contains images of litchi diseases and pests, including algal spot disease, anthracnose, leaf gall midge, sooty mold, and felt disease, both front and back of the affected area. During annotation, the bounding boxes are placed close to the edges of the lesions, and lesions with large areas of obstruction are removed.