Lightweight agricultural pest detection algorithm

By optimizing the YOLO series algorithms through a feature adaptive compression module and a compact multi-scale feature fusion module, and combining them with the SIoU loss function, the problems of loss of small target features and high computational complexity in agricultural pest detection are solved, achieving lightweight, real-time, and accurate pest detection.

CN121505541APending Publication Date: 2026-02-10BENGBU COLLEGE
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511646162.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-11
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing agricultural pest detection algorithms struggle to achieve efficient and accurate small target detection in complex field environments and on devices with limited computing resources. In particular, the feature details of tiny pests are easily lost, the models are complex, and the computational costs are high, making real-time detection difficult to achieve.

Method used

The algorithm employs a Feature Adaptive Compression (FAD) module and a Compact Multi-Scale Feature Fusion (CF-Neck) module, combined with the SIoU loss function, to optimize the backbone network and the feature fusion network. By using dual-path feature extraction and cross-channel-spatial recombination, it reduces computational complexity while preserving microstructural features. At the same time, it introduces a loss function with multi-dimensional constraints to improve positioning accuracy.

Benefits of technology

It enables real-time detection of tiny pests on portable devices, significantly improving the detection accuracy and robustness of small targets, reducing the number of model parameters and computational load, and adapting to the field deployment needs of embedded devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121505541A_ABST
    Figure CN121505541A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight agricultural pest detection algorithm, which belongs to the technical field of image processing, and is characterized in that a feature adaptive compression module is integrated in a backbone network based on a YOLO series architecture, and the module is used for extracting dominant features through convolution operation; and meanwhile, the capability of capturing microstructural features such as pest antennae and speckles is enhanced by virtue of a maximum pooling and parameter sharing strategy. Secondly, a lightweight Neck structure is introduced, the redundancy of network channels is reduced by adopting packet convolution, and the multi-scale feature fusion efficiency is further optimized through a cross-channel-spatial dimension feature recombination strategy. Finally, a bounding box constraint loss function based on similarity measurement is introduced, the position, shape and direction consistency between a prediction box and a real box is comprehensively optimized, and the positioning accuracy and detection generalization performance of the model on the tiny pest target are improved. According to the method provided by the invention, the model parameter quantity and computing resource occupation are remarkably reduced while relatively high detection precision is maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, specifically to a lightweight agricultural pest detection algorithm. Background Technology

[0002] Efficient identification of agricultural pests is crucial for ensuring food security and improving agricultural economic benefits. With the increasing penetration of artificial intelligence in agriculture, pest detection algorithms based on deep learning have become the core of precision agriculture research. However, current technologies still face two major challenges: First, the complex field environment (fluctuations in light intensity, crop shading) and the small size and varied morphology of pests lead to insufficient detection accuracy for small targets. Second, existing detection models have a large number of parameters and high computational costs, making them difficult to adapt to resource-constrained embedded devices (such as portable detection terminals and edge gateways), and thus unable to meet the needs of real-time on-site detection.

[0003] In existing technologies, mainstream solutions mostly revolve around balancing lightweight design and accuracy, but all have obvious limitations: taking the YOLO series as an example, YOLOv5 achieves lightweight design through the C3 module, but generates a large number of redundant prediction boxes due to the anchor box mechanism, reducing real-time performance; although AgriPest-YOLO supports the identification of 25 types of pests, its average detection accuracy is only 71.3%, making it difficult to cope with complex scenarios; Hu et al. introduced BiFPN and SwinTransformer in YOLOv5s to improve accuracy to 79.8%, but the computational complexity increased dramatically, limiting embedded deployment; Xie Jiaxing et al. optimized litchi pest detection through HDC and ECA attention, and Guo Jiaxuan et al. combined GRN attention and SIoU loss to balance convergence speed and accuracy (accuracy 72.3%), but neither of them effectively solved the common problems of loss of small target details and low efficiency of multi-scale fusion caused by lightweight strategies. The former relies on simple compression methods such as channel pruning, resulting in a high false negative rate in dense pest scenarios; the latter introduced enhancement modules to improve performance, but violated the requirements of lightweight deployment.

