YOLOv7-tiny lightweight vehicle target detection method and system

By improving and pruning on YOLOv7-tiny, the problem of deploying existing vehicle object detection algorithms in resource-constrained environments is solved, and an efficient and lightweight vehicle object detection method is realized.

CN119649316AActive Publication Date: 2025-03-18CHANGAN UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411616286.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-18
Estimated Expiration
2044-11-13

AI Technical Summary

Technical Problem

Existing vehicle object detection algorithms such as YOLOv7 perform excellent in accuracy but have high computing resource requirements, and are not suitable for deployment in resource-constrained environments.

Method used

A YOLOv7-tiny lightweight vehicle target detection method is proposed. By constructing an improved initial vehicle target detection model and applying pruning strategies for lightweight processing, the calculation complexity is reduced while maintaining high detection accuracy.

Benefits of technology

The performance and efficiency of vehicle object detection is significantly improved, and the computational complexity is reduced, making the method suitable for deployment in resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119649316A_ABST
    Figure CN119649316A_ABST
Patent Text Reader

Abstract

The invention provides a YOLOv7-tiny lightweight vehicle target detection method and system, and relates to the technical field of computer vision and deep learning, and the method comprises the steps: constructing a roadside vehicle data set; performing image filtering, image enhancement and data set division on the roadside vehicle data set; constructing an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on a YOLOv7-tiny network; performing lightweight processing on the initial vehicle target detection model by applying a pruning strategy to obtain a lightweight vehicle detection model; inputting the divided data set into a lightweight vehicle detection model for training, testing and verification to obtain a final vehicle target detection model; and inputting the to-be-detected image into the final vehicle target detection model to obtain a detection result. According to the method, the performance and efficiency of vehicle target detection are remarkably improved through multi-aspect improvement of YOLOv7-tiny, the calculation complexity is reduced through lightweight model design, and the method is suitable for being deployed in a resource-limited environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision and deep learning technology, and in particular to a YOLOv7-tiny lightweight vehicle target detection method and system. Background Art

[0002] The vehicle target detection algorithm is the underlying foundation for the implementation of the vehicle target global tracking and trajectory association algorithm for multiple cameras. Accurate and efficient detection results are of great significance for subsequent vehicle target tracking under single camera and vehicle target tracking under multiple cameras.

[0003] With the development of autonomous driving technology, vehicle target detection has become one of the key technologies in intelligent transportation systems. Although existing target detection algorithms such as YOLOv7 have excellent accuracy, they have high requirements for computing resources and are not suitable for deployment in resource-constrained environments. Therefore, it is of great significance to develop a lightweight detection technology that can maintain high detection accuracy while reducing computational complexity. Summary of the invention

[0004] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a YOLOv7-tiny lightweight vehicle target detection method and system, which can improve the detection accuracy while reducing the computational complexity.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] A YOLOv7-tiny lightweight vehicle target detection method, comprising:

[0007] Construct a roadside vehicle dataset containing vehicle images of various models, in different lighting and weather conditions;

[0008] Performing image filtering, image enhancement, and data set division on the roadside vehicle data set to obtain a training set, a validation set, and a test set;

[0009] Constructing an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network;

[0010] Applying a pruning strategy to lightweight the initial vehicle target detection model to obtain a lightweight vehicle detection model;

[0011] Inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and verification to obtain a final vehicle target detection model;

[0012] The image to be detected is input into the final vehicle target detection model to obtain a detection result.

[0013] Preferably, the target types in the roadside vehicle dataset include: cars, buses, vans and others.

[0014] Preferably, performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set includes:

[0015] Performing filtering processing on the image in the roadside vehicle data set to obtain a filtered image;

[0016] Constructing an image enhancement window, and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image;

[0017] Performing histogram equalization processing on the denoised image to obtain an enhanced image;

[0018] The enhanced images are divided into data sets according to a preset ratio to obtain the training set, the verification set and the test set.

[0019] Preferably, filtering the image in the roadside vehicle data set to obtain a filtered image includes:

[0020] Performing wavelet decomposition on the roadside vehicle data set at multiple scales to obtain corresponding wavelet coefficients;

[0021] A filtering threshold is constructed according to the size and decomposition scale of the roadside vehicle data set; the formula of the filtering threshold is: Among them, λ j represents the filtering threshold at the jth decomposition scale, σ j represents the standard deviation of the noise at the jth decomposition scale, N j represents the signal length at the jth decomposition scale, where j represents the decomposition scale;

[0022] The image filtering model is constructed using the filtering threshold; the formula of the image filtering model is: Wherein, sign is the sign function, a is the first preset coefficient, b is the second preset coefficient, ω j,k represents the kth wavelet coefficient at the jth decomposition scale, represents the wavelet coefficients after filtering;

[0023] The image of the roadside vehicle data set is filtered using the image filtering model to obtain the filtered image.

[0024] Preferably, constructing an image enhancement window and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image includes:

[0025] Detecting the filtered image using an image recognition model to obtain a proportion value under each image enhancement window;

[0026] When the proportion value in the image enhancement window is greater than a preset threshold, median denoising is performed on the image in the corresponding image enhancement window to obtain an image after median denoising;

[0027] The image enhancement window is slid until the entire filtered image is traversed to obtain the denoised image.

[0028] Preferably, the filtered image is detected using an image recognition model to obtain a proportion value under each image enhancement window, including:

[0029] Using Formula F ij =|x ij -y ij |Get the pixel difference of each pixel under each image enhancement window; where F ij Represents the pixel difference of the image at position (i, j), x ij Represents the pixel value of the image at position (i, j), y ij represents the pixel value of the filtered image at position (i, j);

[0030] Pixels whose pixel difference is greater than the feature threshold are taken as feature points and the number is recorded;

[0031] The ratio of the feature points to all the pixels in the image enhancement window is taken as the ratio value.

[0032] Preferably, the initial vehicle target detection model comprises: an input network, a backbone network, a neck network and a detection head connected in sequence;

[0033] The input network is used to perform data enhancement and image preprocessing operations on the input image set to obtain a preprocessed image; the backbone network is used to extract image features on the preprocessed image based on the ELAN model and the MP model to obtain a feature map; the neck network is used to perform feature fusion and enhancement on the feature map to obtain a fusion map; the detection head is used to perform feature detection based on the fusion map to obtain a detection result.

[0034] Preferably, the backbone network of the backbone network is a MobileNetV3 network.

