A lightweight target detection method based on YOLO
By introducing the lightweight FasterNet and Dim-SimAM modules into the YOLOv8 framework and combining them with the pruning-optimization module, the high computing resource problem of the drone target detection model is solved, and efficient and real-time target detection is achieved on low-cost equipment.
Patent Information
- Application Number
- CN202510654862.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-05-21
AI Technical Summary
Existing target detection models require high computing resources when running on drones, resulting in a sharp increase in power consumption and a serious reduction in flight time. In addition, lightweight solutions make it difficult to reduce the number of model parameters while ensuring accuracy.
A lightweight target detection method based on the YOLOv8 framework is adopted. By introducing the lightweight FasterNet module, Dim-SimAM module and joint pruning-optimization module, feature extraction and model pruning are optimized, reducing computational complexity and storage requirements.
While ensuring detection accuracy, it significantly reduces the number of model parameters and computational complexity, improves inference speed, and is suitable for real-time computing on low-cost edge devices.
Smart Images

Figure CN120182585B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and provides a lightweight target detection method based on YOLO. Background Art
[0002] Drone applications require rapid target location in complex environments (such as farmland and urban buildings) to perform tasks such as real-time identification of crop pests and diseases and human traffic monitoring. However, to achieve high accuracy and robust target recognition, existing target detection models place significant demands on computing resources. Training and inference of complex models typically require powerful GPUs. The performance of processors available for drones is very limited, and the high computational load leads to a dramatic increase in power consumption, significantly shortening the drone's flight time. Consequently, low-power and low-computation algorithms are in high demand.
[0003] Object detection algorithms combine object localization and classification. Detectors fall into two categories: two-stage region proposal-based algorithms and single-stage regression-based algorithms. Two-stage algorithms involve two steps: object localization and classification. Region proposals are generated first, followed by classification, such as FasterR-CNN (Fast Region-based Convolutional Network). This approach offers high detection accuracy but slow inference speed. Single-stage algorithms, such as OverFeat and YOLO, directly use a CNN (Convolutional Neural Network) to extract features and simultaneously predict both classification and localization. This approach is simple, efficient, and suitable for real-time scenarios. The YOLO family of single-stage object detection algorithms offers more balanced advantages and has proven practicality in industry. The YOLOv8 framework achieves cutting-edge performance in both accuracy and speed. Existing lightweight object detection network solutions suffer from several insurmountable drawbacks: the inability to balance detection accuracy with the number of model parameters, low accuracy after pruning, and difficulty restoring model accuracy after pruning. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides a lightweight object detection method based on YOLO, which overcomes the limitations of computing power and enables real-time inference calculations on low-cost edge devices while ensuring accuracy.
[0005] The present invention provides a lightweight target detection method based on YOLO, comprising:
[0006] S1: Acquire and preprocess an image to obtain a preprocessed image;
[0007] S2: Building a lightweight object detection model based on the YOLOv8 framework. The lightweight object detection model includes a backbone network, a feature extraction network, and a joint pruning-optimization module. The backbone network includes a lightweight FasterNet module, and the feature extraction network includes a Dim-SimAM module.
[0008] S3: Setting training parameters, and using the preprocessed images to train the lightweight object detection model to obtain a lightweight object detection training model;
[0009] S4: Input the required detection image into the lightweight object detection training model to obtain the detection result.
[0010] According to a YOLO-based lightweight target detection method provided by the present invention, the lightweight FasterNet module is used to replace the feature extraction module in the backbone network.
[0011] According to a YOLO-based lightweight target detection method provided by the present invention, the operating steps of the lightweight FasterNet module are as follows:
[0012] S11: Divide the FasterNet input data into channels to obtain channel group data, and perform PConv convolution on the channel group data by channel to obtain the first module output data;
[0013] S12: Performing depthwise separable convolution on the output data of the first module to obtain output data of the second module;
[0014] S13: Perform GLU stacking on the output data of the second module and activate it using the ReLU function to obtain the output data of the third module;
[0015] S14: performing convolution on the output data of the third module to obtain output data of the fourth module;
[0016] S15: Multiply the FasterNet input data and the fourth module output data element by element to obtain FasterNet output data.
[0017] According to a YOLO-based lightweight target detection method provided by the present invention, the Dim-SimAM module replaces the RepNCSPELAN4 module of the feature extraction network.
[0018] According to a lightweight target detection method based on YOLO provided by the present invention, the Dim-SimAM module includes:
[0019] S21: Solve the intermediate feature map of the input feature map and minimize the energy function according to the SimAM algorithm;
[0020] S22: solving dynamic parameters according to the input feature map and the minimized energy function;
[0021] S23: updating the dynamic parameters and the intermediate feature map to obtain an updated SimAM algorithm;
[0022] S24: Calculate the input feature map according to the updated SimAM algorithm to obtain an output feature map.
[0023] According to a lightweight target detection method based on YOLO provided by the present invention, the dynamic parameter adjusts the benchmark of the energy function by adding the variance of the intermediate feature map.
[0024] According to a lightweight target detection method based on YOLO provided by the present invention, when the input feature map is a multi-layer feature map, downsampling and upsampling operations fuse different feature maps, multi-scale downsampling is performed on the input feature map, SimAM is independently applied at each scale to generate attention weights, the resolution is aligned through bilinear interpolation upsampling, and the input feature maps are weightedly fused to obtain the output feature map.
[0025] According to a YOLO-based lightweight target detection method provided by the present invention, the joint pruning-optimization module includes the following steps:
[0026] S31: Calculating the sparse loss of the lightweight object detection model;
[0027] S32: Calculating the distillation loss of the lightweight object detection model;
[0028] S33: Calculate the task loss of the lightweight object detection model, where the task loss is the sum of the box regression loss and the object confidence loss of the YOLO model;
[0029] S34: Calculate the total loss, which is the sum of the task loss, sparse loss and distillation loss. When the total loss converges, the training of the lightweight object detection model is completed.
[0030] According to a lightweight object detection method based on YOLO provided by the present invention, the sparse loss calculation step includes:
[0031] S311: Use regularization to sparsify the BN layer coefficients of the lightweight object detection model to obtain the pruned lightweight object detection model and calculate the layer sparsity parameters;
[0032] S312: Calculate the sparse loss according to the layer sparsity parameter.
[0033] According to a lightweight object detection method based on YOLO provided by the present invention, the distillation loss calculation step includes:
[0034] S321: Performing knowledge distillation on the lightweight object detection model to obtain a teacher model and a student model;
[0035] S322: Calculate the dynamic response of the teacher model, and adjust the pruning threshold according to the dynamic response;
[0036] S323: Calculate the distillation loss based on the pruning threshold, the teacher model, and the student model.
[0037] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0038] The present invention provides a lightweight target detection method based on YOLO, which achieves the following advantages by introducing a lightweight FasterNet module, a Dim-SimAM module, and a joint pruning-optimization module:
[0039] (1) The present invention solves the problems of large model size and limited portability by reducing redundant calculations and memory accesses through a partial convolution algorithm, which can significantly reduce the amount of parameter calculation and computational complexity of the model.
[0040] (2) Without increasing the original network parameters, the three-dimensional attention weights are inferred for the feature maps, and the input feature maps are globally adaptively weighted, which enhances the feature extraction capability of the model and effectively solves the problem of accuracy loss caused by lightweighting.
[0041] (3) The combination of model pruning and knowledge distillation can improve the inference speed and reduce the number of network parameters while ensuring accuracy.
[0042] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 This is a flowchart of a lightweight target detection method based on YOLO provided by the present invention.
[0045] Figure 2 This is the structure diagram of the lightweight FasterNet module.
[0046] Figure 3 It is a parameter information diagram during the model training process.
[0047] Figure 4 This is a performance comparison chart of the present invention and different algorithms. DETAILED DESCRIPTION
[0048] To make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below. Obviously, the embodiments described are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0049] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0050] Example
[0051] The following combination Figures 1 to 4 The present invention is described.
[0052] like Figure 1 As shown, Figure 1 The flowchart of the lightweight target detection method based on YOLO provided by the present invention includes the following steps:
[0053] S1: Acquire and preprocess an image to obtain a preprocessed image;
[0054] S2: Building a lightweight object detection model based on the YOLOv8 framework. The lightweight object detection model includes a backbone network, a feature extraction network, and a joint pruning-optimization module. The backbone network includes a lightweight FasterNet module, and the feature extraction network includes a Dim-SimAM module.
[0055] S3: Setting training parameters, and using the preprocessed images to train the lightweight object detection model to obtain a lightweight object detection training model;
[0056] S4: Input the required detection image into the lightweight object detection training model to obtain the detection result.
[0057] The lightweight FasterNet module is used to replace the feature extraction module in the backbone network. The Dim-SimAM module replaces the RepNCSPELAN4 module of the feature extraction network.
[0058] Specifically, such as Figure 2 The operating steps of the lightweight FasterNet module are as follows:
[0059] S11: Divide the FasterNet input data into channels to obtain channel group data, and perform PConv convolution on the channel group data by channel to obtain the first module output data;
[0060] S12: Performing depthwise separable convolution on the output data of the first module to obtain output data of the second module;
[0061] S13: Perform GLU stacking on the output data of the second module and activate it using the ReLU function to obtain the output data of the third module;
[0062] S14: performing convolution on the output data of the third module to obtain output data of the fourth module;
[0063] S15: Multiply the FasterNet input data and the fourth module output data element by element to obtain FasterNet output data.
[0064] The lightweight FasterNet module is primarily composed of a PConv (Partial Convolution) module. The PConv structure performs conventional convolution on only a subset of the input channels, fully utilizing information from all channels to extract spatial features while maintaining the size of the remaining channels. In conventional memory access, if the input and output feature maps have the same number of channels, the first or last consecutive channel is used as the representative of the entire feature map during calculations.
[0065] The computational complexity of PConv is only 1 / 16 of that of ordinary convolution. In addition, PConv has lower memory access, and its computational complexity is shown in the formula:
[0066]
[0067] in, is the channel height, is the channel width, For continuous network channels, Filters. Replacing different network model architectures often requires additional data operations, and the runtime of these operations significantly impacts lightweight model improvements. To improve the speed of target detection tasks while maintaining lightweightness, the FasterNet backbone network is added. The design of PConv is improved to prevent channel loss, achieving good performance with low latency. This paper proposes a collaborative optimization scheme for dynamic grouped partial convolution (DG-PConv) and gated linear units (Convolutional GLUs), reconstructing the FasterNet backbone network. The specific implementation is as follows:
[0068] According to the channel correlation of the input feature map, the channel groups involved in the convolution are dynamically divided through a lightweight gating network (each group of channels performs 3×3 convolution independently), and the remaining channels maintain the same mapping
[0069] The input features are divided into two groups through 1×1 convolution. One group undergoes 3×3 depthwise separable convolution (DWConv) and nonlinear activation, and then performs element-wise multiplication with the other group to achieve dynamic feature selection.
[0070] Specifically, the Dim-SimAM module includes:
[0071] S21: Solve the intermediate feature map of the input feature map and minimize the energy function according to the SimAM algorithm;
[0072] S22: solving dynamic parameters according to the input feature map and the minimized energy function;
[0073] S23: updating the dynamic parameters and the intermediate feature map to obtain an updated SimAM algorithm;
[0074] S24: Calculate the input feature map according to the updated SimAM algorithm to obtain an output feature map.
[0075] Typically, information-rich neurons exhibit different firing patterns from surrounding neurons, and firing neurons generally inhibit surrounding neurons, a phenomenon known as spatially localized inhibition. Therefore, neurons with spatially localized inhibition should be given higher importance. The simplest way to search for such neurons is to measure the linear separability between the target neuron and other neurons. The importance of each neuron can be expressed using a corresponding energy function, as shown in the following formula:
[0076]
[0077] in, is the energy function, is the weight of the target neuron, is the bias coefficient, is the total number of energy functions, For the The input to the neuron, is the neuron number, , is the input of the feature map on a single channel, It is a dynamic parameter.
[0078] The analysis is as follows
[0079]
[0080]
[0081]
[0082]
[0083] in, is the average value of single channel data, is the single channel data variance, is the mean value of all neurons.
[0084] Solve the SimAM module The minimized energy function of neurons The algorithm is as follows:
[0085]
[0086]
[0087]
[0088]
[0089] in, is the variance of all neurons, To minimize the input of the feature map corresponding to the energy function on a single channel, To minimize the weight of the target neuron corresponding to the energy function, is the bias coefficient corresponding to the minimized energy function. The lower the neurons The greater the importance and difference between the neurons around it. Quantify the similarity between different locations on the feature map and calculate the energy function to determine the feature maps with significant differences in both the channel domain and the spatial domain. The refinement of the output feature map by the scaling operator is shown in the following formula:
[0090]
[0091] in, is the intermediate feature map, is the activation function, is the energy function value, is the input feature map, is element-wise multiplication.
[0092] In particular, the closed-form solution of the energy function is used to enhance the effective information output of neurons, where All in channel and spatial dimensions Group. Fixed values cannot adapt to the needs of different network layers or complex scenarios. This paper introduces a learnable dynamic parameter to adaptively adjust the sensitivity of the energy function according to the statistical characteristics of the input feature map. The formula is as follows:
[0093]
[0094] in, is a learnable parameter, is the global average pooling function.
[0095] SimAM also only works on a single-layer feature map and lacks the ability to fuse information across scales. This paper designs a multi-scale pyramid attention (MS-Pyramid) algorithm, which fuses feature maps of different resolutions through upsampling. The input feature map is upsampled at multiple scales (e.g., 1 / 2, 1 / 4), and SimAM is applied independently at each scale to generate attention weights. The multi-scale attention maps are weighted and fused together by upsampling with bilinear interpolation to align the resolutions.
[0096]
[0097] in, is the multi-layer energy function value, is the learnable scale weight coefficient, is the upsampling function, To obtain the single-layer energy function value function.
[0098] SimAM, a parameter-free attention mechanism, is a universal attention mechanism that is not limited to a specific network and offers high flexibility. By introducing the SimAM module into the model network, the representational capabilities of the convolutional layer are greatly improved. At the same time, most operations are based on the defined energy function, avoiding excessive structural adjustments.
[0099] Specifically, the joint pruning-optimization module includes the following steps:
[0100] S31: Calculating the sparse loss of the lightweight object detection model, including:
[0101] S311: Use regularization to sparsify the BN layer coefficients of the lightweight object detection model to obtain the pruned lightweight object detection model and calculate the layer sparsity parameters;
[0102] L1 regularization is used to sparsify the BN layer coefficients of the target detection model to enhance the model's adjustment to a more sparse structure. After sparse training, the channels are pruned according to the preset pruning rate to obtain a target detection model that takes up less storage space, achieving a balance between model size and accuracy. The pruning operation involves removing unimportant channels to make the model lightweight. Channel pruning helps generate a more compact and efficient target detection model by removing unimportant channels. The pruning process is performed by introducing a scaling factor and analyzing the statistical information of the BN layer to retain channels that have a greater impact on model accuracy and minimize the storage and computational costs of the model. The calculation formula of the BN layer is as follows:
[0103]
[0104]
[0105] in, is the middle value of the BN layer, is the input of the BN layer, is the mean of the BN layer, is the BN layer variance, To prevent the denominator from being 0, is the output of the BN layer, is the first parameter of the BN layer, is the second parameter of the BN layer. The parameters are multiplied by the output of the channel, and then the weights of the original network and Parameters. When When it is close to 0, the output is independent of the input. The parameters are sorted and filtered, and channels with values less than the set global threshold are directly removed, thereby reducing the number of model parameters and the amount of computation. The channel pruning algorithm utilizes the parameters in the BN layer. It is used as an important indicator for network pruning to measure the importance of each channel.
[0106] S312: Calculating the sparse loss according to the layer sparse parameters :
[0107]
[0108] in, For the The first parameter of the BN layer, is the layer number after pruning, , is the total number of layers after pruning, is the first-order norm.
[0109] Since the accuracy of the pruned model will decrease, it needs to be retrained through fine-tuning to adapt to the updated network structure and restore the model's performance. To address the problem of decreased model accuracy that may occur during lightweight processing, knowledge distillation can be used. This method extracts knowledge from a model with high accuracy but large number of parameters and computational complexity, and then transfers it to a smaller model to achieve model compression, thereby reducing the model size while maintaining high accuracy.
[0110] S32: Calculating the distillation loss of the lightweight object detection model, including:
[0111] S321: Performing knowledge distillation on the lightweight object detection model to obtain a teacher model and a student model;
[0112] The results of the teacher and student networks are processed through Softmax and then the loss is calculated. The two loss results are multiplied by a multiple of the coefficient value and then added together to obtain the total loss for training. When predicting, the trained weights are directly applied to the student network for direct prediction. To enhance inter-class associations, data is annotated with soft labels and hard labels. Hard labels are the original labels, while soft labels carry more information to improve generalization. The calculated probability output by the Softmax layer is used as the soft target. The Softmax function is shown in the following formula:
[0113]
[0114] in, is the soft label data, For Hard label data, is the distillation temperature. The higher the distillation temperature, the smaller the soft label value differentiation.
[0115] The present invention designs an offline distillation method, in which the large-model teacher network is an improved YOLO-Fast model, and the small-model student network is a pruned model. In the knowledge distillation training algorithm, the training accuracy of the teacher model is higher than that of the student model. The more significant the difference, the more obvious the distillation effect. The parameters of the teacher model are usually fixed to ensure that the knowledge of the teacher model is not changed when training the student model. The distillation loss function calculates the output prediction difference between the teacher model and the student model, and uses this difference as the loss of the student model. Combined with the overall training loss, the performance and accuracy of the student model are improved through gradient updates, ultimately achieving the coordinated optimization of model compression and accuracy recovery.
[0116] S322: Calculate the dynamic response of the teacher model and adjust the pruning threshold according to the dynamic response :
[0117]
[0118] in, is the adjustable coefficient, is the mean value function, Teacher Network The first parameter mean of the layer BN is used. An iterative pruning and distillation mechanism is used. In each training cycle, forward propagation is performed alternately to calculate the joint loss and backpropagation is used to update the student network weights. The feature response is used to dynamically guide the channel importance evaluation.
[0119] S323: Calculate the distillation loss based on the pruning threshold, teacher model and student model :
[0120]
[0121] in, is the feature layer alignment set of the teacher-student network, No. The teacher model Fn loss of the layer, No. The student model Fn loss of the layer, is the second-order norm.
[0122] S33: Calculate the task loss of the lightweight object detection model, where the task loss is the sum of the box regression loss and the object confidence loss of the YOLO model;
[0123] S34: Calculate total loss , the total loss is the sum of the task loss, sparse loss and distillation loss:
[0124]
[0125] in, is the distillation loss parameter, is the pruning loss parameter, is the task loss parameter, Loss of mission.
[0126] When the total loss converges, the training of the lightweight object detection model is completed.
[0127] like Figure 3 As shown, Figure 3 Parameter information for lightweight models trained on the VisDrone dataset, Figure 3 In the example, train and val represent the data of the training set and validation set respectively. The blue dots represent the actual results, and the orange dotted line represents the smoothed curve. The training set directly participates in the entire process of the model's forward reasoning, loss calculation, backpropagation, weight update, etc. The validation set is only used for model forward reasoning, and then the model is evaluated according to the predetermined evaluation indicators, which can be used to reflect the performance of the current model on the validation set. Figure 3 (a) and Figure 3 As shown in (f), the box regression loss (box_loss) is used to measure the position difference between the predicted box and the true box; Figure 3 (b) and Figure 3 As shown in (g), the category classification loss (cls_loss) is used to measure the accuracy of classification of different categories; Figure 3 (c) and Figure 3 As shown in (h), the error distance loss (dfl_loss) is used to measure the distance error between the predicted box and the calibration box. In addition, as Figure 3 As shown in (d), metrics / precision is the proportion of samples whose predicted bounding boxes coincide with the true bounding boxes during training, that is, the proportion of predicted positive samples that are true positive samples. Figure 3 The metrics / recall shown in (e) is the proportion of all true samples that the evaluation model can find during the training process, that is, the proportion of true samples that are correctly predicted among the positive examples. Figure 3 in (i) and Figure 3 As shown in (j), the performance of the model is evaluated from two indicators: mAP50 and mAP95. The detection rule of mAP50 is that when the IoU (Intersection over Union) of the detection area is ≥ 0.5, it is (True positive), if the IoU of the detection area is less than 0.5, it is classified as (False positive). Similarly, the detection rule of mAP95 is that when the IoU of the detection area is ≥ 0.95, it is classified as , if the IoU of the detection area is less than 0.95, it is classified as Compared to the original YOLOv8 model, mAP and FP increased by 3.03% and 2.2% respectively. Through model sparse training and channel pruning, the model's computational complexity was reduced to 68.2%.
[0128] like Figure 4 As shown in the figure, the proposed YOLO-Fast algorithm is compared with several mainstream algorithms, including CenterNet, Fully Convolutional One-Stage Object Detection (FCOS), and Detection Transformer (DETR), in terms of mAP and inference speed on the Atlas 200I platform. The experimental results show that the proposed YOLO-Fast achieves an accuracy of 91.17% at mAP@0.5 on the VisDrone test set and an inference time of 42ms on the Atlas 200I, achieving the highest detection accuracy among all models. Compared with the original model, both detection accuracy and inference speed are improved. Compared with the Yolov7, Yolov6, and Yolov5 models, the proposed YOLO-Fast model is the preferred choice in terms of detection accuracy and speed.
[0129] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
[0130] It should be noted that the embodiments of the present disclosure can be implemented by hardware, software, or a combination of software and hardware. The hardware portion can be implemented using dedicated logic; the software portion can be stored in a memory and executed by an appropriate instruction execution system such as a microprocessor or dedicated hardware. Those skilled in the art will understand that the above-mentioned devices and methods can be implemented using computer-executable instructions and / or contained in processor control code, for example, such code is provided on a programmable memory or a data carrier such as an optical or electronic signal carrier.
[0131] In addition, although the operations of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flow chart can change the order of execution. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of a device described above can be further divided into being embodied by multiple devices.
[0132] Although the present disclosure has been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the specific embodiments disclosed. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A lightweight target detection method based on YOLO, characterized in that: include: S1: Acquire and preprocess an image to obtain a preprocessed image; S2: A lightweight target detection model is established based on the YOLOv8 framework. The lightweight target detection model includes a backbone network, a feature extraction network, and a joint pruning-optimization module. The backbone network includes a lightweight FasterNet module. The operating steps of the lightweight FasterNet module are: S11: Divide the FasterNet input data into channels to obtain channel group data, and perform PConv convolution on the channel group data by channel to obtain the first module output data; S12: Performing depthwise separable convolution on the output data of the first module to obtain output data of the second module; S13: Perform GLU stacking on the output data of the second module and activate it using the ReLU function to obtain the output data of the third module; S14: performing convolution on the output data of the third module to obtain output data of the fourth module; S15: Multiply the FasterNet input data and the fourth module output data element by element to obtain FasterNet output data; The feature extraction network includes a Dim-SimAM module; The Dim-SimAM module includes: S21: Solve the intermediate feature map of the input feature map and minimize the energy function according to the SimAM algorithm; S22: Solving dynamic parameters based on the input feature map and the minimized energy function ; S23: updating the dynamic parameters and the intermediate feature map to obtain an updated SimAM algorithm; S24: Calculate the input feature map according to the updated SimAM algorithm to obtain an output feature map; The closed solution of the energy function is used to enhance the effective information output of neurons, where the energy function value The minimized energy function of all neurons is grouped in the channel and spatial dimensions, and learnable parameters are introduced according to the input feature map. The statistical characteristics of are used to adaptively adjust the sensitivity of the energy function. The formula is as follows: in, is a learnable parameter, is the activation function, is the global average pooling function, Design a multi-scale pyramid attention, fuse feature maps of different resolutions through upsampling operations, perform multi-scale downsampling on the input feature map, apply SimAM independently at each scale to generate attention weights, align the resolution through bilinear interpolation upsampling, and weighted fuse the multi-scale attention map. in, is the multi-layer energy function value, is the learnable scale weight coefficient, is the upsampling function, To obtain the single layer energy function value function; The joint pruning-optimization module includes the following steps: S31: Calculating the sparse loss of the lightweight object detection model; S311: Regularization is used to sparsify the BN layer coefficients of the lightweight object detection model to obtain the pruned lightweight object detection model and calculate the layer sparsity parameters. The calculation formula of the BN layer is as follows: in, is the middle value of the BN layer, is the input of the BN layer, is the mean of the BN layer, is the BN layer variance, To prevent the denominator from being 0, is the output of the BN layer, is the first parameter of the BN layer, is the second parameter of the BN layer; S312: Calculating the sparse loss according to the layer sparse parameters : in, For the The first parameter of the BN layer, is the layer number after pruning, , is the total number of layers after pruning, is the first-order norm; S32: Calculating the distillation loss of the lightweight object detection model; S321: Performing knowledge distillation on the lightweight object detection model to obtain a teacher model and a student model; S322: Calculate the dynamic response of the teacher model and adjust the pruning threshold according to the dynamic response : in, is the adjustable coefficient, is the mean value function, Teacher Network The first parameter mean of layer BN; S323: Calculate the distillation loss based on the pruning threshold, teacher model and student model : in, is the feature layer alignment set of the teacher-student network, No. The teacher model Fn loss of the layer, No. The student model Fn loss of the layer, is the second-order norm; S33: Calculate the task loss of the lightweight object detection model, where the task loss is the sum of the box regression loss and the object confidence loss of the YOLO model; S34: Calculate the total loss, which is the sum of the task loss, the sparse loss, and the distillation loss. When the total loss converges, the training of the lightweight object detection model is completed. in, is the distillation loss parameter, is the pruning loss parameter, is the task loss parameter, Loss of mission; S3: Setting training parameters, and using the preprocessed images to train the lightweight object detection model to obtain a lightweight object detection training model; S4: Input the required detection image into the lightweight object detection training model to obtain the detection result.
2. A lightweight target detection method based on YOLO according to claim 1, characterized in that, The lightweight FasterNet module is used to replace the feature extraction module in the backbone network.
3. A lightweight target detection method based on YOLO according to claim 1, characterized in that, The Dim-SimAM module replaces the RepNCSPELAN4 module of the feature extraction network.
4. A lightweight target detection method based on YOLO according to claim 1, characterized in that, The dynamic parameter is added to the variance of the intermediate feature map to adjust the benchmark of the energy function.