[0004] While current mainstream single-stage target detection models (such as the YOLO series) offer real-time advantages, they still have significant shortcomings when detecting small agricultural pests. Firstly, existing lightweight backbone networks (such as improved C2f-based modules) focus on reducing computation but lack enhancement mechanisms for microstructural features like insect antennae and markings, leading to the loss of shallow features during downsampling. Secondly, feature fusion networks (such as HSFPN) rely on standard convolutions, resulting in computational redundancy and low efficiency in multi-scale fusion. Furthermore, loss functions (such as WIoU) only optimize the bounding box overlap area and center distance, neglecting common issues like angular deviations and shape mismatches in small targets, leading to insufficient localization accuracy. Some solutions (such as the invention patent application number 202510730283.3) attempt to repair blurred features through super-resolution preprocessing, but the additional super-resolution model increases deployment complexity and inference latency, failing to meet the requirements for minimally invasive deployment in embedded devices.

[0005] In summary, existing technologies have not yet achieved an effective balance between lightweight deployment and accurate detection of minute pests. There is an urgent need to design lightweight detection solutions adapted to agricultural scenarios to solve core problems such as loss of small target features, low fusion efficiency, and complex deployment. Summary of the Invention

[0006] The technical solution of this invention addresses the problem that existing technical solutions are too simplistic and provides a solution that is significantly different from existing technologies. It mainly provides a lightweight agricultural pest detection algorithm to solve the technical problems mentioned in the background that the feature details of small targets are easily lost in current agricultural pest detection tasks, and that the model is too complex and difficult to run in real time on devices with limited computing resources.

[0007] The existing detection scenarios do not possess the unique characteristics of agricultural pests, such as their small size (2-3mm), critical microstructure (antennae / spots as identification criteria), and dense overlap. This leads to technicians being limited by the inertia of the scenarios and making it difficult for them to realize the need for targeted design.

[0008] Existing dual-path techniques involve channel splitting (e.g., ShuffleNet in CN115661657A: half channels are convolutional, half are unprocessed) or function splitting (e.g., the FPB module in CN118196836A: partial convolution, partial identity mapping). The core focus is on reducing computation, not preserving micro-features. The design logic differs, making it difficult for engineers to break through the existing dual-path framework and thus hindering their ability to conceive of using pooling to focus on micro-features before splitting. Furthermore, existing dual-path techniques involve independent parameter computation, without parameter sharing. Based on the existing independent parameter logic, engineers cannot conceive of using parameter sharing to balance lightweighting and micro-feature consistency. Therefore, existing dual-path techniques cannot be adapted to meet the need for a balance between micro-structure preservation and lightweighting.

[0009] Existing neckline improvements are all single-technology optimizations, lacking multi-technology synergy for densely packed small targets. For example, the GSConv lightweight convolution disclosed in CN116740538A is only used to replace traditional convolutions, without combining it with grouped convolutions to reduce channel redundancy or cross-channel-spatial recombination techniques to resolve confusion in dense features. When agricultural pests are densely distributed, the features output by GSConv are prone to low fusion efficiency due to channel redundancy. Technicians find it difficult to break free from the mindset of single optimization and derive the combination logic. Furthermore, existing neckline fusion aims at multi-scale feature complementarity, targeting targets at different scales rather than densely packed targets at the same scale. Without scenario references, technicians find it difficult to devise recombination strategies that recombine densely packed pest features at the same scale according to spatial location and channel semantics. Therefore, existing neckline optimization techniques lack a synergistic combination for fusion of densely packed small targets.

[0010] In the existing technology, the loss function only covers GIoU, EIoU, and WIoU, and does not involve angle constraints and shape constraints. Based on the existing loss function, technicians cannot think of designing angle / shape constraints for targets with variable shapes, and it is even more difficult to select SIoU that has not been disclosed in existing patents.

[0011] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:

[0012] A lightweight agricultural pest detection algorithm is proposed, based on the YOLO series architecture. The backbone network uses a Feature-Adaptive Downsampling (FAD) module as a downsampling structure, and the feature fusion network incorporates a Compact Fusion Neck (CF-Neck). The loss function is the SIoU loss function.

[0013] Furthermore, the adaptive feature compression module achieves feature extraction through a dual-path structure: the input features are first initially reduced in dimensionality (by average pooling) and then split into two parallel processing paths along the channel dimension. The main path extracts basic contour and texture features through convolution operations, while the auxiliary path utilizes max pooling and convolution operations to enhance the capture of salient features (microstructures such as insect antennae and markings). Both paths share convolution parameters to reduce network complexity, i.e., computational complexity. Finally, the features from the two paths are concatenated and fused, and then processed by an activation function, achieving efficient feature compression while retaining more detailed information about the insect target.