[0035] Preferably, the pruning strategies include: importance-based layer adaptive pruning, channel weight-based pruning and growth regularization-based pruning.

[0036] A YOLOv7-tiny lightweight vehicle target detection system, including:

[0037] The dataset construction module is used to construct a roadside vehicle dataset containing vehicle images of various models and under different lighting and weather conditions;

[0038] A data set processing module, used for performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set;

[0039] A model improvement module, used to construct an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network;

[0040] A lightweight module, used for applying a pruning strategy to perform lightweight processing on the initial vehicle target detection model to obtain a lightweight vehicle detection model;

[0041] A training module, used for inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and validation to obtain a final vehicle target detection model;

[0042] The detection module is used to input the image to be detected into the final vehicle target detection model to obtain the detection result.

[0043] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0044] The present invention provides a YOLOv7-tiny lightweight vehicle target detection method and system, the method comprising: constructing a roadside vehicle data set containing vehicle images of various vehicle models and under different lighting and weather conditions; performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a verification set and a test set; constructing an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on a YOLOv7-tiny network; applying a pruning strategy to lightweight the initial vehicle target detection model to obtain a lightweight vehicle detection model; inputting the training set, the verification set and the test set into the lightweight vehicle detection model for training, testing and verification to obtain a final vehicle target detection model; inputting the image to be detected into the final vehicle target detection model to obtain a detection result. The present invention significantly improves the performance and efficiency of vehicle target detection through various improvements to YOLOv7-tiny, and reduces the complexity of calculation through lightweight model design, and is suitable for deployment in resource-constrained environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0046] Figure 1 A flow chart of a method provided by an embodiment of the present invention;

[0047] Figure 2 A schematic diagram of a technical route provided for an embodiment of the present invention;

[0048] Figure 3 A schematic diagram of an example of conversion of a Zhiyuan-Wanji roadside data set provided in an embodiment of the present invention; wherein Figure 3 (a) is the format of the marked file; Figure 3 (b) is the data after conversion;

[0049] Figure 4 A schematic diagram of an example of Rope3D data set conversion provided by an embodiment of the present invention; wherein Figure 4 (a) is the format of the marked file; Figure 4 (b) is the data after conversion;

[0050] Figure 5 A schematic diagram of an example of UA-DETRAC data set conversion provided by an embodiment of the present invention; wherein Figure 5 (a) is the original .xml tag format information; Figure 5 (b) is the markup format information after conversion;

[0051] Figure 6 A distribution diagram of various types of vehicle samples in the data set provided by the embodiment of the present invention;

[0052] Figure 7 An improved network model structure diagram provided by an embodiment of the present invention;

[0053] Figure 8 A schematic diagram of a method for calculating a SIoU loss function provided in an embodiment of the present invention;

[0054] Fig. 9 A pruning process diagram provided for an embodiment of the present invention;

[0055] Fig.10 A schematic diagram of the change in loss during the training process provided by an embodiment of the present invention;

[0056] Fig.11 A schematic diagram comparing the experimental results of the improved network provided in an embodiment of the present invention and YOLOv7-tiny. DETAILED DESCRIPTION

[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] The purpose of the present invention is to provide a YOLOv7-tiny lightweight vehicle target detection method and system, which significantly improves the performance and efficiency of vehicle target detection by making many improvements to YOLOv7-tiny.

[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0060] Figure 1 A flow chart of a method provided by an embodiment of the present invention, such as Figure 1 As shown, the present invention provides a YOLOv7-tiny lightweight vehicle target detection method, comprising:

[0061] Step 100: construct a roadside vehicle dataset containing vehicle images of various vehicle types and under different lighting and weather conditions;

[0062] Step 200: performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set;

[0063] Step 300: constructing an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network;

[0064] Step 400: Applying a pruning strategy to perform lightweight processing on the initial vehicle target detection model to obtain a lightweight vehicle detection model;

[0065] Step 500: inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and verification to obtain a final vehicle target detection model;

[0066] Step 600: Input the image to be detected into the final vehicle target detection model to obtain a detection result.

[0067] Preferably, the target types in the roadside vehicle dataset include: cars, buses, vans and others.

[0068] Specifically, in order to improve the accuracy and reliability of traffic target detection, this embodiment requires a large amount of high-quality image data as support, which will be used to train and verify the target detection algorithm. At present, most of the data sets for traffic scenes are collected through vehicle-mounted cameras, such as the BDD100K data set, the KITTI data set, and the ApolloScape data set. Due to the differences between vehicle-mounted cameras and roadside surveillance cameras in terms of viewing angle, lighting conditions, and target distance, these factors may affect the performance of the target detection algorithm. Therefore, this embodiment aims to reduce the impact of these differences on the traffic target detection results by collating and annotating the data sets of roadside perspectives. By collating different open source data sets, manually annotating, etc., a roadside vehicle target data set of 23,811 images in 4 categories is produced. The existing open source roadside data sets are mainly processed to meet the needs of this embodiment, including the Zhiyuan-Wanji data set, the Rope3D data set, and the UA-DETRAC data set.

[0069] This embodiment uses the 2D image data in the Zhiyuan-Wanji roadside dataset, which is a large-scale roadside dataset designed for vehicle-road collaborative autonomous driving. The dataset contains 2500 frames of 3D point cloud data and 5000 frames of 2D image data. The 3D point cloud data is collected by a 32-line mechanical rotating LiDAR (WLR-32R), providing annotation information such as the three-dimensional coordinates of the target center point, target category, length, width, height and heading angle. The 2D image data is collected by a camera with a resolution of 1080P, providing the target frame position and annotation information of different categories. The Zhiyuan-Wanji dataset covers a variety of complex urban traffic environments, including busy intersections, changeable climatic conditions and rich traffic scenes. These diverse data are essential for training robust traffic target detection models. Supports 3D point cloud detection, 2D image detection, and laser radar and image fusion detection tasks. The data annotation quality is high and meets industry standards. This embodiment focuses on the target detection task based on 2D images, so only the RGB image data in the dataset is used, and it is analyzed and processed in detail to extract and learn the key features of traffic targets.

[0070] The file format of the labels in the Zhiyuan-Wanji Roadside Dataset is .txt, which is the same file format that can be used for YOLO algorithm training. The annotation file format in this dataset is as follows: Figure 3 As shown in (a), compared with the labels required by the YOLO algorithm, the last column of target IDs is added and converted to Figure 3 (b) The five columns of data in the figure are type, horizontal coordinate of the center of the detection frame, vertical coordinate of the center of the detection frame, width of the detection frame, and height of the detection frame.

