Lightweight plant leaf disease and pest detection method based on improved YOLOv8
By improving the lightweight detection method of YOLOv8 and combining a bidirectional pyramid structure and dual-enhanced detection heads, the difficulties in identifying pests and diseases in complex field environments and the problem of model lightweighting were solved, achieving high-precision pest and disease detection with low computational load.
Patent Information
- Application Number
- CN202611494410.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-27
AI Technical Summary
Existing methods for detecting plant leaf diseases and pests are difficult to identify in complex field environments, struggle to effectively separate weak pathological signals, have insufficient discriminative power of feature vectors, and are difficult to balance between lightweight models and detection accuracy, making them difficult to deploy on edge devices.
A lightweight plant leaf disease and pest detection method based on improved YOLOv8 is adopted. Feature extraction is enhanced by a bidirectional pyramid structure and a dynamic feature refinement module. The ability to identify lesions is improved by combining a dual-enhanced detection head. Deep strip convolution and color anomaly attention are used to enhance small targets. A lightweight network structure is designed to adapt to edge devices.
It improves the accuracy of pest and disease detection and the ability to identify small lesions in complex field environments, while reducing the number of model parameters, making it suitable for deployment on edge devices such as drones and field sensors.
Smart Images

Figure CN123182031A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of plant disease and pest detection technology, and relates to a lightweight plant leaf disease and pest detection method based on an improved YOLOv8. Background Technology
[0002] Plant leaves are key organs for photosynthesis and material production, and their health directly affects the yield and quality of medicinal herbs and cash crops. In intensive production, factors such as simplified ecological structures, continuous cropping obstacles, and climate change have exacerbated plant leaf diseases and pests. Due to a lack of sophisticated monitoring methods, farmers typically resort to high-frequency, high-dose chemical pesticide spraying for control, which not only increases planting costs but also poses risks of pesticide residue exceeding limits and environmental pollution. Therefore, utilizing intelligent detection technology for early identification and precise monitoring of plant leaf diseases and pests has become a crucial technological means to ensure the green and high-quality development of agriculture.
[0003] With the development of information technology, computer vision has become an important means of automatic identification of pests and diseases in smart agriculture. Early methods typically relied on manually designed color, texture, and shape features, combined with dimensionality reduction or discriminant methods such as Principal Component Analysis (PCA) and Linear Discriminant Analysis (LDA) for identification. However, their feature representation ability and adaptability to complex environments were limited, and their recognition performance easily declined under conditions of changing lighting, shooting angle, and background interference. With the rise of deep learning, Convolutional Neural Networks (CNNs) can automatically extract color, texture, shape, and edge information of pest and disease areas through hierarchical feature learning, thus improving the detection performance of plant pests and diseases. Current target detection methods mainly include two-stage methods represented by the R-CNN series and one-stage methods represented by the YOLO series. The latter integrates classification and regression tasks into the same network, has a fast inference speed, and is more suitable for real-time agricultural monitoring tasks. YOLOv8 introduces an anchorless mechanism and a decoupled head, which has certain advantages in terms of detection accuracy, inference efficiency, and structural scalability.
[0004] However, existing general methods for detecting plant diseases and pests still face the following technical bottlenecks. First, identification is difficult in complex field environments. In actual farmland, light changes drastically, leaves overlap, and the background is cluttered. Early-stage lesions are small and have low contrast with healthy tissue. Existing fixed-field convolution operators struggle to effectively separate weak pathological signals from complex backgrounds, resulting in a high rate of missed detection for small lesions. Second, there is little difference in feature vectors between disease and pest categories, but significant differences within categories. Different disease and pest species exhibit high inter-class similarity in appearance, while the same category of diseases and pests shows significant intra-class variability due to differences in infection stage and environment, leading to model classification confusion and localization bias. Third, deployment of edge devices is difficult. High-precision models have a large number of parameters, making them difficult to deploy directly on edge devices such as drones and field sensors. Lightweight strategies such as channel pruning and depthwise separable convolution can reduce the number of model parameters and computational cost. However, if the network structure design or pruning ratio is unreasonable, it may weaken the model's ability to represent fine-grained textures and lesion edges, resulting in a certain decrease in detection accuracy.
[0005] To address the aforementioned issues, existing research has explored various approaches. A lightweight improved YOLOv8n method achieved 35.8 frames per second on Jetson Nano; Dai et al. proposed GCR-YOLOv10, designing a gated attention and cross-layer feature fusion structure; DAS-YOLOv11 was proposed for cucumber diseases and pests, introducing switchable dilated convolutions to enhance spatial perception; and a lightweight framework was proposed for rice leaf diseases, enhancing multi-scale context extraction capabilities through a multi-branch large-kernel fusion module. Although visual detection technology has achieved good applications in agriculture, existing object detection methods still have the following shortcomings: (i) Insufficient robustness in complex field environments. Under varying light conditions, leaf shading, and cluttered backgrounds, fixed-field convolution is unable to capture the faint edge and texture signals of tiny lesions, resulting in a high rate of missed detection for small targets.
[0006] (ii) Insufficient discriminative power of feature vectors. The fine-grained distribution pattern of high inter-class similarity and large intra-class differences makes the features extracted by the model lack sufficient inter-class separation and intra-class cohesion, leading to classification confusion.
[0007] (iii) It is difficult to balance detection accuracy and model lightweighting. Although existing model compression methods can reduce the number of parameters and computational cost, unreasonable lightweight structures or pruning strategies may lead to a decrease in the ability to express fine-grained features, making it difficult to simultaneously meet the requirements of detection performance and deployment of resource-constrained equipment. Summary of the Invention
[0008] To address the problems existing in the prior art, this invention proposes a lightweight method for detecting plant leaf diseases and pests based on an improved YOLOv8.
[0009] To achieve the above objectives, the embodiments of the present invention adopt the following technical solutions: On the one hand, a lightweight method for detecting plant leaf diseases and pests based on an improved YOLOv8 is provided, including the following steps: Acquire images of the plant leaves to be detected.
[0010] The plant leaf images were processed using a pest and disease detection model to obtain the identification results of plant leaf pest and disease categories and bounding box coordinates; The pest and disease detection model comprises a backbone network, a neck network, and a dual-enhanced detection head connected in sequence. The backbone network uses YOLOv8 to extract multi-scale features from plant leaf images. The neck network uses a bidirectional pyramid structure to fuse and correct the multi-scale features output by the backbone network. The top-down branch transmits high-level semantic information to the lower layers through upsampling and fusion correction modules. The bottom-up branch first refines the high-resolution shallow-layer enhanced features through a dynamic feature refinement module, then transmits low-layer positional information to the higher layers through convolutional layers and a fusion correction module, ultimately outputting three optimized features at different scales. The fusion correction module is used to adjust the features at different levels or propagation levels. After spatial dimension alignment and channel stitching of the features to be fused along the path, global channel calibration, nonlinear mapping, and dual-path dynamic gating are performed sequentially to output multi-scale adaptive enhanced features. The dynamic feature refinement module is used to perform orientation-aware modeling and cross-space aggregation on the high-resolution shallow enhanced features, and deep strip convolution is used to enhance the geometric edge features of long strip lesions. The dual-enhancement detection head is used to perform color anomaly attention enhancement on the three optimized features respectively, and to perform micro-target enhancement on the first-scale color enhancement feature. The micro-target enhancement results and the second and third-scale color enhancement features are respectively input into the dual-branch detection head of the corresponding scale to generate plant leaf disease and pest category recognition results and bounding box coordinates.
[0011] One of the above technical solutions has the following advantages and beneficial effects: The aforementioned lightweight plant leaf disease and pest detection method based on improved YOLOv8 includes: acquiring images of plant leaves to be detected; processing the plant leaf images using a disease and pest detection model to obtain plant leaf disease and pest category identification results and bounding box coordinates. This method, based on the YOLOv8 framework, improves upon existing problems in plant leaf disease and pest detection such as multi-scale feature aliasing, small lesion size, strong background interference, channel redundancy, and boundary positioning deviation. While meeting the requirements of lightweight deployment, it enhances the model's ability to perceive small lesions and early lesions, thereby improving the accuracy of plant leaf disease and pest detection. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the conventional technology, the drawings used in the description of the embodiments or the conventional technology will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a flowchart illustrating a lightweight plant leaf disease and pest detection method based on an improved YOLOv8 in one embodiment. Figure 2 This is a schematic diagram of the overall structure of a pest and disease detection model in one embodiment; Figure 3 This is a schematic diagram of the FCM module structure in one embodiment; Figure 4 This is a schematic diagram of the structure of the Dynamic Feature Refinement Module (DFRM module) in one embodiment; Figure 5 This is a schematic diagram of the Bi-Enhance Detect Head module structure in one embodiment; Figure 6 This is a schematic diagram illustrating the channel pruning principle in one embodiment; Figure 7 This is the original image in one embodiment; Figure 8 This is a schematic diagram of the YOLOv8n (baseline) visualization detection results in one embodiment; Figure 9 This is a schematic diagram of the YOLOv9t visualization detection results in one embodiment; Figure 10 This is a schematic diagram of the YOLOv10n visualization detection results in one embodiment; Figure 11 This is a schematic diagram of the YOLOv11n visualization detection results in one embodiment; Figure 12 This is a schematic diagram of the YOLOv12n visualization detection results in one embodiment; Figure 13 This is a schematic diagram of the YOLO26n visualization detection results in one embodiment; Figure 14 This is a schematic diagram of the FFCA-YOLO visualization detection results in one embodiment; Figure 15 This is a schematic diagram of the DynamicDet-YOLO visualization detection results in one embodiment; Figure 16 This is a schematic diagram of the visualization of the detection results of this method in one embodiment; Detailed Implementation
[0014] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0015] 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 in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0016] It should be noted that, in this document, the reference to "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The presentation of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will understand that the embodiments described herein can be combined with other embodiments. The term "and / or" as used herein refers to any combination of one or more of the associated listed items, and all possible combinations, including such combinations.
[0017] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0018] In one embodiment, such as Figure 1 As shown, a lightweight method for detecting plant leaf diseases and pests based on an improved YOLOv8 is provided, which may include the following processing steps 1 to 2: Step 1: Obtain images of the plant leaves to be detected.
[0019] Step 2: Process plant leaf images using a pest and disease detection model to obtain pest and disease category identification results and bounding box coordinates. The pest and disease detection model includes a backbone network, a neck network, and a dual-enhancement detection head connected sequentially. The backbone network uses YOLOv8 to extract multi-scale features from the plant leaf images. The neck network uses a bidirectional pyramid structure to fuse and correct the multi-scale features output by the backbone network. The top-down branch transmits high-level semantic information to the lower layers through upsampling and fusion correction modules. The bottom-up branch first refines the high-resolution shallow enhancement features through a dynamic feature refinement module, then transmits low-level positional information to the higher layers through convolutional layers and fusion correction modules, ultimately outputting three different scales of optimized features. The system comprises three modules: a fusion correction module and a dual-branch detection head. The fusion correction module performs spatial dimension alignment and channel stitching on two features to be fused from different levels or propagation paths, and then sequentially performs global channel calibration, nonlinear mapping, and dual-path dynamic gating to output multi-scale adaptive enhanced features. The dynamic feature refinement module performs orientation-aware modeling and cross-space aggregation on high-resolution shallow enhanced features, and uses deep strip convolution to enhance the geometric edge features of long strip-shaped lesions. The dual-enhancement detection head performs color anomaly attention enhancement on the three optimized features, and performs micro-target enhancement on the first-scale color enhancement feature. The micro-target enhancement results and the second and third-scale color enhancement features are input into the corresponding scale dual-branch detection heads to generate plant leaf disease and pest category recognition results and bounding box coordinates.
[0020] Specifically, this embodiment uses the leaves of *Polygonatum odoratum* as a specific detection object. Considering the macroscopic geometric characteristics of the leaves (linear-lanceolate shape) and the microscopic gradient of anisotropic diffusion of lesions due to vein restriction, a lightweight LSFA was obtained through in-depth customization based on YOLOv8n. The YOLO detection network uses a lightweight LSFA. The YOLO detection network is used as the pest and disease detection model in this method. The design of this model focuses on making the network's inductive bias approximate the actual physical manifold of *Polygonatum odoratum* lesions, while also considering the constraints of limited computing power (0.5-2.0 TFLOPS) and on-chip storage resources on edge embedded devices. The structure of the pest and disease detection model is as follows: Figure 2 As shown, it mainly consists of three parts: a backbone network for feature extraction, a neck network for fusion calibration, and a dual-enhanced detection head. It should be noted that this embodiment uses the leaves of *Polygonatum odoratum* as the specific detection object, and is only used to illustrate the technical solution of the present invention; it does not constitute a limitation on the types of plant leaves to which the present invention is applicable.
[0021] The architecture's design logic directly stems from the characteristics of the high longitudinal and transverse gradients and large covariance eccentricity of the vein constraints in *Phyllostachys edulis* leaves. In the feature fusion stage, the neck network integrates four fusion correction modules (FCM modules), and a dynamic feature refinement module (DFRM module) is added for high-resolution shallow enhancement features. Deep strip convolution is used to refine the anisotropic edge texture of lesions. A spatial dimension alignment operator is used to achieve feature size uniformity, and a dual-path dynamic gating mechanism is employed for scale awareness and dynamic feature selection, reducing interference caused by semantic redundancy and aliasing artifacts during multi-scale aggregation. The final feature stream is fed into a Bi-Enhance Detection Head, which includes a Color Anomaly Attention Module (CAA), a Small Target Enhancement Module (STB), and a decoupled detection head. The three optimized features undergo color anomaly attention enhancement through the CAA module, with the first-scale color enhancement feature further processed by the STB for high-frequency detail compensation to obtain the final first-scale enhancement feature. These first-scale, second-scale, and third-scale color enhancement features are then fed into the corresponding decoupled detection heads. Following the task separation principle of translation invariance for classification tasks and translation equivariance for regression tasks, the decoupled detection heads perform category prediction and bounding box regression through classification and bounding box regression branches, respectively. This hierarchical structure design significantly improves the localization accuracy of bounding boxes on the minor axis while ensuring the model parameter count is less than 3M. The forward propagation path of the pest and disease detection model not only topologically solves the feature confusion problem in complex field backgrounds but also provides a highly physically interpretable baseline structure for ablation experiments and edge device deployment.
[0022] Existing general-purpose target detection models are easily affected by leaf vein texture, irregular lesion morphology, and striped diffusion characteristics when processing leaf lesions of *Polygonatum odoratum*, resulting in insufficient expression of irregular target edges. This method incorporates a Dynamic Feature Refinement (DFRM) module, using 1×5 and 5×1 depth strip convolution operators to fit the elongated physical manifold of *Polygonatum odoratum* lesions, thus improving the ability to identify irregular lesion edges.
[0023] Existing multi-scale feature fusion methods are susceptible to semantic redundancy, scale differences, and background noise interference. This invention incorporates a fusion correction module (FCM), which utilizes spatial dimension alignment, global channel calibration, and dual-path dynamic gating mechanisms to complete cross-scale feature fusion and correction, reducing semantic redundancy and aliasing interference during multi-scale aggregation and improving the feature signal-to-noise ratio in complex backgrounds.
[0024] Existing models are prone to missing detections when dealing with early-stage micro-lesions and lack the ability to identify weakly textured targets. This invention employs a Bi-Enhance Detect Head, combining a Color Anomaly Attention Module (CAA) and a Micro-Target Enhancement Module (STB), to enhance the representation of leaf discoloration areas and high-frequency edge details, thereby improving the detection performance of early-stage micro-lesions, pinpoint lesions, and weakly textured targets.
[0025] This method, based on the YOLOv8 framework, improves upon existing problems in plant leaf disease and pest detection, such as feature overlap, small lesions, strong background interference, channel redundancy, and inaccurate localization. While maintaining a low computational load, it enhances the model's sensitivity to small initial lesions.
[0026] This method improves the model's ability to extract lesion edges, micro-textures, and abnormal color regions from *Polygonatum odoratum* leaves by redesigning efficient feature representation operators; reduces the interference of complex leaf vein textures and field background noise on lesion information through multi-scale feature collaboration and long-range dependency modeling; enhances the model's ability to locate and identify subtle lesions, small targets, and irregular lesions by improving the detection head structure; and reduces network redundancy channels and model parameters through structured channel pruning technology, enabling the model to have better lightweight deployment capabilities while minimizing accuracy loss.
[0027] The aforementioned lightweight plant leaf disease and pest detection method based on improved YOLOv8 acquires images of the plant leaves to be detected. A disease and pest detection model is then used to process the plant leaf images, yielding the plant leaf disease and pest category identification results and bounding box coordinates. This method, based on the YOLOv8 framework, improves upon existing problems in plant leaf disease and pest detection, such as feature overlap, small lesions, strong background interference, channel redundancy, and inaccurate localization. While maintaining a low computational load, it enhances the model's sensitivity to small initial lesions, thereby improving the accuracy of plant leaf disease and pest detection.
[0028] In one embodiment, the neck network includes four fusion correction modules, one dynamic feature refinement module, and two convolutional layers; step 2 includes: inputting the above-mentioned plant leaf image into the backbone network to obtain shallow features, mid-level features, and deep features; inputting the shallow features, mid-level features, and deep features into the neck network; in the top-to-bottom branch of the neck network, upsampling the deep features and inputting them together with the mid-level features into the first fusion correction module to obtain mid-level enhanced features; upsampling the mid-level enhanced features and inputting them together with the shallow features into the second fusion correction module to obtain shallow enhanced features; in the neck network... In the bottom-up branch of the network, the shallow enhancement features are input into the dynamic feature refinement module for processing to obtain the first-scale optimized features; the first-scale optimized features are processed by the first convolutional layer and then input into the third fusion correction module with the middle-layer enhancement features to obtain the second-scale optimized features; the second-scale optimized features are processed by the second convolutional layer and then input into the fourth fusion correction module with the deep features to obtain the third-scale optimized features; the first-scale optimized features, the second-scale optimized features, and the third-scale optimized features are input into the dual-enhancement detection head to obtain the plant leaf disease and pest category identification results and bounding box coordinates.
[0029] In one embodiment, the fusion correction module includes: a spatial dimension alignment module, a splicing operation, a weight generation module, a channel broadcasting processing module, a nonlinear mapping layer, and a dual-path dynamic gating mechanism; the upsampled deep features and mid-level features are input into the first fusion correction module to obtain mid-level enhanced features, including: upsampling the deep features to obtain first upsampled features; inputting the first upsampled features and mid-level features into the spatial dimension alignment module, and processing them respectively using spatial dimension alignment operators to obtain first aligned features and second aligned features with consistent spatial dimensions; aligning the first aligned features and second aligned features in the channel dimension... The initial fusion features with cross-level semantic information are concatenated to obtain the initial fusion features. The initial fusion features are then input into the weight generation module to obtain the channel gain coefficients. The channel gain coefficients are then input into the channel broadcast processing module, where dimension compression, staggered repetition, and dimension expansion operations are used to adjust the dimension of the channel gain coefficients to match the dimension of the initial fusion features, resulting in dimension-adjusted channel gain coefficients. The dimension-adjusted channel gain coefficients are then multiplied element-wise with the initial fusion features and input into the nonlinear mapping layer to obtain the first intermediate feature. The first intermediate feature is then input into the dual-path dynamic gating mechanism to obtain the mid-layer enhancement feature.
[0030] In one embodiment, the weight generation module includes an adaptive average pooling layer, a first convolutional layer, a SiLU activation layer, a second convolutional layer, and a Sigmoid activation layer connected in sequence, used to process the initial fused features and generate channel gain coefficients.
[0031] In one embodiment, the nonlinear mapping layer includes two convolutional modules connected in series; each convolutional module includes a convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence.
[0032] In one embodiment, the dual-path dynamic gating mechanism includes three parallel branches: a first depthwise convolutional branch, a second depthwise convolutional branch, and a dynamic gain generation branch. Each depthwise convolutional branch includes a depthwise convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence. The dynamic gain generation branch includes an average pooling layer, a first gain convolutional layer, a SiLU activation layer, a second gain convolutional layer, and a Sigmoid activation layer connected in sequence. The first intermediate feature is input into the dual-path dynamic gating mechanism to obtain the intermediate-layer enhancement feature, including: inputting the first intermediate feature into the first depthwise convolutional branch to obtain a first spatial texture feature; inputting the first intermediate feature into the second depthwise convolutional branch to obtain a second spatial texture feature; inputting the first intermediate feature into the dynamic gain generation branch to obtain a set of dynamic gain coefficients, splitting the dynamic gain coefficients into a first gating weight and a second gating weight; multiplying the first gating weight and the second gating weight element-wise with the first spatial texture feature and the second spatial texture feature respectively, and then adding and fusing them to obtain the intermediate-layer enhancement feature.
[0033] Specifically, the Fusion Correction Module (FCM module) is used to resolve semantic conflicts and information aliasing issues that occur during multi-scale feature aggregation. For the detection of diseases in *Polygonatum odoratum* in this embodiment, special consideration is needed due to the significant differences in lesion size. The structural diagram of the FCM module is shown below. Figure 3 As shown. The execution flow of the FCM module starts with spatial dimension alignment and preliminary fusion, first processing the features... and characteristics Spatial DimensionAlignment is used to achieve size uniformity, and then channel dimension concatenation is performed to obtain an initial fused feature map with cross-level semantic information, specifically: (1) in, This is the initial fused feature map. Align `Concat` is the spatial dimension alignment operator, and `Concat` is the channel dimension concatenation operation.
[0034] To achieve dynamic adjustment of the weights of the fused features, the FCM module proposes a global channel calibration mechanism. The concatenated initial fused features are sequentially processed through adaptive average pooling, a first convolution, a SiLU activation function, a second convolution, and a Sigmoid activation to obtain channel gain coefficients. This processing path constitutes a global channel weight generation unit. The channel gain coefficients are then processed through channel broadcasting, using dimensionality compression (Squeeze), repeat interleave, and dimensionality expansion (Unsqueeze) operations to adjust them to the same dimension as the initial fused features. Element-wise multiplication is then performed, followed by non-linear mapping through two cascaded convolutional modules, specifically: (2) in, The first intermediate feature is obtained after global channel calibration and nonlinear mapping of the initial fused features. It is the Sigmoid activation function. It is a nonlinear mapping layer consisting of two concatenated convolutional modules. For average pooling operation, Conv This is a convolution operation; SiLU The SiLU activation function is used. This process effectively suppresses the response of irrelevant background levels and enhances features related to lesion targets. The channel-calibrated features are nonlinearly mapped by two cascaded convolutions, batch normalization, and SiLU activation units (2×Conv-BN-SiLU), thereby smoothing feature perturbations at the fusion boundary.
[0035] The FCM module uses a dual-path dynamic gating mechanism at its end to finely select features. The first intermediate feature... The inputs are fed into two parallel depthwise convolutional branches on the left and right, respectively, to extract spatial texture features under different receptive fields. Simultaneously, the first intermediate feature is input into the middle dynamic gain generation branch, generating a set of dynamic gain coefficients (gains), which are then divided into... and Two independent gating weights are used to adjust the feature outputs of the left and right DWConv branches, respectively: (3) in, and These are the first gating weight and the second gating weight, respectively. The first gating weight and the second gating weight are two independent gating weights. Split This means that the dynamic gain coefficients of the dynamic gain generation branch output are split along the channel dimension into the first gating weights. Second gating weight This structure can dynamically adjust the weights of each branch based on the currently input lesion features, thereby enhancing the ability to extract the edge features of lesions in Polygonatum odoratum.
[0036] Finally, the outputs of the left and right depthwise convolutional branches are multiplied element-wise by the first and second gate weights, respectively. The resulting two gated weighted features are then added and fused to obtain the enhanced features with multi-scale adaptive capabilities. Specifically: (4) in, , This involves two depthwise convolution operations, one on the left and one on the right.
[0037] In one embodiment, the dynamic feature refinement module includes: a channel grouping operator, a symmetric complementary dual-branch structure, and a cross-spatial aggregation module based on the EMA mechanism; the symmetric complementary dual-branch structure includes a first branch and a second branch; the first branch includes a vertical adaptive average pooling operator, a horizontal adaptive average pooling operator, a permute operation, a concatenation operation, a 1×1 convolutional layer, a split operation, a Sigmoid activation function, an element-wise multiplication operation, and a batch normalization layer; the second branch includes a 1×5 depth strip convolutional layer, a batch normalization layer, a SiLU activation layer, and a 5×1 depth strip convolutional layer connected in sequence; the cross-spatial aggregation module based on the EMA mechanism includes... The process includes global average pooling, reshape, softmax normalization, permute, matrix multiplication, sigmoid activation, element-wise multiplication, and average fusion. After processing the shallow enhanced features through a dynamic feature refinement module, the first-scale optimized features are obtained. This includes processing the shallow enhanced features using a channel grouping operator to obtain grouped features, and inputting these grouped features into the first and second branches respectively. In the first branch, the grouped features are processed using vertical adaptive average pooling and horizontal adaptive average pooling operators to obtain vertical and horizontal features. The horizontal features are then permute. The `mute` operation concatenates the result with the vertical features, and then processes the concatenated result through a 1×1 convolutional layer. The resulting convolutional result is then split into vertical and horizontal perceptual features using a `split` operation. The vertical perceptual features are activated using a sigmoid function to obtain vertical perceptual weights, and the horizontal perceptual features are sequentially activated using a `permute` operation with a sigmoid function to obtain horizontal perceptual weights. The grouped features, vertical perceptual weights, and horizontal perceptual weights are then multiplied element-wise, followed by batch normalization to obtain the output features of the first branch. In the second branch, the grouped features are... After passing through a 1×5 depth strip convolutional layer, a batch normalization layer, a SiLU activation layer, and a 5×1 depth strip convolutional layer, the second branch output features are obtained. The first branch output features, the second branch output features, and the grouped features are input into a cross-space aggregation module based on the EMA mechanism. The first branch output features are then processed by global average pooling, reshape and softmax normalization, and permute operation. The resulting processing is then combined with the reshape-processed second branch output features by matrix multiplication. The resulting processing is then subjected to reshape and Sigmoid activation to obtain the first spatial weights.The output features of the second branch are sequentially processed by global average pooling, reshape and softmax normalization, and permute. The result is then multiplied by matrix multiplication with the reshaped output features of the first branch. The result is then reshaped and activated by sigmoid to obtain the second spatial weights. The first and second spatial weights are then multiplied element-wise with the grouped features to obtain the first weighted features and the second weighted features. The first and second weighted features are then averaged and fused to obtain the average fusion result. The average fusion result is then reshaped and added to the shallow enhancement features by residual calculation to obtain the first scale optimized feature, calculated using the following formula: (5) in, For the first-scale optimization features, Grouped features obtained by channel grouping shallow enhancement features These are the output features of the first branch and the output features of the second branch, respectively. This is a shallow enhancement feature; It is the Sigmoid activation function. For average pooling operation, Represents matrix multiplication. This indicates element-wise multiplication.
[0038] Specifically, the Dynamic Feature Refinement (DFRM) module is designed as a feature representation method for the morphology of lesions in *Polygonatum odoratum*. Its execution flow is a process of guiding global coordinates to local geometric fitting. The DFRM module structure diagram is as follows. Figure 4 As shown, the input feature X is first processed by the channel grouping operator to obtain the grouped features. The aim is to reduce the computational density of subsequent subspaces while establishing multiple sets of parallel subspace representations. The module uses parallel-deployed vertical and horizontal adaptive average pooling operators to capture long-range spatial dependencies. The resulting vertical and horizontal features are concatenated and then processed sequentially through 1×1 convolution and split operations, followed by Sigmoid activation to obtain the vertically aware weights. and horizontal sensing weights At the feature level, direction-aware encoding is implemented (Equation 6). DFRM uses a symmetrical and complementary two-branch structure to extract features. The first branch groups the features. The vertical and horizontal perception weights are multiplied element-wise, and then batch normalized to stabilize the channel statistical characteristics and feature distribution, yielding the first branch output features. These grouped features are then processed. The second branch output features are obtained by sequentially processing 1×5 depth strip convolution, batch normalization, SiLU activation, and 5×1 depth strip convolution, which improves the model's accuracy in capturing the nonlinear morphological details of lesions (see Formula 7).
[0039] To suppress discrete noise in the field background, this module employs cross-spatial aggregation based on the EMA mechanism. This mechanism generates first and second spatial weights through bidirectional matrix multiplication of the first and second branch output features. These spatial weights are then used to dynamically modulate the same group of features, achieving cross-spatial feature aggregation and spatial gain. This bidirectional interaction helps reduce the interference of point-like background noise on the strip-shaped necrotic tissue features, improving the feature signal-to-noise ratio of the target region. Finally, the module fuses the cross-spatial aggregated features with the original input features through global residual connections to obtain the final first-scale optimized features. (See Formula 5) to provide high-resolution enhanced features for subsequent multi-scale feature fusion of the neck network and detection head.
[0040] (6) (7) in, These are the vertical perception weights and the horizontal perception weights, respectively.
[0041] In one embodiment, the dual-enhancement detection head includes three color anomaly attention modules, one small target enhancement module, and a decoupled detection head. The decoupled detection head includes dual-branch detection heads corresponding to three feature scales, each including a classification branch and a bounding box regression branch. In the dual-enhancement detection head: the first-scale optimized features are input into the first color anomaly attention module; the first-scale optimized features are divided into g subgroups according to the channel dimension; adaptive average pooling and two-layer nonlinear mapping are performed on each subgroup to obtain the local perceptual weights corresponding to each subgroup; each local perceptual weight is multiplied element-wise with the corresponding subgroup features; the resulting weighted features of each subgroup are then concatenated along the channel dimension to obtain the first-scale local features; the first-scale optimized features are sequentially subjected to global average pooling, flattening, first linear layer processing, SiLU activation, second linear layer processing, and Sigmoid activation; and the processing results are dimensionally reshaped to obtain... The first-scale global perception weights are broadcast to the first-scale local features. The first-scale global perception weights are then multiplied element-wise with the first-scale local features, and the result is added to the residual of the first-scale optimized features to obtain the first-scale color enhancement features. The second-scale and third-scale optimized features are processed in the same way as the first-scale optimized features, respectively, through the second and third color anomaly attention modules to obtain the second-scale and third-scale color enhancement features. The first-scale color enhancement features are then input into the micro-target enhancement module for processing to obtain the first-scale final enhancement features. The first-scale final enhancement features, second-scale color enhancement features, and third-scale color enhancement features are then input into the corresponding scale dual-branch detectors, and processed through the classification branch and bounding box regression branch of each dual-branch detector to obtain the plant leaf disease and pest category identification results and bounding box coordinates.
[0042] In one embodiment, the micro-target enhancement module includes a high-frequency residual extraction branch, a gated weight generation branch, and an output mapping module. The high-frequency residual extraction branch includes average pooling, subtraction, convolutional layers, and batch normalization layers. The gated weight generation branch includes an average pooling layer, a first gated convolutional layer, a SiLU activation layer, a second gated convolutional layer, and a Sigmoid activation layer connected in sequence. The output mapping module includes a convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence. The first-scale color enhancement feature is input into the micro-target enhancement module for processing to obtain the first-scale final enhancement feature, including: inputting the first-scale color enhancement feature into the high-frequency residual extraction branch and performing average pooling on the first-scale color enhancement feature to obtain a smooth feature. The high-frequency residual features are obtained by subtracting the first-scale color enhancement features from the smoothing features. These high-frequency residual features are then subjected to convolution and batch normalization to obtain high-frequency enhancement features. The high-frequency enhancement features are then added to the first-scale color enhancement features using residuals to obtain the second intermediate features. The first-scale color enhancement features are input into the gating weight generation branch and subjected to average pooling, first-gated convolution, SiLU activation, second-gated convolution, and Sigmoid activation to obtain the third intermediate features, which are then used as the gating attention map. The second and third intermediate features are then multiplied element-wise, and the result is input into the output mapping module, where it is subjected to convolution, batch normalization, and SiLU activation to obtain the final first-scale enhancement features.
[0043] Specifically, the structure of the dual-enhanced detection head is as follows: Figure 5 As shown, the Bi-Enhance DetectHead is the decision center of LSFA-YOLO, which can improve the ability of the standard decoupled detector head to capture small lesions of Polygonatum odoratum in complex backgrounds. This detector head includes three Color Anomaly Attention Modules (CAA), one Small Target Enhancement Module (STB), and one decoupled detector head. The CAA and STB constitute a dual enhancement pipeline, forming an enhancement process from global and local color feature modeling to high-frequency detail compensation, thereby ensuring that the network feature representation corresponds to the physical characteristics of the lesions.
[0044] The three optimized features at different scales are processed by the Color Anomaly Attention (CAA) module, which primarily enhances features in areas where leaf discoloration and wilting are caused by diseases affecting *Polygonatum odoratum*. Input features are then processed for any scale. CAA employs a dual-path collaborative parallel structure. The first path divides the input features into g subgroups along the channel dimension. Within each subgroup, independent adaptive pooling and a two-layer nonlinear mapping are used to form local perceptual weights. These local perceptual weights are then multiplied element-wise with the corresponding subgroup features. Finally, the weighted features of each subgroup are concatenated along the channel dimension to obtain the local features. This enhances the local color anomaly response in each channel subgroup (Equation 8). Simultaneously, the second path uses global average pooling and a multilayer perceptron (MLP) to extract the global interaction vector across channels, which is then activated by a sigmoid function to obtain the global perceptron weights. Furthermore, the global perception weights are dimensionally reshaped so that they can be broadcast to local features to dynamically adjust the distribution of local features (Formula 9).
[0045] The local features are multiplied element-wise with the global perception weights, and the result is added to the residual of the input features at the corresponding scale to obtain the color enhancement features at the corresponding scale. (Formula 10).
[0046] (8) (9) (10) in, For local features, For globally perceived weights, The current scale optimization features are used as input to the color anomaly attention module. The i-th subgroup feature obtained by dividing the current scale optimized features according to the channel dimension. The color enhancement features are obtained by processing the current scale optimized features through the color anomaly attention module. It is the Sigmoid activation function. This is the SiLU activation function.
[0047] First-scale color enhancement features of P3 layer carrying a large amount of micro-texture information The dual-enhancement detection head further incorporates a Small Target Enhancement (STB) module to compensate for potential edge information loss during downsampling in deep networks. The STB module employs a high-frequency residual extraction path, subtracting the first-scale color enhancement features from the smoothed features obtained through average pooling, and then sequentially processing these subtracted features through convolution and batch normalization to obtain the high-frequency residual features. See formula (11) for details. Simultaneously, the module utilizes parallel gated weight generation paths to model the smoothed global background information, sequentially processing it through average pooling, convolution, SiLU activation, convolution, and Sigmoid activation to generate a gated attention map with global weighting capabilities. (See Formula 12). In the fusion stage, the high-frequency residual components are added to the first-scale color enhancement features, and then multiplied element-wise with the gated attention map (⊙). Finally, a nonlinear mapping is performed through the output mapping module composed of convolution, batch normalization, and SiLU activation to obtain the final enhancement features. (See Formula 13). This high-frequency detail enhancement scheme significantly improves LSFA. YOLO's ability to identify needle-like or filamentous necrotic tissue on the leaves of *Polygonatum odoratum*. Specifically: (11) (12) (13) In the final prediction, the three enhanced features at different scales after processing by the dual-enhanced detection head are respectively sent to the prediction branches at the corresponding scales in the decoupled detection head. The decoupled detection head, following the task separation principle of translation invariance for classification tasks and translation equivariance for regression tasks, performs pest and disease category prediction and bounding box regression respectively through parallel classification and bounding box regression branches. Its output calculation process is shown in (14). Input features at each scale of the decoupled detection head. The definition is shown in formula (15). Through an enhancement process that goes from color abnormality feature enhancement to geometric detail compensation for minute lesions, LSFA-YOLO can still achieve good localization robustness and detection accuracy for atypical lesions in *Polygonatum odoratum* even with fewer than 3M parameters. Specifically: (14) (15) in, , These are the prediction results for pest and disease categories and the bounding box regression results, respectively. For classification branches, For the bounding box regression branch, For the first Features of the decoupled detection head at each scale input .
[0048] In one embodiment, the method further includes: obtaining the batch normalized layer scaling factor of each layer to be pruned in the backbone network and neck network, using the absolute value of the scaling factor as the importance score of the corresponding channel, globally sorting the importance scores of each channel to be pruned, and removing channels with lower importance scores according to a preset pruning ratio; retaining the SPPF module and dual-enhancement detection head during the pruning process, and performing synchronous pruning and channel dimension alignment processing on the channels involved in residual connections and feature splicing to obtain a lightweight pest and disease detection model after pruning.
[0049] Specifically, (1) the principle of pruning methods Model pruning is a classic technique in model compression. It primarily identifies and removes redundant parameters or structures from neural networks, thereby reducing model complexity. Based on the pruning granularity, it can be divided into unstructured pruning and structured pruning. Unstructured pruning sparsifies at the unit weight level, achieving high compression ratios, but requiring dedicated hardware for practical acceleration. Structured pruning, on the other hand, prunes at the filter or channel level, maintaining the regular matrix operation form of the pruned model, allowing direct deployment on general-purpose hardware platforms for accelerated inference.
[0050] Channel pruning is a type of structured pruning, and its basic principle is as follows: Figure 6 As shown. For a certain layer in a convolutional neural network, let the number of input feature map channels be... The number of channels in the output feature map is Then the layer contains There are n convolutional filters, each with a dimension of n. (K is the kernel size). Channel pruning reduces the importance of each output channel, removes less important channels and their corresponding convolutional filters, and reduces the number of input channels in the next layer accordingly, thereby simplifying the network structure.
[0051] Let the parameters of the l-th convolutional layer be... The set of channel indices retained after pruning is Then the parameters after pruning The number of input channels in the (l+1)th layer becomes accordingly. In this way, channel pruning can reduce the number of parameters and computational cost simultaneously while maintaining the regularity of network forward propagation.
[0052] Channel pruning is essentially a sparsity constraint, which involves sparsifying the network's feature representations. Deep neural networks are prone to overparameterization during training, meaning that many channels produce very similar or repetitive feature representations. By using appropriate sparsity constraints to eliminate low-contribution channels, we can achieve efficient model compression while minimizing performance loss.
[0053] (2) Methods for identifying and assessing the importance of prunable layers Not all layers can be pruned; only some can. Convolutional layers are generally the primary targets for pruning. The batch normalization layer parameters corresponding to the pruned convolutional layer, as well as the input channels of subsequent layers, need to be adjusted synchronously. The input and output dimensions of activation layers also change accordingly with the number of channels in the preceding layers. Specifically, for convolution-normalization-activation (Conv-BN-SiLU) combination units that include batch normalization (BN) layers, the scaling factor of the BN layer can serve as an effective measure of channel importance.
[0054] The batch normalization layer standardizes the input of each layer based on the statistics of the mini-batch data, which can speed up model training and make the model more stable. Its forward propagation process can be represented as (16) and (17): (16) (17) Where x is the input feature of the batch normalization layer. Here, y represents the standardized features, and y represents the output features of the batch normalization layer. and The data is divided into the mean and variance of mini-batch data, where γ and β are learnable scaling and bias coefficients. To prevent division by zero of extremely small constants. In channel pruning, the scaling factor γ has important indicative significance. Channels with larger |γ| values have a more significant impact on the network output, while channels with |γ| values close to zero have their output features almost suppressed after scaling, contributing negligibly to subsequent layers and can be considered redundant channels. Based on this, this method uses the absolute value of the scaling factor γ based on the BN layer as the channel importance evaluation index, where the absolute value is equivalent to the L1 norm of the scalar scaling factor. For the i-th channel in the l-th layer, its importance score is defined as (18): (18) Under the global pruning strategy, the scaling coefficients γ of all layers to be pruned in the network are collected, globally sorted according to channel importance scores, and the channel with the lowest score is removed according to a preset pruning ratio ρ. The advantages of this method are its simplicity, low computational cost, and low coupling with the network training process, making it easy to apply directly to pre-trained models. It should be noted that the above importance assessment method assumes that the importance of each channel can be measured independently. For deep networks with complex feature interactions, this assumption may have certain limitations. However, in practical applications, channel importance assessment based on Batch Normalization (BN) scaling coefficients has been widely validated for its effectiveness, achieving a good balance between performance and implementation complexity.
[0055] (3) Pruning strategy design 1) Selection of pruning targets Not all layers in the target detection network can be pruned. Based on the characteristics of the *Polygonatum odoratum* disease detection task, this invention focuses on pruning the feature extraction layer in the backbone network and the feature fusion and refinement layer in the neck network. The DFRM (Dynamic Feature Refinement Module) in the neck network has strong shape recognition capabilities, but still exhibits some channel redundancy after depthwise convolution. While the FCM (Fusion Correction Module) in the neck network improves multi-scale feature fusion efficiency, it contains multiple convolutional layers; pruning low-importance channels reduces the computational cost of multi-layer feature aggregation. The Color Anomaly Attention Module (CAA) and the Small Target Enhancement Module (STB) in the dual-enhancement detection head are responsible for color anomaly feature enhancement and high-frequency detail compensation for small lesions, respectively, and the final classification and bounding box regression are completed by the decoupled detection head. To avoid weakening the model's ability to detect early small lesions and atypical lesions through pruning, this method retains the SPPF module and the dual-enhancement detection head without performing structured channel pruning, thus maintaining the model's stability in detecting anisotropic lesions.
[0056] 2) Channel alignment processing When performing channel pruning, the residual connections and feature fusion operations in the network must unify the number of channels. Without this, feature map dimensionality mismatches will occur, preventing forward propagation. This section mainly discusses two typical connection structures that appear in the improved model.
[0057] The C2f module in the improved model backbone network widely adopts residual connections, that is, the output of the main branch is added element-wise to the output of the shortcut branch. Let the number of output channels of the main branch be... The number of output channels for the shortcut branch is Normal requirements After pruning, if the number of channels or channel indices retained by the main branch and the shortcut branch are inconsistent, element-wise addition of the outputs of the two branches will be impossible. To address this issue, this method employs a synchronous pruning strategy: for layers with residual connections, a unified set of retained channel indices is determined based on the importance scores of the corresponding channels in both branches, and the same pruning mask is applied to both branches to ensure that the number of channels and channel indices retained by the two branches are consistent after pruning. To maintain the effectiveness of residual connections.
[0058] Feature fusion in the neck network is accomplished using cross-layer feature map concatenation or element-wise addition. Taking concatenation as an example, if the two feature maps to be fused have channels C1 and C2 respectively, and after pruning they become C1′ and C2′, then the total number of channels after concatenation is C1′ + C2′, and the input channel count of subsequent layers must be adjusted accordingly. This method, during the model reconstruction phase, calculates the input and output channel count of each layer sequentially from the shallowest layers, following the network's forward topology. For nodes with feature concatenation, the input channel count of subsequent layers is determined by the sum of the channels retained after pruning each input branch. This ensures that the input channel count of each layer matches the upstream output features and connection operation results, avoiding runtime errors due to inconsistent channel dimensions.
[0059] In a verification embodiment, the method was verified using a public tomato leaf disease and pest dataset (dataset 1) and a self-built *Polygonatum odoratum* disease and pest dataset (dataset 2).
[0060] (1) Ablation test results The ablation experiments used a single-module and module combination control approach to evaluate the independent contributions of the DFRM, FCM, and Bi-EnhanceDetect Head modules to model performance. Tables 1 and 2 show the changes in metrics for each module combination under two different datasets.
[0061] Table 1. Ablation Experiment Results of Dataset 1 (Tomato Leaf Diseases and Pests Dataset)
[0062] Table 2. Ablation Experiment Results of Dataset 2 (Xiangyuzhu Leaf Diseases and Pests Dataset)
[0063] Note: All experiments above used YOLOv8n as the baseline model. √ indicates that the module was included, blank indicates that the module was not included, and BEDH indicates Bi-Enhance Detect Head.
[0064] To test the applicability of the improved strategy to leaf lesion characteristics of different plants, eight ablation experiments were conducted on the public tomato leaf disease and pest dataset (Dataset 1) and the self-built *Polygonatum odoratum* disease and pest dataset (Dataset 2), using YOLOv8n as the baseline model. Tables 1 and 2 show that, based on the changing trends of various performance indicators, the roles and synergistic relationships of each improved module in the feature modeling process can be obtained.
[0065] From the perspective of the relationship between global parameter quantity and detection accuracy, LSFA YOLO demonstrated significant performance gains and a lightweight design in both sets of experiments. With the number of parameters reduced from 3.011 M to 2.039 M (a reduction of approximately 32.3%), the model achieved a significant increase in mAP50 on the *Polygonatum odoratum* dataset, from 68.5% to 81.5%. This result indicates that by introducing modules adapted to the morphology and multi-scale features of plant lesions, the expressive power of pest and disease characteristics can be enhanced while reducing the number of model parameters.
[0066] Comparing Experiment 2 with the baseline model, it was found that DFRM significantly improved the mAP50 of the *Polygonatum odoratum* dataset compared to the tomato dataset. Specifically, the mAP50 on the tomato dataset increased from 87.6% to 88.1%, an improvement of 0.5 percentage points; while the mAP50 on the *Polygonatum odoratum* dataset increased from 68.5% to 73.0%, an improvement of 4.5 percentage points. This phenomenon may be related to the morphological differences between tomato and *Polygonatum odoratum* lesions. Tomato lesions are mostly nearly circular or relatively isotropic, while *Polygonatum odoratum* lesions, influenced by the parallel vein direction, exhibit more obvious directional and elongated edge characteristics. DFRM enhances the directional geometric edges through deep strip convolution, thus showing a more significant fit when dealing with elongated lesions in *Polygonatum odoratum*. In the self-built *Polygonatum odoratum* dataset, the accuracy of the baseline model was 72.5%, which increased to 79.2% after introducing the FCM module alone, an improvement of 6.7 percentage points. The results show that FCM, through spatial dimension alignment, global channel calibration, and dual-path dynamic gating mechanisms, helps reduce semantic aliasing and spurious responses in non-target regions during cross-scale feature fusion, improving the model's recognition reliability under complex lighting and background interference conditions. Experiment 4 and its combination with FCM and DFRM demonstrate that the dual-enhancement detection head, including a color anomaly attention module and a small target enhancement module, is beneficial for enhancing the feature representation of color anomalies, small lesions, and weakly textured targets. In Dataset 2, the final recall rate of this method reached 79.2%, an improvement of 11.1 percentage points compared to the baseline model's 68.1%. These results indicate that from DFRM's perception of lesion directional morphology to FCM's fusion and correction of multi-scale features, and then to the dual-enhancement detection head's compensation for color anomalies and small edge details, the modules constitute a synergistic feature enhancement process. This method shows certain applicability on a public tomato leaf disease and pest dataset and exhibits good domain adaptability in scenarios such as anisotropic diffusion of lesions in *Polygonatum odoratum* and early small edge blurring.
[0067] (2) Comparison of experimental results with mainstream models To comprehensively verify the overall competitiveness of this method in the detection of plant leaf diseases and pests, this section selects representative lightweight models such as YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, YOLOv12n, and YOLO26n, and compares them with representative detection models such as FFCA-YOLO and DynamicDet. The comparative experiments aim to compare the balance between model parameter size and detection performance of this method in two aspects: the detection performance on the public tomato leaf disease and pest dataset (Table 3) and the domain adaptation performance on the self-built *Polygonatum odoratum* leaf disease and pest dataset (Table 4).
[0068] Table 3 Comparison Experiment of Dataset 1 (Tomato Leaf Diseases and Pests Dataset)
[0069] Table 4 Comparative Experiment of Dataset 2 (Xiangyuzhu Leaf Diseases and Pests Dataset)
[0070] In comparison with the public tomato pest and disease dataset (Dataset 1), this method demonstrates strong detection performance. Experimental results show that, with only 2.039 M parameters, this method achieves an mAP50 of 88.8%, outperforming the benchmark models YOLOv8n, YOLOv12n, and YOLO26n. Under more stringent mAP50 conditions... On the 95-point scale, our method outperforms other lightweight models with 79.2%, which is also higher than the 76.6% achieved by DynamicDet with 79.43 M parameters. Combined with the aforementioned ablation experiment results, this demonstrates that the cross-scale feature correction of the fusion correction module and the enhancement of color anomalies and minute details by the dual-enhanced detection head are beneficial to improving the overall detection accuracy of the model under different IoU thresholds.
[0071] Specific tests targeting diseases and pests of *Polygonatum odoratum* (dataset 2) further demonstrated the model's domain adaptability. Faced with the significant anisotropy of *Polygonatum odoratum* lesions and complex field backgrounds, our method achieved an mAP50 of 81.5%, a 13 percentage point improvement over the benchmark model, while reducing the number of parameters by 32.3%. This performance also surpasses DynamicDet (78.0%) and the latest lightweight state-of-the-art model YOLO26n (80.7%). Experiments show that DFRM enhances the directional texture and geometric edges of lesions through deep strip convolution, enabling the model to effectively extract key discriminative features of *Polygonatum odoratum* lesions even with a smaller number of parameters. Furthermore, our model's accuracy of 84.5% ranks first among the comparative models, indicating good false alarm suppression capabilities in complex field environments.
[0072] (3) Comparison of experimental results with different pruning rates To investigate the effect of different pruning ratios on model performance, experiments were conducted with pruning ratios of 10%, 15%, and 20%, respectively. The results are shown in Table 5.
[0073] Table 5 Comparison of model performance under different pruning ratios
[0074] The experimental results show that the number of parameters and the model file size of this method decrease linearly with the increase of the pruning ratio. At pruning intensities of 10% and 15%, the model's mAP50 remains relatively stable, decreasing by only 0.1% and 0.3%, respectively. This indicates that there is some channel redundancy in the improved architecture. Using the scaling factor γ of the BN layer for channel filtering can effectively remove channels that contribute less to the expression of lesion features in *Polygonatum odoratum*. At a pruning ratio of 20%, all performance indicators show a significant decrease. Specifically, mAP50 drops to 78.3%, and recall also decreases by 3.9%. This suggests that a higher pruning ratio may remove some important channels, weakening the ability of the backbone and neck networks to express lesion texture and edge features, and indirectly affecting the detection head's ability to detect small lesions. Considering both compression efficiency and accuracy preservation, at a 15% pruning ratio, the number of parameters in this method is compressed to 1.733M, while the mAP50 still reaches 81.2%. Therefore, this is considered the preferred pruning scheme in this embodiment.
[0075] (4) Comparison of existing lightweight models with experimental results To verify the effectiveness of the pruning method of the present invention, the model obtained by pruning was compared with the existing lightweight target detection model on the self-built Xiangyuzhu leaf disease and pest dataset (dataset 2). The results are shown in Table 6.
[0076] Table 6 Performance Comparison with Existing Lightweight Models
[0077] As shown in Table 6, the Prune-15% model, with 1.733 M parameters, still achieves an mAP50 of 81.2%, which is higher than lightweight models such as YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, YOLOv12n, and YOLO26n. This indicates that at a 15% pruning ratio, the structured channel pruning method used in this invention can maintain good detection performance while reducing the number of model parameters, making it highly valuable for edge device deployment.
[0078] (5) Visualized detection result analysis To further verify the detection efficiency of this method in real-world complex farmland environments from a qualitative perspective, this invention selected typical field scene images from the self-built dataset of *Polygonum aviculare* and compared the detection results of this method with benchmark models YOLOv8n, YOLOv9t, YOLOv10n, YOLOv11n, YOLOv12n, YOLO26n, FFCA-YOLO, and DynamicDet-YOLO. The visualized detection results are shown below. Figures 7 to 16 As shown in the figure, the blue boxes in the detection results graph of each model represent the model prediction boxes, the numbers represent the prediction confidence, the red boxes represent the missed targets, and the orange boxes represent the falsely detected targets.
[0079] The comparison reveals that mainstream models such as the benchmark YOLOv8n, YOLOv10n, and YOLOv12n exhibit significant missed detections when handling early-stage small lesions and have limited ability to represent the geometric edges of banded lesions. In contrast, LSFA... YOLO was able to capture most occult lesions, missing only one, with a highest recognition confidence of 0.71, demonstrating good weak feature perception capabilities. Meanwhile, LSFA-YOLO's predicted bounding boxes for atypical lesions better matched the labeled areas, maintaining good detection performance even against complex backgrounds of red soil and weed interference. Combined with the aforementioned ablation experiment results, this indicates that DFRM, FCM, and dual-enhanced detection heads are beneficial for enhancing the edges of directional lesions, reducing background interference, and improving the detection capability of small lesions.
[0080] To address the challenges of identifying plant leaf diseases and pests in complex field environments, the similarity of features between disease and pest categories while significant differences within categories, and the difficulty of deploying edge devices, a deeply customized LSFA-YOLO lightweight detection model (the disease and pest detection model proposed in this application) is proposed. Since the lesions of *Polygonatum odoratum* exhibit a strip-like physical manifold due to the restriction of leaf veins, a Dynamic Feature Refinement Module (DFRM) is set in the neck network. This module utilizes a deep strip convolution operator to enhance the directional texture and geometric edge features of the lesions, improving the insufficient edge representation problem of traditional convolution when handling irregularly shaped targets. In the feature fusion stage, an Integrated Fusion Correction Module (FCM) is employed. Through spatial dimension alignment, global channel calibration, and dual-path dynamic gating processing, semantic redundancy and feature aliasing caused by scale differences are reduced, improving the feature signal-to-noise ratio of the model in complex backgrounds. To address the issue of early-stage, small lesions being easily missed or falsely detected, a novel Bi-Enhance DetectHead is proposed. This head utilizes a Color Anomaly Attention Module (CAA) and a Small Target Enhancement Module (STB) to enhance high-frequency edge details of local color anomalies and small lesions on leaves, respectively. To further improve the algorithm's efficiency in resource-constrained scenarios, a structured channel pruning technique based on batch normalization layer scaling coefficients is introduced. By retaining the SPPF module and the Bi-Enhancement DetectHead, low-importance channels in the backbone and neck networks are pruned, while the channels involved in residual connections and feature splicing are dimensionally aligned. Experimental results show that the improved LSFA-YOLO model exhibits superior performance on the self-built Xiangyuzhu dataset. With a 15% pruning ratio, the model parameters are compressed to 1.733 M, the model file size is only 3.81 MB, and mAP@0.5 is still maintained at a high level of 81.2%. Compared with mainstream lightweight models such as YOLOv8n and YOLOv12n, this method achieves a better balance between detection accuracy and lightweight design, providing a technical basis for field monitoring of plant leaf diseases and pests and the deployment of edge devices.
[0081] It should be understood that, although the above Figure 1 The steps are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated in this document, there is no strict order in which these steps are executed; they can be performed in other orders. Furthermore, the above... Figure 1 At least some of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0082] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0083] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of protection of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and all such modifications and improvements fall within the scope of protection of this application.
Claims
1. A lightweight method for detecting plant leaf diseases and pests based on an improved YOLOv8, characterized in that, Including the following steps: Acquire images of the plant leaves to be detected; The plant leaf images are processed using a pest and disease detection model to obtain the identification results of plant leaf pest and disease categories and bounding box coordinates; The pest and disease detection model includes a backbone network, a neck network, and a dual-enhanced detection head connected in sequence; the backbone network is used to extract multi-scale features from plant leaf images using the YOLOv8 backbone network. The neck network employs a bidirectional pyramid structure to fuse and correct multi-scale features output from the backbone network. The top-down branches transmit high-level semantic information to lower levels via upsampling and fusion correction modules. The bottom-up branches first refine high-resolution shallow enhancement features through a dynamic feature refinement module, then transmit low-level positional information to higher levels via convolutional layers and the fusion correction module, ultimately outputting three optimized features at different scales. The fusion correction module performs spatial dimension alignment and channel concatenation on features from two different levels or propagation paths, then sequentially performs global channel calibration, nonlinear mapping, and dual-path dynamic gating to output multi-scale adaptive enhancement features. The dynamic feature refinement module performs orientation-aware modeling and cross-spatial aggregation on high-resolution shallow enhancement features, and uses deep strip convolution to enhance the geometric edge features of elongated lesions. The dual-enhancement detection head is used to perform color anomaly attention enhancement on the three optimized features respectively, and to perform micro-target enhancement on the first-scale color enhancement feature. The micro-target enhancement results and the second and third-scale color enhancement features are respectively input into the dual-branch detection head of the corresponding scale to generate plant leaf disease and pest category recognition results and bounding box coordinates.
2. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 1, characterized in that, The neck network includes four fusion correction modules, one dynamic feature refinement module, and two convolutional layers; The plant leaf images are processed using a pest and disease detection model to obtain pest and disease category identification results and bounding box coordinates, including: The above plant leaf images are input into the backbone network to obtain shallow features, medium features, and deep features; The shallow, mid-layer, and deep features are input into the neck network. In the top-down branch of the neck network, the deep features are upsampled and then input into the first fusion correction module along with the mid-layer features to obtain the mid-layer enhanced features. The mid-layer enhanced features are upsampled and then input into the second fusion correction module along with the shallow features to obtain the shallow enhanced features. In the bottom-up branch of the neck network, the shallow enhanced features are processed by the dynamic feature refinement module to obtain the first scale optimized features. The first scale optimized features are processed through the first convolutional layer and then input into the third fusion correction module along with the mid-layer enhanced features to obtain the second scale optimized features. The second scale optimized features are processed through the second convolutional layer and then input into the fourth fusion correction module along with the deep features to obtain the third scale optimized features. The first-scale optimized feature, the second-scale optimized feature, and the third-scale optimized feature are input into the dual-enhanced detection head to obtain the identification results of plant leaf diseases and pests and the bounding box coordinates.
3. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 2, characterized in that, The fusion correction module includes: a spatial dimension alignment module, a splicing operation, a weight generation module, a channel broadcast processing module, a nonlinear mapping layer, and a dual-path dynamic gating mechanism; The upsampled deep features and the mid-layer features are input into the first fusion correction module to obtain mid-layer enhanced features, including: The deep features are upsampled to obtain the first upsampled features; The first upsampled feature and the middle layer feature are input into the spatial dimension alignment module, and processed by the spatial dimension alignment operator respectively to obtain the first alignment feature and the second alignment feature with the same spatial size. The first alignment feature and the second alignment feature are concatenated along the channel dimension to obtain an initial fusion feature with cross-level semantic information. The initial fusion features are input into the weight generation module to obtain the channel gain coefficients; The channel gain coefficient is input into the channel broadcast processing module, and the dimension of the channel gain coefficient is adjusted to be consistent with the dimension of the initial fusion feature by using dimension compression, interleaving and expansion operations to obtain the dimension-adjusted channel gain coefficient. The dimension-adjusted channel gain coefficient is multiplied element-wise with the initial fusion feature and then input into the nonlinear mapping layer to obtain the first intermediate feature; The first intermediate feature is input into the dual-path dynamic gating mechanism to obtain the mid-level enhanced feature.
4. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 3, characterized in that, The weight generation module includes an adaptive average pooling layer, a first convolutional layer, a SiLU activation layer, a second convolutional layer, and a Sigmoid activation layer connected in sequence, used to process the initial fusion features and generate the channel gain coefficients.
5. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 3, characterized in that, The nonlinear mapping layer comprises two convolutional modules connected in series; each convolutional module comprises a convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence.
6. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 3, characterized in that, The dual-path dynamic gating mechanism includes three parallel branches: a first depthwise convolution branch, a second depthwise convolution branch, and a dynamic gain generation branch. Each depthwise convolution branch includes a depthwise convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence. The dynamic gain generation branch includes an average pooling layer, a first gain convolutional layer, a SiLU activation layer, a second gain convolutional layer, and a Sigmoid activation layer connected in sequence. The first intermediate feature is input into the dual-path dynamic gating mechanism to obtain the mid-level enhanced features, including: The first intermediate feature is input into the first depthwise convolution branch to obtain the first spatial texture feature; The first intermediate feature is input into the second deep convolution branch to obtain the second spatial texture feature; The first intermediate feature is input into the dynamic gain generation branch to obtain a set of dynamic gain coefficients, and the dynamic gain coefficients are split into a first gating weight and a second gating weight. The first gating weight and the second gating weight are multiplied element-wise with the first spatial texture feature and the second spatial texture feature, respectively, and then added and fused to obtain the mid-layer enhancement feature.
7. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 2, characterized in that, The dynamic feature refinement module includes: a channel grouping operator, a symmetric complementary bi-branch structure, and a cross-space aggregation module based on the EMA mechanism; The symmetric complementary bi-branch structure includes a first branch and a second branch; the first branch includes a vertical adaptive average pooling operator, a horizontal adaptive average pooling operator, a permute operation, a splicing operation, a 1×1 convolutional layer, a split operation, a Sigmoid activation function, an element-wise multiplication operation, and a batch normalization layer; the second branch includes a 1×5 depth strip convolutional layer, a batch normalization layer, a SiLU activation layer, and a 5×1 depth strip convolutional layer connected in sequence. The cross-space aggregation module based on the EMA mechanism includes global average pooling operation, reshape operation, softmax normalization operation, permute operation, matrix multiplication operation, sigmoid activation operation, element-wise multiplication operation, and average fusion operation. After the shallow enhancement features are processed by the dynamic feature refinement module, the first-scale optimized features are obtained, including: The shallow enhancement features are processed by the channel grouping operator to obtain grouped features, and the grouped features are input into the first branch and the second branch respectively. In the first branch, the grouped features are processed by vertical adaptive average pooling and horizontal adaptive average pooling operators respectively to obtain vertical and horizontal features. The horizontal features are permuteed, and the result is concatenated with the vertical features. The concatenated result is processed by the 1×1 convolutional layer. The convolutional result is split into vertical and horizontal perceptual features by a split operation. The vertical perceptual features are activated by a sigmoid function to obtain vertical perceptual weights. The horizontal perceptual features are permuteed by a sigmoid function to obtain horizontal perceptual weights. The grouped features, the vertical perceptual weights, and the horizontal perceptual weights are multiplied element-wise and then batch normalized to obtain the output features of the first branch. In the second branch, the grouped features are processed sequentially through a 1×5 depth strip convolutional layer, a batch normalization layer, a SiLU activation layer, and a 5×1 depth strip convolutional layer to obtain the output features of the second branch. The first branch output features, the second branch output features, and the grouping features are input into the cross-spatial aggregation module based on the EMA mechanism. The first branch output features are sequentially processed by global average pooling, reshape and softmax normalization, and permute. The resulting processing is then multiplied with the reshaped second branch output features using matrix multiplication. The result is then processed by reshape and sigmoid activation to obtain the first spatial weights. The second branch output features are sequentially processed by global average pooling, reshape and softmax normalization, and permute. The result is then multiplied with the reshaped first branch output features using matrix multiplication. The result is then processed by reshape and sigmoid activation to obtain the second spatial weights. The first spatial weights and the second spatial weights are then multiplied element-wise with the grouping features to obtain the first weighted features and the second weighted features. The first weighted features and the second weighted features are then averaged and fused to obtain the average fusion result. The average fusion result is reshaped and then added to the shallow enhancement features to obtain the first-scale optimized features, the calculation formula of which is as follows: in, For the first-scale optimization features, Grouped features obtained by channel grouping shallow enhancement features These are the output features of the first branch and the output features of the second branch, respectively. This is a shallow enhancement feature; It is the Sigmoid activation function. For average pooling operation, Represents matrix multiplication. This indicates element-wise multiplication.
8. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 1, characterized in that, The dual-enhancement detection head includes three color anomaly attention modules, one small target enhancement module, and a decoupled detection head. The decoupled detection head includes dual-branch detection heads corresponding to three feature scales, and each dual-branch detection head includes a classification branch and a bounding box regression branch. In the dual-enhanced detection head: The first-scale optimized features are input into the first color anomaly attention module. The first-scale optimized features are divided into g subgroups according to the channel dimension. Adaptive average pooling and two-layer nonlinear mapping are performed on each subgroup to obtain the local perceptual weights corresponding to each subgroup. Each local perceptual weight is multiplied element-wise with the corresponding subgroup features. The resulting weighted features of each subgroup are then concatenated along the channel dimension to obtain the first-scale local features. The first-scale optimized features are then subjected to global average pooling, flattening, first linear layer processing, SiLU activation, second linear layer processing, and Sigmoid activation in sequence. The processing results are then dimensionally reshaped to obtain the first-scale global perceptual weights that can be broadcast to the first-scale local features. The first-scale global perception weights are multiplied element-wise with the first-scale local features, and the result of the multiplication is added to the first-scale optimized features as a residual to obtain the first-scale color enhancement features. The second-scale optimized feature and the third-scale optimized feature are processed by the second color anomaly attention module and the third color anomaly attention module respectively in the same way as the first-scale optimized feature to obtain the second-scale color enhancement feature and the third-scale color enhancement feature. The first-scale color enhancement feature is input into the micro-target enhancement module for processing to obtain the first-scale final enhancement feature; The first-scale final enhancement feature, the second-scale color enhancement feature, and the third-scale color enhancement feature are respectively input into the corresponding scale dual-branch detection head. The classification branch and bounding box regression branch of each dual-branch detection head are used for processing to obtain the identification results of plant leaf diseases and pests and the bounding box coordinates.
9. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 8, characterized in that, The micro-target enhancement module includes a high-frequency residual extraction branch, a gated weight generation branch, and an output mapping module; the high-frequency residual extraction branch includes average pooling operation, subtraction operation, convolutional layer, and batch normalization layer; the gated weight generation branch includes an average pooling layer, a first gated convolutional layer, a SiLU activation layer, a second gated convolutional layer, and a Sigmoid activation layer connected in sequence; the output mapping module includes a convolutional layer, a batch normalization layer, and a SiLU activation layer connected in sequence. The first-scale color enhancement features are input into the micro-target enhancement module for processing to obtain the final first-scale enhancement features, including: The first-scale color enhancement feature is input into the high-frequency residual extraction branch. Average pooling is performed on the first-scale color enhancement feature to obtain a smooth feature. The first-scale color enhancement feature is subtracted from the smooth feature to obtain a high-frequency residual feature. The high-frequency residual feature is sequentially convolved and batch normalized to obtain a high-frequency enhancement feature. The high-frequency enhancement feature is added to the first-scale color enhancement feature by adding their residuals to obtain a second intermediate feature. The first-scale color enhancement feature is input into the gate weight generation branch, and average pooling, first gated convolution, SiLU activation, second gated convolution and Sigmoid activation are performed in sequence to obtain the third intermediate feature, which is then used as the gated attention map. The second intermediate feature and the third intermediate feature are multiplied element-wise, and the multiplication result is input into the output mapping module. Convolution, batch normalization and SiLU activation are performed in sequence to obtain the first scale final enhanced feature.
10. The lightweight plant leaf disease and pest detection method based on improved YOLOv8 according to claim 1, characterized in that, The method further includes: obtaining the batch normalized layer scaling factor of each layer to be pruned in the backbone network and the neck network, using the absolute value of the scaling factor as the importance score of the corresponding channel, globally sorting the importance scores of each channel to be pruned, and removing channels with lower importance scores according to a preset pruning ratio; retaining the SPPF module and the dual-enhancement detection head during the pruning process, and performing synchronous pruning and channel dimension alignment processing on the channels involved in residual connections and feature splicing to obtain a lightweight pest and disease detection model after pruning.