[0014] Furthermore, the main path uses a 3×3 convolution kernel for basic feature extraction; the auxiliary path enhances the ability to capture local salient features through a cascaded design of 3×3 max pooling combined with 1×1 convolution.

[0015] Furthermore, the compact multi-scale feature fusion includes GS convolutional units, GS bottleneck modules, GSCSP modules, and VoV-GS convolutional units. Grouped convolutions are used to reduce redundancy in network channels.

[0016] Furthermore, the GS convolutional unit first undergoes feature transformation and channel number adjustment through standard convolution, and then processes it through a depthwise separable convolution (DSConv) layer to concatenate the feature maps obtained from the standard convolution and the depthwise separable convolution. Finally, a shuffle mechanism is used to uniformly mix the feature channel information generated by the two convolutions. Through the cross-channel-spatial dimension feature recombination strategy, the efficiency of multi-scale feature fusion is further optimized.

[0017] Furthermore, the SIoU loss function adds multi-dimensional constraints such as positional distance, bounding box shape, and center position orientation to the traditional IoU loss function. The SIoU loss function calculates angular cost, distance cost, shape cost, and overlapping area cost. Therefore, this invention introduces a bounding box constraint loss function based on similarity metrics, comprehensively optimizing the consistency of position, shape, and orientation between the predicted and ground truth boxes. This improves the model's accuracy in locating small pest targets and its generalization performance, alleviates the ambiguity problem in locating small targets, and enhances detection robustness.

[0018] Specifically, the formula for calculating SIoU loss is: ; in, Indicates the cost of overlapping area. Indicates the cost of the angular shape. This represents distance cost, and the calculation of distance cost includes angle cost.

[0019] Furthermore, the formula for calculating the cost of overlapping area is as follows: ; Where B is the center point of the prediction box, B GT It is the center point of the actual bounding box.

[0020] Furthermore, the formula for calculating shape cost is as follows: ; in: ; ; in, and These are the width and height of the prediction box. and These are the width and height of the actual frame. It is a hyperparameter that controls the shape cost weight.

[0021] Furthermore, the distance cost calculation formula is as follows: ; in: ; ;

[0022] ; Where B is the center point of the predicted bounding box, and its coordinates are ( , ); B GT It is the center point of the true bounding box, and its coordinates are ( , ); C w It is point B and B GT The minimum bounding rectangle width, and These are the width and height of the prediction box; The formula for calculating angle cost is as follows: ; in: ; ; ; Among them, C h It is point B and B GT The minimum bounding rectangle height, α is B and B GT The angle between the line and the X-axis, It is the distance between the center points.

[0023] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0024] (1) This invention addresses the challenges of identifying agricultural pests (such as aphids and thrips) that are small (2-3 mm) and whose key identification criteria rely on microstructural features such as antennae and markings. By employing a dual-path design in the Feature Adaptive Compression (FAD) module, it overcomes the technical bottleneck of microstructural loss caused by excessive feature compression in traditional downsampling operations. The module first performs initial dimensionality reduction using average pooling, then splits into main and auxiliary paths along the channels. The main path extracts target contour and texture features, while the auxiliary path enhances the saliency response to microstructures. The dual paths collaboratively cover the feature dimensions of both macroscopic contours and microscopic details. Furthermore, the shared convolution parameters across the dual paths ensure consistency in microstructural feature extraction without increasing computational load, avoiding feature shifts caused by independent parameters across multiple paths. Experimental data shows that this module improves the model's mAP@0.5 (the core evaluation metric for small targets) by 0.6 percentage points compared to the benchmark YOLOv8n model, thereby reducing the false negative rate and resolving the issue of existing lightweight models (such as YOLOv5n and AgriPest-YOLO) sacrificing microstructural features for lightweight design, leading to false negatives of small targets. This invention can accurately capture the microstructural features of tiny pests, significantly improving the detection accuracy of small targets.