[0071] Aiming at the research of vehicle target perception tasks from the roadside perspective, Baidu's open-source Rope3D dataset provides large-scale and multi-perspective vehicle target data, which is suitable for a variety of research scenarios. The dataset contains a total of 50,009 frames of images. The dataset has the following characteristics: (1) The dataset is collected by using roadside cameras with different configurations, including changing focal lengths, pitch angles, and installation heights, thereby simulating a variety of monitoring conditions in the real world; (2) The dataset contains a variety of different environmental conditions and traffic conditions, such as daytime, nighttime, dusk, and scenes under different weather conditions, as well as various traffic conditions from congestion to smooth traffic, from low traffic to high traffic. These rich scenarios help train models to adapt to the changing actual application environment; (3) In order to protect personal privacy and comply with relevant laws and regulations, sensitive information in the dataset, such as vehicle license plate numbers and faces, has been effectively desensitized to ensure data security and compliance; (4) The data is complete, including desensitized original images, annotated data, and calibration files. Although the Rope3D dataset was originally designed for 3D and point cloud detection tasks, this embodiment successfully constructed a dataset suitable for 2D detection of roadside vehicle targets by utilizing the detailed annotation information it provides, properly processing and converting the dataset.

[0072] The annotation file format in the Rope3D dataset is as follows Figure 4 (a) shows that this format does not meet the annotation file requirements used by the YOLO algorithm. YOLO annotation files only need to use Figure 4 The first, fifth, sixth, seventh, and eighth columns of the data shown in (b) and other parameter data can be directly ignored. After processing, the format required by the YOLO algorithm is obtained.

[0073] UA-DETRAC is a dataset specifically used for urban autonomous driving research. It has the advantages of diverse scenes, large data scale, and high annotation accuracy. The UA-DETRAC dataset contains 10 hours of video captured at 24 different locations in Beijing and Tianjin. The video recording was carried out in the urban traffic environment of Beijing and Tianjin, capturing real traffic scenes at a speed of 25 frames per second and a resolution of 960×540 pixels. The UA-DETRAC dataset manually annotated more than 8,250 vehicles, totaling 1.21 million labeled bounding boxes. The annotation file contains detailed vehicle information, such as vehicle speed, type, occlusion, truncation rate, and precise bounding box coordinates, which are essential for understanding traffic flow and vehicle behavior.

[0074] The UA-DETRAC dataset uses the XML format by default. In order to make the UA-DETRAC dataset suitable for the YOLO target detection framework, this embodiment converts the format of the original .xml tag and generates a .txt format tag suitable for YOLO, such as Figure 5 As shown, Figure 5 (a) is the original .xml tag format information, Figure 5 (b) is the converted label format information. In addition, the UA-DETRAC dataset is made of videos with 25 frames per second, so there are many image frames with the same scene and little change in the target position in the dataset. To address this problem, in order to reduce the number of similar frames in the dataset and improve training efficiency, this embodiment adopts a frame skipping strategy when processing the UA-DETRAC dataset, that is, a frame of image is selected every certain number of frames to reduce the scene repetitiveness, and a picture is taken every 10 frames into the final dataset.

[0075] The target categories annotated between different datasets are different, but in order to ensure the consistency and interoperability of different datasets in subsequent tracking algorithms, this embodiment reclassifies and summarizes the integrated dataset according to the category standard defined by the UA-DETRAC dataset. The final dataset categories are car, bus, van, and other. In addition, the video data of a tunnel in Wuxi was selected for frame-by-frame segmentation, and the labelme image annotation tool was used to manually annotate according to the category definition of the UA-DETRAC dataset, thereby obtaining the annotation file and the corresponding image file, and then obtaining the final roadside vehicle detection dataset. Then, this embodiment performed image processing on the dataset. After that, in order to achieve good performance evaluation and generalization ability testing during the model training process, this embodiment divided the dataset into training set, test set, and validation set according to the common practice method, with the proportions of 70%, 20%, and 10%, respectively. The training set has 16,667 images, the test set has 4,763 images, and the validation set has 2,381 images. The distribution of each label category in the dataset is as follows: Figure 6 shown.

[0076] Preferably, performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set includes:

[0077] Performing filtering processing on the image in the roadside vehicle data set to obtain a filtered image;

[0078] Constructing an image enhancement window, and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image;

[0079] Performing histogram equalization processing on the denoised image to obtain an enhanced image;

[0080] The enhanced images are divided into data sets according to a preset ratio to obtain the training set, the verification set and the test set.

[0081] Preferably, filtering the image in the roadside vehicle data set to obtain a filtered image includes:

[0082] Performing wavelet decomposition on the roadside vehicle data set at multiple scales to obtain corresponding wavelet coefficients;

[0083] A filtering threshold is constructed according to the size and decomposition scale of the roadside vehicle data set; the formula of the filtering threshold is: Among them, λ j represents the filtering threshold at the jth decomposition scale, σ j represents the standard deviation of the noise at the jth decomposition scale, N j represents the signal length at the jth decomposition scale, where j represents the decomposition scale;

[0084] The image filtering model is constructed using the filtering threshold; the formula of the image filtering model is: Wherein, sign is the sign function, a is the first preset coefficient, b is the second preset coefficient, ω j,k represents the kth wavelet coefficient at the jth decomposition scale, represents the wavelet coefficients after filtering;

[0085] The image of the roadside vehicle data set is filtered using the image filtering model to obtain the filtered image.

[0086] Specifically, it can be seen from the above filter threshold formula that as the decomposition scale increases, the threshold of each layer decreases accordingly, which is in line with the law of wavelet denoising, and thus can improve the performance of wavelet denoising.

[0087] Demonstratively, the present invention utilizes an image filtering model to perform a self-adjusting threshold transformation on the wavelet coefficients at each scale, thereby highlighting the detailed features of the image at different decomposition levels, suppressing image noise, and enhancing the layering of the image.

[0088] Preferably, constructing an image enhancement window and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image includes:

[0089] Detecting the filtered image using an image recognition model to obtain a proportion value under each image enhancement window;

[0090] When the proportion value in the image enhancement window is greater than a preset threshold, median denoising is performed on the image in the corresponding image enhancement window to obtain an image after median denoising;

[0091] The image enhancement window is slid until the entire filtered image is traversed to obtain the denoised image.

[0092] Furthermore, the original filtering algorithm, such as the mean filtering algorithm, performs mean processing on the pixel points in each neighborhood (i.e., the denoising window) on the image (regardless of whether there are noise points), so the processed image will be distorted. The present invention can find the characteristic noise points on the image by utilizing the image enhancement window, and then process the corresponding characteristic noise points to smooth out the noise points in the image while retaining the original pixel information on the image as much as possible.

[0093] Preferably, the filtered image is detected using an image recognition model to obtain a proportion value under each image enhancement window, including:

[0094] Using Formula F ij =|x ij -y ij |Get the pixel difference of each pixel under each image enhancement window; where F ij Represents the pixel difference of the image at position (i, j), x ij Represents the pixel value of the image at position (i, j), y ij represents the pixel value of the filtered image at position (i, j);

[0095] Pixels whose pixel difference is greater than the feature threshold are taken as feature points and the number is recorded;

[0096] The ratio of the feature points to all the pixels in the image enhancement window is taken as the ratio value.

[0097] Optionally, this embodiment performs median denoising on the image in the corresponding window based on the image enhancement window, which can alleviate the problem that existing denoising methods (such as mean filter denoising) cause certain features in the image to disappear, so that the original pixel information of the image can be retained to the greatest extent. In addition, this embodiment uses histogram equalization to process the image, which can improve the image interpretation effect.

[0098] Preferably, the initial vehicle target detection model comprises: an input network, a backbone network, a neck network and a detection head connected in sequence;

[0099] The input network is used to perform data enhancement and image preprocessing operations on the input image set to obtain a preprocessed image; the backbone network is used to extract image features from the preprocessed image based on the ELAN model and the MP model to obtain a feature map; the neck network is used to perform feature fusion and enhancement on the feature map to obtain a fusion map; the detection head is used to perform feature detection based on the fusion map to obtain a detection result. The backbone network of the backbone network is a MobileNetV3 network.

[0100] In view of the problem of high computing power when deploying the current vehicle target detection algorithm, this embodiment designs a vehicle target detection algorithm based on the improved YOLOv7-tiny. Figure 7 This is the improved network model structure diagram of this embodiment. First, the backbone network is replaced with MobileNetV3, and GSConv is used in the Neck part to greatly reduce redundant information, reduce the amount of model calculation, and speed up the model reasoning. In the Head part, the self-attention dynamic detection head DyHead and the decoupled head DecoupledHead are introduced to improve the performance of target detection.

[0101] Furthermore, the loss function of this embodiment is designed as follows:

[0102] When the aspect ratio of the detection box and the true value box is equal, the aspect ratio penalty is 0. In addition, the width and height in CIoU are opposite to the gradient of the penalty term, that is, the width and height cannot increase or decrease at the same time. To address the above problems, this embodiment uses SIoULoss as the loss function. SIoU further considers the angle between the detection box and the true value box, and redefines the calculation method of the penalty term, which mainly consists of four items: angle cost, distance cost, shape cost, and IoU cost. The main calculation method is as follows: Figure 8 shown.

[0103] The calculation formula of SIoULoss is shown below.

[0104]

[0105] Among them, IoU is the intersection over union ratio, Δ is the distance cost after considering the angle cost, and Ω is the shape cost. The calculation formula is shown as follows:

[0106]

[0107] ρ in the formula x , y ,γ,w t and w w The calculation formula is as follows: θ is used to control the attention to the shape cost Ω, which is set to 4 in the experiment.

[0108]

[0109] γ=2-Λ

[0110]

[0111] in, Represents the center point coordinates of the true value box, Represents the center point coordinate of the detection box, Λ represents the angle cost, and its calculation formula is shown in the following formula.

[0112]

[0113] Among them, σ represents the distance between the centers of the ground truth box and the detection box, and c h is the height difference between the centers of the ground truth box and the detection box.

[0114] Preferably, the pruning strategy includes: layer adaptive pruning based on importance, pruning based on channel weights, and pruning based on growth regularization.

[0115] Specifically, these above improvements in this embodiment enable the network to improve the accuracy of the algorithm on the basis of lightweight. In order to further optimize the efficiency and performance of the network model, in this embodiment, different pruning strategies are used to prune the modified network model, and the unnecessary parameters and connections in the neural network are adjusted through the pruning strategy to better balance the lightweight degree and accuracy of the model. The research in this embodiment is mainly based on the Torch_Pruning library for pruning, and mainly uses the layer adaptive pruning strategy based on importance, the pruning strategy based on channel weights, and the pruning strategy based on growth regularization in this library.

[0116] Furthermore, research shows that selecting good layer-by-layer sparsity can achieve a state-of-the-art balance between sparsity and performance for the importance-based pruning strategy. Similar to the early neural networks that extracted features by manually setting parameters, layer-by-layer sparsity also needs to be manually selected or searched through a large number of search algorithms. Later, a LAMP pruning strategy (Layer-adaptive Sparsity For The Magnitude-Based Pruning, importance-based layer adaptive pruning strategy) was proposed. This algorithm is a rescaled version of the weight importance and does not require any hyperparameters while considering the model distortion problem.

[0117] Consider a feedforward neural network with depth d, whose weight tensors are W (1) ,…,W (d) , and these weight tensors are all related to each fully connected layer or convolutional layer, but the corresponding dimensions are different. For a fully connected layer, the corresponding weight tensor is a two-dimensional matrix, while for a two-dimensional convolutional layer, the corresponding weight tensor is four-dimensional. To unify the scoring of the fully connected layer and the convolutional layer, assume that each weight tensor is expanded into a one-dimensional tensor. For these expanded tensors, assume that after corresponding them according to the index, the weights are arranged in ascending order, that is, when u < v, |W[u]| ≤ |W[v]|, where |W[u]| represents the entry mapped through index u, and its corresponding importance-based layer adaptive pruning score is shown in the following formula.

[0118]

[0119] This measures the importance of the target connection relative to other surviving connections in the same layer, where connections with smaller weight importance in the same layer are pruned. From the formula, it can be seen that when two connections with the same weight importance appear in the same layer, the criterion for pruning depends on the order of the indexes.