[0025] (2) This invention addresses the practical needs of agricultural field detection, which relies on portable terminals (such as edge gateways and handheld detection devices) and has limited computing resources. Through lightweight optimization of the entire backbone and Neck link, it achieves the same accuracy while reducing both the number of parameters and the amount of computation: The FAD module of the backbone network replaces the traditional stride convolution, reducing the number of parameters by 0.3M and the amount of computation by 0.6G compared to YOLOv8n; The feature fusion network (CF-Neck) adopts lightweight units such as GS convolution and GSCSP module, reduces channel redundancy through group convolution, and optimizes fusion efficiency through cross-channel-spatial recombination, further reducing the amount of computation by 0.9G compared to YOLOv8n; and the final overall model has only 2.5M parameters and 6.6G of computation. Compared with mainstream models of the same level, it maintains the accuracy advantage while significantly reducing the hardware adaptation threshold. This invention features an extremely lightweight design that is perfectly adapted for field deployment on embedded devices. The model can perform real-time inference on low-cost embedded devices without relying on high-performance servers, meeting the needs of on-the-spot field inspection and solving the contradiction between existing technologies that require excessive computation to achieve the required accuracy and limited deployment due to lightweight design.

[0026] (3) This invention addresses the problem that field pests are often densely distributed (e.g., aphids clustering on leaves), and traditional feature fusion is prone to false detections due to channel redundancy and scale confusion. The compact multi-scale feature fusion module (CF-Neck) of this invention achieves multi-technology collaborative optimization: the GS convolution unit uses standard convolution and depthwise separable convolution splicing and a shuffle mechanism to reduce time complexity while uniformly mixing feature channel information, avoiding the confusion of dense target features caused by single convolution; the module integrates GS bottleneck, VoV-GS convolution, and other units to form a hierarchical fusion architecture, improving the fusion efficiency of multi-scale features (e.g., adults and larvae, clusters and individual pests) through cross-space-channel dimension feature recombination; experimental verification shows that the false detection rate of the model of this invention is low in dense pest scenarios. Therefore, this invention can improve the robustness of dense pest scenarios by optimizing the multi-scale feature fusion efficiency.

[0027] (4) This invention addresses the problem that traditional IoU loss functions (such as CIoU and WIoU) only optimize the overlapping area and center distance, without considering the angle deviation and shape mismatch caused by the morphological variations of agricultural pests (such as folded wings of moths and differences in body shape of beetles). This invention introduces the SIoU loss function: the loss function is constrained by four dimensions: angle cost, distance cost, shape cost, and overlapping area cost, and comprehensively optimizes the position, direction, and shape consistency between the predicted box and the real box. In particular, it addresses the common angle offset (such as the tilted body shape of aphids) and shape difference (such as the difference in body shape between larvae and adults) of small targets, thereby reducing the positioning error. The angle cost solves the positioning offset caused by the neglect of directional deviation by calculating the coordinate axis angle between the predicted box and the real box. The shape cost quantifies the difference in width and height through weight coefficients to adapt to the diversity of pest morphology. Generalization validation shows that in the IP102 cross-dataset test, the model of this invention achieves a 2.9 percentage point improvement in mAP@0.5 compared to YOLOv8n, and a 1.8 percentage point improvement in mAP@0.5 compared to 0.95. This demonstrates its stable detection capability for agricultural pests of different types and in different scenarios, avoiding the limitation of existing models that perform well only on specific datasets and have poor cross-scenario generalization. Therefore, this invention enhances localization accuracy and generalization performance through a multi-dimensional constrained loss function.

[0028] (5) The model of this invention can be integrated into handheld detection terminals, UAV inspection systems, and other equipment to achieve real-time identification, species determination, and density estimation of field pests. Compared with the existing traditional detection mode that requires image acquisition and cloud analysis in the laboratory, this invention reduces the detection delay from hours to seconds, greatly improving operational efficiency, and is especially suitable for rapid inspection of large areas of farmland. Therefore, the technical solution of this invention directly serves the needs of early prevention and control of agricultural pests and diseases, and has clear industrial application value.

[0029] In summary, this invention not only overcomes the technical contradictions of lightweight design, precision, and deployability, but also provides a low-cost, highly reliable, and easily implemented solution for agricultural pest detection at the industrial level, which is of great significance for ensuring food security and promoting the digital transformation of agriculture.

[0030] The present invention will be explained in detail below with reference to the accompanying drawings and specific embodiments. Attached Figure Description

[0031] Figure 1 This is a schematic diagram of the dataset image in an embodiment of the present invention;

[0032] Figure 2 This is a schematic diagram of the improved backbone network in this invention;

[0033] Figure 3 This is a schematic diagram of the GSConv module in the feature fusion network of the present invention;

[0034] Figure 4 This is a diagram showing the calculation parameters related to the SIoU loss function of this invention. Detailed Implementation