[0120] The above formula is used to calculate the importance-based layer adaptive pruning score of each connection, and then a global scan is performed to prune the connection with the lowest importance-based layer adaptive pruning score until the set global sparsity constraint is met. This method is equivalent to performing importance pruning using automatically selected inter-layer sparsity, as can be seen from the following formula.

[0121]

[0122] For any tensor W and index u,v, it can be inferred that this formula holds. In fact, the method of global pruning using importance-based layer adaptive pruning scores is different from the method of global pruning using weighted importance scores |W[u]|. In the process of using importance-based layer adaptive pruning scores for global pruning, if there is a connection with an importance-based layer adaptive pruning score of 1, then the importance-based layer adaptive pruning score of this connection may be the largest, that is, the importance-based layer adaptive pruning score will ensure that at least one connection will be retained in each layer during the global pruning process, while the method of global pruning using weighted importance scores |W[u]| may prune all connections.

[0123] In addition, compared with the original importance-based pruning algorithm, the importance-based layer adaptive pruning score does not require additional hyperparameter adjustment and can be implemented through simple tensor operations. In addition, the computational cost of the importance-based layer adaptive pruning score is very low, which can save computing resources to a certain extent.

[0124] Furthermore, as the depth of the convolutional neural network increases, the network's representation ability gradually increases, but the required computing resources also gradually increase. For example, a 152-layer residual network requires 60 million parameters. The deployment of convolutional neural networks in practical applications is usually affected by model size, running memory, and the number of computing operations. Other model compression methods can only solve 1 or 2 of the problems mentioned, and require special software or hardware for acceleration. Fine-grained sparsification methods are more flexible and the compressed model is more compact, but special software or hardware is required for fast inference. Coarse-grained sparsification methods do not require additional auxiliary means, but are less flexible. The algorithm mentioned in this section is based on channel sparsity. It completes model pruning without relying on software or hardware acceleration, and minimizes the overhead in the model training process. This algorithm automatically identifies unimportant channels during training and prunes them afterwards to obtain a compact and accurate model, achieving a balance between flexibility and feasibility. In the output process of each layer, the response of each channel is multiplied by its corresponding scaling factor γ to adjust the importance of the channel. During the network training process, these scaling factors γ are learned together with the network weights to ensure that the model can adaptively adjust the weights of each channel. In order to promote the sparsity of the model and avoid overfitting, sparse regularization is applied to these scaling factors. In this way, the model can identify and retain those channels that are more critical to the final task, while suppressing those channels that contribute less. After the training process, the scaling factors γ are analyzed, and those channels with smaller scaling factors γ are pruned. This step effectively reduces the complexity of the model and improves computational efficiency. Finally, the pruned network is fine-tuned to restore and optimize its performance. The specific calculation method of this method is shown in the following formula:

[0125]

[0126] Where (x, y) represents the training input and target; W represents the training weight; ∑ (x,y) l(f(x,W),y) represents the training loss of a convolutional neural network; g(·) represents the penalty of sparsity on the scaling factor γ, which balances these two terms.

[0127] The pruning process involves evaluating the impact of each channel and simplifying the network by removing those channels with smaller contributions. The advantage of this approach is that it can achieve network compactness without relying on special software or hardware acceleration techniques, such as Fig. 9As shown in Figure 2. The introduction of the scaling factor γ provides an effective metric for channel selection. These factors are jointly optimized with the network weights, allowing the model to automatically identify and retain channels that contribute more to the task during training. In this way, it is possible to safely remove unimportant channels during pruning while keeping the network's generalization ability unaffected.

[0128] The Batch Normalization (BN) layer is a standard method for most CNNs to achieve fast convergence and improve generalization performance. Therefore, the scaling factor on the channel can be integrated during the activation process. The BN layer uses small batch statistics to normalize the internal activations as shown in the following formula. Let z in and z out are the input and output of the BN layer respectively, and B represents the current mini-batch.

[0129]

[0130] Among them, μ B and σ B are the mean and standard deviation of the input activations on B; γ and β are trainable parameters that provide the possibility to linearly transform the normalized activations back to any scale.

[0131] With this strategy, after the channel sparsification training is completed, the model will obtain a set of scaling factors close to zero. Based on these factors, channels that contribute less to the model output can be identified and pruned, including their related input, output connections and weights. In order to achieve a controlled pruning process, a threshold can be set. For example, if the threshold is set to 70%, the channels with the following scaling factors will be pruned to form a more streamlined network structure. It is worth noting that a higher pruning ratio may lead to a decrease in model accuracy.

[0132] Furthermore, regularization has long been used to learn sparsity in deep neural network pruning. However, its effect is mainly explored within a small range of penalty strengths. The algorithm proposes a simple but effective regularization augmentation scheme that can transfer the model expressiveness to the remaining part during the pruning process. In addition, the gradually increasing regularization is further used to implicitly utilize the Hessian matrix. This method can more accurately select unimportant weights. The method is easy to implement and can be extended to large-scale datasets and networks.

[0133] Pruning can be formulated as a transformation T(*) whose input is a pre-trained large model w and whose output is a small model w 1 , usually after pruning, a fine-tuning process F(*) is added, and the final output w 2 , w 2The calculation formula of F(*) is as follows. F(*) is a standard neural network training process. We don’t need to pay too much attention to it. We should pay more attention to the conversion from w to w 1 The pruning process can be further transformed into two sub-transformations: (1) M = T 1 (w), obtain a binary mask vector M, which determines which weights will be removed; (2) T 2 (w) is used to adjust the value of the remaining weights and finally output w 1 The calculation formula is as follows.

[0134] w 2 =F(w 1 )

[0135] w 1 =T(w)=T 1 (w)⊙T 2 (w)=M⊙T 2 (w)

[0136] For one-shot pruning, T 1 There is no iterative training in , it is up to the specific algorithm to decide whether to adjust the remaining weights. For learning-based pruning, T 1 and T 2 Both involve iterative training, and the retained weights will always be adjusted.

[0137] The first method in the algorithm is a variant of L1 norm pruning, which obtains the mask M by L1 norm sorting and adjusts the retained weights by regularization. Specifically, given a pre-trained model w and layer pruning ratio γ l , sort the filters according to the L1 norm, set the mask M to 0 for those filters with the smallest norm, and then drive those unimportant weights to 0 through a gradually increasing L2 penalty. The calculation method is as follows.

[0138] λ j =λ j +δλ,j∈{j|,M[j]=0}

[0139] Among them, λ j is the penalty factor for the jth weight; δλ is the granularity of increasing the penalty. Obviously, the smaller δλ is, the smoother the regularization process is. j Only in every K u It is updated once in each iteration, which is a buffer time to allow the network to adapt to the new regularization. j When the preset upper limit τ is reached, the training is terminated and the weights with the smallest L1 norm are pruned, and then fine-tuning is performed. Pruning has almost no effect on accuracy, and unimportant weights have been compressed to typically less than one thousandth of the remaining weights.

[0140] The second method in the algorithm uses a gradual growth regularization method for scoring. Neural network training is prone to overfitting, so regularization techniques are usually used. L2 regularization is a standard technique for deep network training. Given a dataset D and model parameters w, the total loss is defined as follows.

[0141]

[0142] Where L represents the task loss function. When the training converges, the following equation should exist:

[0143]

[0144] in, indicates that the i-th weight is at its minimum value.

[0145] Specifically, in order to verify the effectiveness of the algorithm proposed in this embodiment, several authoritative evaluation indicators in the field of object detection are used to verify the effectiveness of the algorithm proposed in this embodiment, mainly including three indicators: mAP, mAP@.5:.95 and model size. Precision and Recall are used to measure the accuracy of algorithm classification, and their calculation requires four indicators:

[0146] TP (True Positives) indicates that the target of interest is correctly identified during the target detection process; TN (True Negatives) indicates that the target of non-interest is correctly identified; FP (False Positives) indicates that the target of non-interest is identified as the target of interest, resulting in a false detection; FN (False Negatives) indicates that the target of interest is identified as the target of non-interest, resulting in a missed detection.

[0147] Precision represents the ratio of correctly detected targets to the total detected targets, as shown below.

[0148]

[0149] Recall represents the ratio of correctly detected targets to the total detected targets, as shown below.

[0150]

[0151] In order to better evaluate the performance of target detection, we can use the average accuracy AP and the mean average accuracy mAP. mAP is obtained by calculating the AP of each detection category and taking the weighted average. The area value of the closed area drawn with Recall and Precision as the horizontal and vertical coordinates is the average accuracy AP. The calculation formula of mAP is as follows.

[0152]

[0153] Among them, C is the number of categories; AP i is the AP value of the i-th class. mAP@.5:95 represents the average mAP under different intersection-over-union thresholds.

[0154] Optionally, the quantitative and qualitative analysis of the target detection results of this embodiment is as follows: the data set used in this embodiment, the types in the data set are car, bus, van and other. The data set is divided into a training set, a test set and a validation set in a ratio of 7:2:1, wherein the training set has 16667 images, the test set has 4763 images and the validation set has 2381 images.

[0155] (1) Quantitative analysis of target detection results

[0156] In order to evaluate the performance of the improved algorithm proposed in this study in the vehicle target detection task, this embodiment selects multiple classic models in the field of target detection as benchmarks for comparative analysis. On the premise of ensuring that all algorithms involved in the comparison use a consistent data set, different network architectures such as Faster RCNN, SSD, YOLOV5, YOLOv8, YOLOv7, and YOLOv7-tiny are exhaustively tested. Through comparative analysis, this embodiment can comprehensively evaluate the performance difference between the improved algorithm and the existing model under the same conditions. The experimental results are summarized in Table 1, which lists in detail the performance indicators of each model in the vehicle target detection task. These indicators not only cover the detection accuracy of the model, but also include other key performance evaluation factors.

[0157] Table 1 Performance comparison of this model with other classic network models

[0158] Model mAP@0.5 / % mAP@.5:.95 / % Model size / M FasterRCNN 84.3 63.4 137.1 SSD 83.3 62.8 26.3 YOLOv5x 84.7 63.9 86.7 YOLOv7 88.1 65.1 72.0 YOLOv7-tiny 85.0 60.8 11.7 This embodiment model 87.0 64.3 8.7

[0159] As can be seen from Table 1, the network models with lower mAP than the algorithm of this embodiment are Faster RCNN, SSD, YOLOv5x and YOLOv7-tiny. FasterRCNN, as a classic two-stage target detection algorithm, is not much different from the algorithm of this embodiment in terms of accuracy, and its model size is 15.7 times that of the algorithm of this embodiment; SSD, as an early single-stage target detection algorithm, has improved model size and FPS compared with FasterRCNN, and its model size is 3 times that of the algorithm of this embodiment, and its accuracy is 3.7% lower than that of the algorithm proposed in this embodiment; YOLOv5x network model is a relatively large model with higher accuracy in the YOLOv5 algorithm, and its model size is 9.9 times that of the algorithm of this embodiment, and its real-time performance is not much different from that of this embodiment; YOLOv7-tiny is the basic network model of this embodiment, which is slightly lower than the algorithm proposed in this embodiment in terms of accuracy and model size. The network model with higher mAP than the algorithm of this embodiment is YOLOv7. Compared with the basic network model YOLOv7-tiny of this embodiment, YOLOv7 strives to be more stable in accuracy, but has higher requirements on computing power equipment. It can be seen from the table that the accuracy of its model is higher than that of the algorithm proposed in this embodiment, but the network model is larger than the network model proposed in this embodiment, and the model size is 8.3 times that of the model proposed in this article. The mAP of the improved YOLOv7-tiny vehicle target detection algorithm proposed in this embodiment reaches 87%, which is 2% higher than the basic YOLOv7-tinymAP. The average mAP under different intersection-over-union ratio thresholds reaches 64.3%, which is 3.5% higher than the basic YOLOv7-tiny. In summary, the improved YOLOv7-tiny vehicle target detection algorithm not only ensures the accuracy of algorithm detection, but also reduces the parameters of the model, making the model lighter, reflecting the advantages of the algorithm of this embodiment in the field of roadside vehicle detection, and can provide accurate and efficient detection results for subsequent vehicle target tracking under single camera and multiple cameras. In order to verify the influence of different pruning strategies on the model, the improved model was pruned by the pruning strategy on the data set prepared in this embodiment, and the results are shown in Table 2. Sparse means that sparse training is required, 2.0x means it is set to twice the speed (1.5x is the same), and when the model compression reaches the set speed, it will automatically enter the fine-tuning stage.

[0160] Table 2 Comparison of model pruning effects

[0161]