[0035] To facilitate understanding of the present invention, a more comprehensive description of the present invention will be given below with reference to the accompanying drawings, which illustrate several embodiments of the present invention. However, the present invention can be implemented in different forms and is not limited to the embodiments described in the text. Rather, these embodiments are provided to make the disclosure of the present invention more thorough and complete.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly associated with those skilled in the art to which this invention pertains. The terminology used herein in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0037] Example: A lightweight agricultural pest detection algorithm mainly involves training an image dataset using the AS-YOLO model.

[0038] In this embodiment, the data is selected from the publicly available benchmark dataset IP102 and open-source agricultural pest images from the Kaggle community. Eight categories of agriculturally important pests were selected to construct a multi-source dataset, containing 12,579 labeled images, all in JPG format. The images were manually labeled using the labelImg dataset annotation tool. The labeled dataset was then randomly divided into training, validation, and test sets in an approximate 8:1:1 ratio. The training dataset contains 10,063 images, the validation set contains 1,257 images, and the test set contains 1,259 images. Simultaneously, to improve model generalization, data augmentation strategies such as geometric transformations, flipping, rotation, and shearing were employed to expand data diversity. Figure 1 As shown.

[0039] The AS-YOLO algorithm redesigns the backbone, feature fusion structure, and loss function of traditional single-stage lightweight object detection networks, specifically including the following three improvements:

[0040] (1) In the backbone network, this invention employs a Feature-Adaptive Downsampling (FAD) module to replace the traditional downsampling structure. The FAD module achieves feature extraction through a dual-path structure: the input features are first initially reduced in dimensionality by average pooling, and then split into two processing paths along the channel dimension. The main path extracts basic contour and texture features through convolution operations, while the auxiliary path further enhances the ability to capture salient features using max pooling and convolution operations. The two paths share convolution parameters to reduce network complexity. Finally, the output features of the two paths are concatenated and integrated using activation functions, significantly improving the network's ability to perceive subtle structures and achieving efficient feature compression and accuracy preservation. Specifically:

[0041] In convolutional neural networks, downsampling reduces computational complexity by lowering the resolution of feature maps, but traditional implementations risk feature loss. For example... Figure 2 As shown on the left, the original YOLOv8n model uses stride convolution (Conv) for downsampling, and its structure consists of a single convolutional layer and a SiLU activation function. While this design has the advantage of high computational efficiency, when processing small objects, an excessively large convolutional stride can lead to over-compression of shallow, subtle features, resulting in the loss of crucial texture information. To address this, the module replaces the ordinary convolutional downsampling layer in the original model with a layered feature recombination and cross-branch parameter sharing, thereby enhancing multi-scale feature preservation while controlling computational load.

[0042] like Figure 2As shown on the right, the module optimizes the structure while retaining the downsampling function of the original convolutional layer: the input features are first reduced in dimensionality by an average pooling layer, and then split into two processing paths along the channel dimension. The main path uses a 3×3 convolutional kernel for basic feature extraction, while the auxiliary path uses a cascaded design of "3×3 max pooling + 1×1 convolution" to enhance the capture of local salient features. The two paths share the convolutional kernel weight parameters, reducing the number of parameters while maintaining consistency in feature extraction. Finally, the outputs of the two paths are concatenated and then transformed nonlinearly using the SiLU activation function. Compared to the single-path convolution of the original model (such as...), this approach offers significant advantages. Figure 4 (Left) This module expands the effective receptive field range at the same downsampling rate through pooling-guided multi-granularity feature fusion, while improving the feature response intensity for small targets by utilizing the noise suppression properties of max pooling.

[0043] (2) In the feature fusion network part, this invention incorporates a compact multi-scale feature fusion module (CompactFusion Neck, CF-Neck). This module comprehensively utilizes efficient GS convolutional units, GS bottleneck modules, GSCSP modules, and VoV-GS convolutional units, and adopts a modular hierarchical design, which significantly reduces redundant computation in the fusion process and effectively shortens the model's inference latency. The CF-Neck module effectively improves the network's capture efficiency for multi-scale targets, especially small pests, through a feature interaction and recombination strategy across spatial and channel dimensions. Specifically:

[0044] To make the output of depthwise separable convolution (DSConv) as close as possible to the output of standard convolution, a lightweight convolution module, GSConv, is used. Its introduction reduces time complexity and improves the timeliness of pest detection models. The principle of the GSConv module is illustrated below. Figure 3 As shown, this module first performs feature transformation and channel number adjustment using standard convolution, changing the input feature channel number from C1 to C2 / 2. Then, it processes the data through a DSConv layer, concatenating the feature maps obtained from standard convolution and depthwise separable convolution. Finally, a shuffle mechanism is used to uniformly mix the feature channel information generated by the two convolutions. In the Neck section, GSConv, GS bottleneck, GSCSP, and VoV-GSConv are used to form the compact multi-scale feature fusion module used in this invention.

[0045] (3) A multidimensional consistency loss function was used. This loss function adds constraints on multiple dimensions such as positional distance, bounding box shape, and center position orientation to the traditional IoU loss function. By introducing explicit angle cost, distance cost, shape difference cost, and overlap area cost, it explicitly optimizes the positional and orientational matching degree between the predicted box and the ground truth box. Compared with traditional IoU loss functions, this loss function can converge faster and significantly improve the accuracy and robustness of the model for small target localization, without increasing the computational burden on the network. Specifically:

[0046] The original loss function in the YOLOv8 network model is shown in equation (1) below: (1);

[0047] In the formula L loc It is the positioning loss, L conf It is the confidence loss, L class Classification loss. Both the confidence loss and classification loss use the binary cross-entropy loss function (BCEWithLogitsLoss), while the localization loss uses CIoU. CIoU is relatively less sensitive to the bounding box orientation (angle), which affects the convergence efficiency.

[0048] To address the aforementioned problems, this invention uses the SIoU loss function, which comprises four parts: angle cost, angle cost, and angle cost. Distance cost Shape cost Ω and overlap area cost IoU.

[0049] The calculation parameters required for the SIoU loss function are as follows: Figure 4 As shown:

[0050] In the figure, B is the center point of the prediction box, and its coordinates are ( , ); B GT It is the center point of the true bounding box, and its coordinates are ( , C w It is point B and B GT The minimum bounding rectangle width, C h It is point B and B GT The minimum bounding rectangle height, α is B and B GT The angle between the line and the X-axis, It is the distance between the center points.

[0051] The formula for calculating angle cost is as follows: ; in: ; ; (5); The formula for calculating distance cost is as follows: ; in: ; ; (9); The formula for calculating shape cost is as follows: ; in: ; ; in, and These are the width and height of the prediction box. and These are the width and height of the actual frame. It is a hyperparameter that controls the shape cost weight.

[0052] The formula for calculating the cost of overlapping area is as follows: ; SIoU loss: ;

[0053] The following is an experimental analysis:

[0054] 1. Experimental Environment and Training Parameters

[0055] A deep learning platform was built on a Linux system, using an NVIDIA GeForce RTX 4090 D graphics card with 24.2GB of VRAM. The experimental environment used PyTorch version 2.0.0, Python version 3.8.10, and CUDA version 11.8. GPU acceleration was utilized throughout the training and inference processes to improve computational efficiency. The dataset training parameters are configured as shown.

[0056] surface Dataset training parameter configuration

[0057] Optimizer Batch size Training epochs Number of worker threads (workers) Learning rate Input pixels SGD 32 150 8 0.01 640

[0058] 2. Evaluation Indicators

[0059] Evaluation metrics for YOLO series algorithms were used, including precision (P), recall (R), mean average precision (mAP), number of parameters, and GFLOPs. No pre-trained weights were used in the experiments; all training was performed from scratch to ensure fairness. The formulas for calculating precision (P), recall (R), and mean average precision (mAP) are as follows: ; ; ; ;

[0060] TP (True Positive) represents a true positive, FP (False Positive) represents a false positive, and FN (False Negative) represents a false negative. mAP is the average precision (AP) calculated for all categories.

[0061] The performance of the AS-YOLO algorithm model proposed in this invention was evaluated through ablation experiments and comparative experiments.

[0062] 3. AS-YOLO ablation test

[0063] The AS-YOLO model is a target detection model built on the YOLOv8n network structure through three-stage modular optimization. The backbone network uses the Feature Adaptive Compression (FAD) module, the neck network uses the Compact Multi-Scale Feature Fusion (CF-Neck) module, and the loss function is changed to the boundary-aware loss function (SIoU). These were validated as separate modules, and the results are shown in Table 2.

[0064] surface Ablation experiments of different modules of AS-YOLO

[0065] algorithm mAP@0.5% mAP@0.5:0.95% Parameter quantity / M floating-point operations / G YOLOv8-n 84.1 63.4 3.0 8.1 YOLOv8-n+SIoU 84.5 63.6 3.0 8.1 YOLOv8-n+FAD 84.7 64.2 2.7 7.5 YOLOv8-n+CF-Neck 84.8 65.3 2.8 7.3 YOLOv8-n+FAD+CF-Neck 84.9 65.5 2.5 6.6 YOLOv8-n+FAD+CF-Neck+SIoU 85.4 66.1 2.5 6.6

[0066] Depend on It can be seen that each improved module has achieved varying degrees of improvement compared to the baseline model. After introducing SIoU loss in YOLOv8, mAP@0.5 increased by 0.4 percentage points, and mAP@0.5:0.95 increased by 0.2 percentage points. After replacing the convolutional layers after the first layer in YOLOv8 with the FAD module, mAP@0.5 increased by 0.6 percentage points, and mAP@0.5:0.95 increased by 0.8 percentage points, with a reduction of 0.3M parameters and 0.6G computation. After using the CF-Neck module, mAP@0.5 increased by 0.7 percentage points, and mAP@0.5:0.95 increased by 1.9 percentage points, with a reduction of 0.2M parameters and 0.8G computation. Finally, by simultaneously using the SIoU module, FAD module, and CF-Neck module, mAP@0.5 increased by 1.3 percentage points, mAP@0.5:0.95 increased by 2.7 percentage points, with a reduction of 0.5M parameters and 1.5G computation. In summary, the AS-YOLO model performs excellently across key metrics. It not only improves detection performance but also reduces the number of parameters, making it suitable for deployment on embedded devices.

[0067] 4. Comparative Experiment

[0068] To evaluate the performance of the AS-YOLO algorithm, we selected the mainstream algorithms of the same level, YOLOv5-n, YOLOv6-n, YOLOv8-n, and YOLOv11-n, for comparative experiments. The results are shown in Table 3.

[0069] surface Comparison Experiment of AS-YOLO with Mainstream Algorithms of the Same Level

[0070] algorithm mAP@0.5% mAP@0.5:0.95% Parameter quantity / M Number of floating-point operations / G YOLOv5-n 82.9 60.9 2.5 7.1 YOLOv6-n 83.4 63.5 4.2 11.8 YOLOv8-n 84.1 63.4 3.0 8.1 YOLOv11-n 85.0 64.7 2.6 6.5 AS-YOLO 84.8 65.3 2.5 6.6

[0071] As can be seen, the AS-YOLO algorithm outperforms YOLOv5-n, YOLOv6-n, and YOLOv8-n in terms of mAP@0.5, mAP@0.5:0.95, parameter count, and number of floating-point operations. Compared to YOLOv11-n, the algorithm of this invention shows improvement in the mAP@0.5:0.95 metric while significantly reducing the number of model parameters. AS-YOLO's mAP@0.5 is slightly lower than YOLOv11-n, but its computational cost is higher. This demonstrates that the AS-YOLO algorithm can achieve more lightweight target detection while maintaining accuracy.

[0072] 5. Verification of the generalization ability of the AS-YOLO algorithm

[0073] To further verify the generalization ability of the AS-YOLO algorithm, this invention selected the IP102 agricultural pest public dataset for verification experiments. The experimental environment remained unchanged, and the experimental results are shown in Table 4 below.

[0074] Table 4 Comparison of generalization verification experiment results

[0075] Model mAP@0.5% mAP@0.5:0.95% Parameter quantity / M Number of floating-point operations / G YOLOv8-n 46.2 28.8 3.3 9.6 AS-YOLO 49.1 30.6 2.5 6.6

[0076] As shown in Table 4, mAP@0.5 improved by 2.9 points, and the mAP@0.5:0.95 index improved by 1.8 points. The number of parameters and computation were also effectively reduced, achieving a lightweight model implementation.

[0077] Experimental results show that the method proposed in this invention significantly reduces the number of model parameters and computational resource consumption while maintaining high detection accuracy, making it more suitable for deployment in portable or embedded devices to perform real-time detection tasks of agricultural pests.

[0078] In summary, to address the issue that current target detection algorithms have excessively large parameter and computational costs, making them unsuitable for deployment in embedded devices, this invention proposes a lightweight pest detection algorithm based on improved YOLOv8. The AS-YOLO algorithm replaces the original downsampling convolutional layer with the FAD module to more effectively extract key feature information. The CF-Neck module is used in the neck region to effectively reduce the number of model parameters. Finally, the original CIoU loss is replaced with SIoU loss to better capture the shape and orientation features of the target, thereby improving the model's robustness. Experimental results demonstrate that the AS-YOLO algorithm can meet the requirements for deployment in embedded devices and the detection of small targets.

[0079] The present invention has been described by way of example in conjunction with the accompanying drawings. Obviously, the specific implementation of the present invention is not limited to the above-described manner. Any non-substantial improvement made by adopting the inventive concept and technical solution of the present invention, or the direct application of the inventive concept and technical solution of the present invention to other occasions without modification, shall be within the protection scope of the present invention.

Claims

1. A lightweight agricultural pest detection algorithm, characterized in that: Based on the YOLO series architecture, the backbone network uses an adaptive feature compression module as a downsampling structure, the feature fusion network incorporates a compact multi-scale feature fusion module, and the loss function adopts the SIoU loss function.

2. The lightweight agricultural pest detection algorithm according to claim 1, characterized in that: The feature adaptive compression module implements feature extraction through a dual-path structure: the input features are first reduced in dimensionality by average pooling, and then split into two processing paths along the channel dimension. The main path extracts basic contour and texture features through convolution operations, while the auxiliary path uses max pooling and convolution operations to enhance the capture of salient features. The two paths share convolution parameters to reduce network complexity.

3. The lightweight agricultural pest detection algorithm according to claim 2, characterized in that: The main path uses a 3×3 convolution kernel for basic feature extraction; And / or, the auxiliary path enhances the ability to capture local salient features through a cascaded design of 3×3 max pooling combined with 1×1 convolution.

4. The lightweight agricultural pest detection algorithm according to claim 1, characterized in that: The compact multi-scale feature fusion includes GS convolutional units, GS bottleneck modules, GSCSP modules, and VoV-GS convolutional units.

5. The lightweight agricultural pest detection algorithm according to claim 4, characterized in that: The GS convolutional unit first undergoes feature transformation and channel number adjustment through standard convolution, then is processed by a depthwise separable convolutional layer to stitch together the feature maps obtained from the standard convolution and the depthwise separable convolution, and finally uses a shuffle mechanism to achieve uniform mixing of feature channel information generated by the two convolutions.

6. The lightweight agricultural pest detection algorithm according to claim 1, characterized in that: The SIoU loss function adds multi-dimensional constraints such as location distance, bounding box shape, and center position direction to the traditional IoU loss. The calculation items of the SIoU loss function include angle cost, distance cost, shape cost, and overlap area cost.

7. The lightweight agricultural pest detection algorithm according to claim 6, characterized in that: The formula for calculating SIoU loss is: in, Indicates the cost of overlapping area. Indicates the cost of the angular shape. This represents distance cost, and the calculation of distance cost includes angle cost.

8. The lightweight agricultural pest detection algorithm according to claim 7, characterized in that: The formula for calculating the cost of overlapping area is as follows: Where B is the center point of the prediction box, B GT It is the center point of the actual bounding box.

9. The lightweight agricultural pest detection algorithm according to claim 7, characterized in that: The formula for calculating shape cost is as follows: in: in, and These are the width and height of the prediction box. and These are the width and height of the actual frame. It is a hyperparameter that controls the shape cost weight.

10. The lightweight agricultural pest detection algorithm according to claim 7, characterized in that: The formula for calculating distance cost is as follows: in: Where B is the center point of the predicted bounding box, and its coordinates are ( , ); B GT It is the center point of the true bounding box, and its coordinates are ( , ); C w It is point B and B GT The minimum bounding rectangle width, and These are the width and height of the prediction box; The formula for calculating angle cost is as follows: in: Among them, C h It is point B and B GT The minimum bounding rectangle height, α is B and B GT The angle between the line and the X-axis, It is the distance between the center points.

Citation Information

Patent Citations

  • Lightweight unmanned ship target detection method

    CN115661657A

  • Lightweight target detection method and system based on YOLOv8 improvement

    CN116740538A

  • Real-time golden snub monkey detection method based on YOLOv5FS

    CN118196836A

  • Lightweight rice leaf disease identification method based on YOLO target detection

    CN120635014A