[0162] According to Table 2, the models obtained by using three different pruning strategies based on the improved algorithm model in this embodiment have all decreased in model size and parameter quantity, but the corresponding mAP has decreased. The network model parameter quantity obtained by the importance-based layer adaptive pruning strategy at 1.5 times the speed is 55.9% of the original model parameter quantity, and the accuracy has decreased by 1.9%; the network model parameter quantity obtained by the importance-based layer adaptive pruning strategy at 2.0 times the speed is 42.7% of the original model parameter quantity, and the accuracy has decreased by 3.1%; the network model parameter quantity obtained by the channel weight-based pruning strategy at 2.0 times the speed is 41.1% of the original model parameter quantity, and the accuracy has decreased by 2.6%; the network model parameter quantity obtained by the growth regularization-based pruning strategy is 36.1% of the original model parameter quantity, and the accuracy has decreased by 1.3%. The corresponding sizes of the network models obtained by different pruning strategies have all decreased. In actual application, different network models can be selected according to the needs of the application.

[0163] (2) Qualitative analysis of target detection results The training is performed according to the pre-set parameters (as shown in Table 3). The confidence loss (cls_Loss), coordinate regression loss (box_Loss) and target confidence loss (obj_Loss) during the training process are as follows: Fig.10 As shown. The values ​​of the three losses gradually decrease with the increase of epochs. When the epoch reaches the set threshold, the three losses show a trend of convergence. It can be seen from the figure that the improved detection model converges faster than the YOLOv7-tiny model. In order to verify the effect of the target detection algorithm of this embodiment in practical applications, some frames of some road monitoring videos were selected as the input of the algorithm. The detection results obtained show the detection effects on sunny days, rainy days, evenings and nights. It can be seen from the detection results that the improved algorithm can identify all vehicle targets in the current scene in different scenes, with a high recognition rate and no missed detection problems. In addition, it can be seen from the detection results that the algorithm can adapt to the detection tasks of vehicle targets under different camera perspectives.

[0164] Table 3 Parameter setting table

[0165] Parameter Type Parameter Value Image size 640×640 BatchSize 32 Epoch 300 Weight decay coefficient 0.0005 Momentum Factor 0.937 Initial learning rate 0.01

[0166] In order to verify whether the pruned model can accurately complete the target detection task, this embodiment selects the model pruned based on the growth regularization pruning strategy with the best effect in Table 2 for qualitative analysis, explores the effectiveness of the pruned model, and selects pictures of the same scene as the detection result for detection. It can be seen that the pruned model can still complete the vehicle detection and recognition tasks in different scenes, and has a better effect on the detection of close-up vehicle age targets. For the same vehicle in the same scene, the accuracy of the pruned model is higher than that of the unpruned model.

[0167] In order to verify whether the various improvements in the algorithm proposed in this embodiment are effective, an ablation experiment is set up. Different models are added one by one on the basis of YOLOv7-tiny. The ablation experiment results of various performance indicators under different models are compared as shown in Table 4. In addition, the purpose of the ablation experiment is to explore whether each improved model is effective for the algorithm, so the selected evaluation indicators are mAP, mAP@.5:.95 and parameter quantity. "√" in the table indicates that the improved model is used in the model, and "×" indicates that the improved model is not used in the model. A means that the YOLOv7-tiny backbone is replaced by a lightweight backbone MobileNetV3, B means that the GSConv and VOV-GSCSP lightweight models are used, C means that the self-attention dynamic detection head is introduced, and D means that the DecoupledHead decoupling head is added.

[0168] Table 4. Comparison of ablation experiment results

[0169]

[0170] According to Table 4, after the first group of experiments replaced the YOLOv7-tiny backbone network with MobileNetV3, the model size was reduced by 38.9% of the original baseline network, and the mAP increased by 0.2%, indicating that the use of MobileNetV3 can achieve lightweight models while maintaining stable accuracy, thanks to the linear bottleneck inverted residual structure and SE attention mechanism in MobileNetV3. The second group of experiments added different numbers of GSConv and VOV-GSCSP models on the basis of replacing the network backbone with MobileNetV3 in the first group of experiments. After adding the models, the model size was reduced by 41.7% of the original baseline network, and the mAP increased by 0.1% compared with the first group of experiments, and the mAP@.5:.95 decreased by 0.1%, indicating that adding GSConv and VOV-GSCSP models can reduce redundant information and make the model more lightweight. The third group of experiments added the self-attention dynamic detection head Dyhead on the basis of the second group of experiments. The mAP increased by 1.1% compared with the second group of experiments, and increased by 1.4% compared with the original baseline network. The model size was reduced by 32.1% compared with the original baseline network. Compared with the second group of experiments, it increased, mainly because the head model was added on the basis of the original network. However, the accuracy of the self-attention dynamic detection head Dyhead was significantly improved, indicating that the perception ability was improved after adding the self-attention dynamic detection head Dyhead, and the feature expression ability was enhanced. The fourth group of experiments added the decoupling head on the basis of the third group of experiments. The mAP increased by 0.3% compared with the third group of experiments, and increased by 2% compared with the original baseline network. The model size was reduced by 25.3% compared with the original baseline network. In multiple groups of experiments, through the analysis and comparison of mAP and parameter quantity, it was found that the improved algorithm performed well. While keeping the model lightweight, it also has efficient feature extraction capabilities, which is suitable for deployment in applications with limited computing resources. When training the baseline algorithm and the improved algorithm, the change curves of mAP@0.5 and mAP@.5:.95 of the two algorithms are compared. Fig.11 shown.

[0171] In summary, the improvement measures of this embodiment have a positive impact on improving the accuracy and lightweight degree of the vehicle target detection algorithm, and show excellent performance. While the model feature extraction capability does not decrease and is slightly improved, the model meets the lightweight requirements.

[0172] Corresponding to the above method, this embodiment also discloses a YOLOv7-tiny lightweight vehicle target detection system, including:

[0173] The dataset construction module is used to construct a roadside vehicle dataset containing vehicle images of various models and under different lighting and weather conditions;

[0174] A data set processing module, used for performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set;

[0175] A model improvement module, used to construct an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network;

[0176] A lightweight module, used for applying a pruning strategy to perform lightweight processing on the initial vehicle target detection model to obtain a lightweight vehicle detection model;

[0177] A training module, used for inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and validation to obtain a final vehicle target detection model;

[0178] The detection module is used to input the image to be detected into the final vehicle target detection model to obtain the detection result.

[0179] The beneficial effects of the present invention are as follows:

[0180] (1) Compared with the classic target detection algorithms in the target detection field, the improved YOLOv7-tiny lightweight vehicle target detection algorithm proposed in the present invention has better accuracy, smaller model and faster speed. Compared with the original YOLOv7-tiny model, the mAP of the improved algorithm is improved by 2%, and the average mAP in the IoU threshold range of 0.5 to 0.95 reaches 64.3%, which is improved by 3.5%.

[0181] (2) The present invention lightweights the improved model by applying three different pruning strategies. Although the mAP is sacrificed to a certain extent, the size and number of parameters of the model are significantly reduced, making the model more suitable for deployment in resource-constrained environments.

[0182] (3) The algorithm proposed in the present invention can identify vehicle targets in the current scene under various conditions such as sunny days, rainy days, evening and night, and the recognition rate is relatively high.

[0183] (4) Through ablation experiments, the present invention effectively verifies that the different improvement strategies proposed are meaningful to a certain extent in terms of lightweight and detection accuracy of vehicle target detection.

[0184] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0185] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A YOLOv7-tiny lightweight vehicle target detection method, characterized in that: include: Construct a roadside vehicle dataset containing vehicle images of various models, in different lighting and weather conditions; Performing image filtering, image enhancement, and data set division on the roadside vehicle data set to obtain a training set, a validation set, and a test set; Constructing an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network; Applying a pruning strategy to lightweight the initial vehicle target detection model to obtain a lightweight vehicle detection model; Inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and verification to obtain a final vehicle target detection model; The image to be detected is input into the final vehicle target detection model to obtain a detection result.

2. The YOLOv7-tiny lightweight vehicle target detection method according to claim 1, characterized in that The target categories in the roadside vehicle dataset include: cars, buses, vans and others.

3. The YOLOv7-tiny lightweight vehicle target detection method according to claim 1, characterized in that The roadside vehicle dataset is subjected to image filtering, image enhancement and dataset division to obtain a training set, a validation set and a test set, including: Performing filtering processing on the image in the roadside vehicle data set to obtain a filtered image; Constructing an image enhancement window, and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image; Performing histogram equalization processing on the denoised image to obtain an enhanced image; The enhanced images are divided into data sets according to a preset ratio to obtain the training set, the verification set and the test set.

4. The YOLOv7-tiny lightweight vehicle target detection method according to claim 3, characterized in that Filtering the image in the roadside vehicle data set to obtain a filtered image includes: Performing wavelet decomposition on the roadside vehicle data set at multiple scales to obtain corresponding wavelet coefficients; A filtering threshold is constructed according to the size and decomposition scale of the roadside vehicle data set; the formula of the filtering threshold is: Among them, λ j represents the filtering threshold at the jth decomposition scale, σ j represents the standard deviation of the noise at the jth decomposition scale, N j represents the signal length at the jth decomposition scale, where j represents the decomposition scale; The image filtering model is constructed using the filtering threshold; the formula of the image filtering model is: Wherein, sign is the sign function, a is the first preset coefficient, b is the second preset coefficient, ω j,k represents the kth wavelet coefficient at the jth decomposition scale, represents the wavelet coefficients after filtering; The image of the roadside vehicle data set is filtered using the image filtering model to obtain the filtered image.

5. The YOLOv7-tiny lightweight vehicle target detection method according to claim 3, characterized in that Constructing an image enhancement window, and using the image enhancement window to traverse the filtered image to perform denoising to obtain a denoised image, including: Detecting the filtered image using an image recognition model to obtain a proportion value under each image enhancement window; When the proportion value in the image enhancement window is greater than a preset threshold, median denoising is performed on the image in the corresponding image enhancement window to obtain an image after median denoising; The image enhancement window is slid until the entire filtered image is traversed to obtain the denoised image.

6. The YOLOv7-tiny lightweight vehicle target detection method according to claim 5, characterized in that The filtered image is detected using an image recognition model to obtain a proportion value under each image enhancement window, including: Using Formula F ij =|x ij -y ij |Get the pixel difference of each pixel under each image enhancement window; where F ij Represents the pixel difference of the image at position (i, j), x ij Represents the pixel value of the image at position (i, j), y ij represents the pixel value of the filtered image at position (i, j); Pixels whose pixel difference is greater than the feature threshold are taken as feature points and the number is recorded; The ratio of the feature points to all the pixels in the image enhancement window is taken as the ratio value.

7. The YOLOv7-tiny lightweight vehicle target detection method according to claim 5, characterized in that The initial vehicle target detection model includes: an input network, a backbone network, a neck network and a detection head connected in sequence; The input network is used to perform data enhancement and image preprocessing operations on the input image set to obtain a preprocessed image; the backbone network is used to extract image features on the preprocessed image based on the ELAN model and the MP model to obtain a feature map; the neck network is used to perform feature fusion and enhancement on the feature map to obtain a fusion map; the detection head is used to perform feature detection based on the fusion map to obtain a detection result.

8. The YOLOv7-tiny lightweight vehicle target detection method according to claim 7, characterized in that: The backbone network of the backbone network is the MobileNetV3 network.

9. The YOLOv7-tiny lightweight vehicle target detection method according to claim 1, characterized in that: The pruning strategies include: importance-based layer adaptive pruning, channel weight-based pruning, and growth regularization-based pruning.

10. A YOLOv7-tiny lightweight vehicle target detection system, characterized in that: include: The dataset construction module is used to construct a roadside vehicle dataset containing vehicle images of various models and under different lighting and weather conditions; A data set processing module, used for performing image filtering, image enhancement and data set division on the roadside vehicle data set to obtain a training set, a validation set and a test set; A model improvement module, used to construct an improved initial vehicle target detection model; the initial vehicle target detection model is designed based on the YOLOv7-tiny network; A lightweight module, used for applying a pruning strategy to perform lightweight processing on the initial vehicle target detection model to obtain a lightweight vehicle detection model; A training module, used for inputting the training set, the validation set and the test set into the lightweight vehicle detection model for training, testing and validation to obtain a final vehicle target detection model; The detection module is used to input the image to be detected into the final vehicle target detection model to obtain the detection result.

Citation Information

Patent Citations

  • Lightweight small target detection method based on improved YOLOv7

    CN116206185A

  • Lightweight infrared vehicle target detection method

    CN117253200A

  • Intelligent sweeper target detection method based on YOLOv7

    CN118505973A