Lightweight vehicle detection method

The vehicle detection method combined with improved MobileNet and YOLOv4 solves the computational complexity and real-time problems of the vehicle detection algorithm in edge deployment devices, achieves high accuracy and real-time performance, reduces the model size and parameter amount, and is suitable for Edge deployment scenarios.

CN118537840APending Publication Date: 2024-08-23贵州省都匀公路管理局 +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410698325.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-23

Smart Images

  • Figure CN118537840A
    Figure CN118537840A
Patent Text Reader

Abstract

The invention relates to the technical field of target detection, and particularly discloses a lightweight vehicle detection method, which comprises the following steps of S100, constructing a traffic vehicle detection data set, and dividing the data set into a training set and a test set which are respectively used for training and testing a model; s200, constructing a lightweight algorithm model, wherein the lightweight algorithm model takes YOLOv4 as an original model and adopts an improved MobileNet as a trunk feature extraction network; s300, inputting the data set into a lightweight YOLOv4 algorithm model for training and fitting to obtain a trained lightweight algorithm model; and S400, detecting a vehicle image by using the trained lightweight algorithm model. The invention aims to solve the problems that the existing vehicle detection algorithm is high in calculation complexity, poor in real-time performance, large in model occupied memory and not suitable for edge deployment equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to a lightweight vehicle detection method. Background Art

[0002] Vehicle detection is a key research technology in the fields of traffic detection, abnormal vehicle analysis in traffic videos, driver assistance systems and autonomous driving; at the same time, it has always been an important and challenging problem in the field of machine vision. At present, commonly used vehicle detection methods can be divided into two types: traditional methods and methods based on deep learning. The accuracy of traditional target detection algorithms is usually low and can no longer meet actual needs. With the rapid development of deep learning, it has gradually become a powerful ability to extract learning image features, with the advantages of strong generalization ability and high robustness. Vehicle detection based on computer vision combined with deep learning has gradually become the mainstream method in this field. However, most deep learning methods have problems such as high computational complexity, poor real-time performance, and large model memory usage, which makes them unable to be applied to actual edge scenarios because of limited terminal computing resources and storage space; deep learning methods are difficult to apply to embedded platforms. Therefore, finding a vehicle detection method that can maintain high accuracy and real-time performance while adapting to limited resources has become an important and urgent issue. As an advanced target detector, YOLOv4 has achieved good detection speed and detection accuracy on major data sets, but it often does not achieve good results in real-world scenarios with limited computing resources and storage resources. Therefore, how to use less computing resources and storage resources to ensure detection accuracy while also meeting the real-time detection requirements is an urgent problem to be solved. Summary of the invention

[0003] In view of the shortcomings of the prior art, the technical problem solved by the present invention is to provide a lightweight vehicle detection method to solve the problems of the existing vehicle detection algorithm, which has high computational complexity, poor real-time performance, large model memory usage, and cannot be applied to edge deployment devices. In order to solve the above problems, the technical solution adopted by the present invention is:

[0004] A lightweight vehicle detection method comprises the following steps:

[0005] S100: Construct a traffic vehicle detection dataset and divide the dataset into a training set and a test set for model training and testing respectively;

[0006] S200: constructing a lightweight algorithm model, wherein the lightweight algorithm model uses YOLOv4 as the original model and adopts an improved MobileNet as the backbone feature extraction network;

[0007] S300: input the data set into the lightweight YOLOv4 algorithm model for training and fitting, and obtain a trained lightweight algorithm model;

[0008] S400: Detecting vehicle images using the trained lightweight algorithm model.

[0009] Furthermore, in step S200, the MobileNet network model is improved by adding channel shuffling to the MobileNet network model.

[0010] Furthermore, in the model training parameters of step S300, the initial learning rate is 1e-3, the maximum number of iterations is 50,500, the learning rate decays to 1e-4 when the iteration reaches 25,000, and the learning rate decays to 1e-5 when the iteration reaches 35,000.

[0011] Furthermore, in the model training parameters of step S300, the ratio of the training set to the test set is 9:1-8:2, the IoU threshold is set to 0.4-0.6, and the batch size is 7-9.

[0012] Furthermore, the traffic vehicle detection dataset includes a KITTI dataset, a UA-DETRAC dataset and an manually collected urban road dataset, and the KITTI dataset is preprocessed and converted into a VOC format dataset.

[0013] Furthermore, in step S100, the traffic vehicle detection dataset is preprocessed using Mosaic data enhancement.

[0014] The beneficial effects of this program are:

[0015] By adopting the improved MobileNet as the backbone feature extraction network and integrating it into the YOLOv4 target detection model, channel shuffling is added to the MobileNet V2 model, so that the feature information between groups can be well integrated, thereby improving the detection accuracy of the model.

[0016] In this way, the complexity of vehicle detection can be reduced, the model size can be compressed, the real-time performance of detection can be improved, and the accuracy of detection can be guaranteed. In addition, the manually collected data sets and the data sets shared on the network are analyzed in edge deployment scenarios with low computing power. Through experimental testing and verification, it is proved that under the condition of meeting the real-time requirements, the accuracy rate can reach more than 94%, and different types of vehicles and pedestrians can be identified; after experimental testing, the parameter volume of this scheme is 1 / 3 of that of the YOLOv4 model, and the model size is reduced by about 10 times compared with the original YOLOv4 model. While ensuring the accuracy, the model size and parameter volume are effectively reduced, the detection speed is improved, and the real-time requirements can still be met in an environment with limited computing resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 This is the improved YOLOv4 network model structure of the present invention.

[0018] Figure 2 This is a comparison chart of vehicle detection results. DETAILED DESCRIPTION

[0019] The following is further described in detail through specific implementation methods:

[0020] Example 1 The specific network structure is as shown in the attached Figure 1 As shown:

[0021] A lightweight vehicle detection method comprises the following steps:

[0022] S100: Construct a traffic vehicle detection dataset and divide the dataset into a training set and a test set, which are used for model training and testing respectively; the traffic vehicle detection dataset includes the public KITTI dataset, UA-DETRAC dataset, and a manually collected urban road dataset, and the KITTI dataset is preprocessed and converted into a VOC format dataset; the traffic vehicle detection dataset is preprocessed using Mosaic data enhancement.

[0023] S200: Build a lightweight algorithm model. The lightweight algorithm model uses YOLOv4 as the original model and My-Mobile Net as the backbone feature extraction network. My-Mobile Net is a model that improves the MobileNet network model by adding channel shuffling to the Mobile Net V2 network model.

[0024] Channel shuffling includes the following steps: S201: The number of groups needs to be determined based on the number of channels of the input feature map; S202: Group the input channels according to the determined number of groups. For example, if the feature map has 24 channels and is divided into 3 groups, each group will contain 8 channels. This step is completed through the Reshape and Transpose operations, where Reshape is responsible for adjusting the channel dimension and Transpose realizes the permutation between channels. S203: After the grouping is completed, the channels within each group will be shuffled. This operation ensures that channels from different original positions can be mixed together, thereby providing richer feature representations in subsequent layers of the network.

[0025] S300: input the data set into the lightweight YOLOv4 algorithm model for training and fitting, and obtain a trained lightweight algorithm model;

[0026] S400: Detecting vehicle images using the trained lightweight algorithm model.

[0027] First, the proposed lighter-weight improved My-MobileNet is used to replace CSPDarknet-53 as the backbone feature extraction network to extract multi-scale feature maps; then the SSP and PANet in the YOLOv4 network structure model are used for further feature fusion; finally, the prediction box of vehicle detection is linearly attenuated using the NMS algorithm to obtain the vehicle detection result. In order to improve the training speed, the Mosaic data enhancement method is used to preprocess the traffic vehicle detection dataset used for training, and 4 pictures are combined into one picture for training.

[0028] In step S100, an urban road dataset is manually collected, which is an actual road video image collected manually, and the corresponding VOC format annotation is performed on it, and the video frame rate is 25 frames per second. One of the five collected videos is used as a test set, and the remaining four videos are fused with the KITTI dataset and the UA-DETRAC dataset into a test set, thereby improving the robustness of the algorithm.

[0029] In step S300, the specific steps of model training are as follows:

[0030] The training parameters are set. The initial learning rate of the model training parameters is 1e-3, the maximum number of iterations is 50500, the learning rate decays to 1e-4 when the iteration reaches 25000, and the learning rate is 1e-5 when the iteration reaches 35000; the ratio of the training set to the test set is 9:1, the IoU threshold is set to 0.5, and the batch size is 8.

[0031] In the S301 model training stage, forward propagation is first performed to calculate the error between the target's real box and the predicted box, and then backpropagation is performed to continuously minimize the error to optimize the network parameters, so that a good detection effect is finally achieved.

[0032] S302 tests the model, and verifies the network model through the test set during the training process, verifies whether the model converges, and determines whether overfitting or underfitting occurs.

[0033] S303 fine-tunes the model, integrating the manually collected dataset with the KITTI dataset and the UA-DETRAC dataset to complete the training. To this end, a pre-trained model is added during training to fine-tune the network. During the training process, the weight file is saved regularly, and a loss function graph is drawn. By observing the loss function graph, the network parameters are fine-tuned to obtain the optimal network model.

[0034] S304 saves the model. After fine-tuning the network in the previous step, the network model reaches the optimal training result and is saved for use in subsequent vehicle detection.

[0035] The performance of this solution is verified through the following experiments; the test is carried out in the ARM architecture environment. This experiment conducts corresponding tests in multiple different scenarios on three datasets, including the KITTI dataset, the UA-DETRAC dataset, and manually captured urban roads, to verify the performance of the vehicle detection method of this solution.

[0036] Since the YOLOv4 algorithm has obvious advantages over other lightweight target detection algorithms, on the other hand, YOLOv4+Moblie Net makes corresponding improvements based on the YOLOv4 algorithm to make its network model more lightweight. This experiment compares with YOLOv4 and Moblie Net+YOLOv4 respectively. The vehicle detection results are as follows: Figure 2 As shown in the figure, the three vehicle detection algorithms are compared for scenes with poor lighting on sunny days in the KITTI dataset, scenes with poor lighting on rainy days in the UA-DETRAC dataset, and scenes with good lighting on sunny days in the urban road dataset. The number and confidence of vehicles detected by the YOLOv4 algorithm are relatively high. The number of vehicles detected by the method of this scheme is roughly the same as that of YOLOv4, and the confidence of detecting nearby vehicles is slightly higher than that of the YOLOv4 algorithm. The number of vehicles detected by YOLOv4+MobileNet is relatively small, and the confidence is also relatively low. Vehicles in the distance are almost impossible to detect.

[0037] The accuracy rate (Precision), recall rate (Recall), average precision (AP), detection speed (FPS), parameter amount (Parameter), and model size (Weigh) are used as indicators to measure the performance of the model. Among them, the parameter amount, detection speed, and model size are important criteria for measuring whether the model is a lightweight model. The accuracy rate, recall rate, and average precision are important criteria for measuring the performance of the network model. For this reason, the performance indicators of vehicle detection are analyzed on three different data sets, using three different input sizes to analyze the performance of the model proposed in this paper, and compared with the YOLOv4 algorithm and the YOLOv4+Mobile Net algorithm.

[0038] The experimental results are shown in Table 1.

[0039] Table 1 Comparison of model performance under different input sizes

[0040]

[0041] Compared with the YOLOv4 model, the accuracy of the YOLOv4 model is slightly higher than the YOLOv4+My MobileNet detection method of this scheme, but in large-size detection, the accuracy of this detection method is slightly higher than the traditional YOLOv4 model, but as the size of the input image increases, distant objects gradually become clear, so that the detection method of this scheme achieves a good accuracy. However, from the perspective of lightweight, the number of parameters of the method proposed in this paper is 1 / 3 of that of the YOLOv4 model compared to YOLOv4, and the model size is reduced by nearly 10 times, which is enough to meet the lightweight of the model. For the detection speed, since this paper is tested under a CPU with limited computing power, the overall detection speed is low, but compared with the YOLOv4 algorithm, the detection speed of the algorithm proposed in this paper is nearly 2 times higher. When the input detection image is 960x540, the algorithm proposed in this paper can still meet the real-time requirement of FPS not less than 12, but the YOLOv4 model cannot meet the real-time requirement. Compared with the YOLOv4+MobileNet model, since the MobileNet network model does not add channel shuffling, the feature information between groups cannot be well fused, so the accuracy is not as high as the detection method of this scheme. The detection method of this scheme can be 4.5% higher than the accuracy of YOLOv4+MobileNet when the model size is small.

[0042] From a comprehensive perspective, the detection method developed in this scheme is better than YOLOv4 and YOLOv4-Mobile Net. While ensuring the accuracy, it reduces the size of the network model and the number of parameters, improves the detection speed, and can still meet the real-time requirements in an environment with limited computing resources.

[0043] The above is only an embodiment of the present invention, and the common knowledge such as the known specific structure and characteristics in the scheme is not described in detail here. It should be pointed out that for those skilled in the art, several deformations and improvements can be made without departing from the structure of the present invention, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A lightweight vehicle detection method, characterized in that: The following steps are included: S100: Construct a traffic vehicle detection dataset and divide the dataset into a training set and a test set for model training and testing respectively; S200: constructing a lightweight algorithm model, wherein the lightweight algorithm model uses YOLOv4 as the original model and adopts an improved MobileNet as the backbone feature extraction network; S300: input the data set into the lightweight YOLOv4 algorithm model for training and fitting, and obtain a trained lightweight algorithm model; S400: Detecting vehicle images using the trained lightweight algorithm model.

2. A lightweight vehicle detection method according to claim 1, characterized in that: In step S200, the MobileNet network model is improved by adding channel shuffling to the MobileNet network model.

3. A lightweight vehicle detection method according to claim 1, characterized in that: In the model training parameters of step S300, the initial learning rate is 1e-3, the maximum number of iterations is 50,500, the learning rate decays to 1e-4 when the iteration reaches 25,000, and the learning rate decays to 1e-5 when the iteration reaches 35,000.

4. A lightweight vehicle detection method according to claim 1, characterized in that: In the model training parameters of step S300, the ratio of the training set to the test set is 9:1-8:2, the IoU threshold is set to 0.4-0.6, and the batch size is 7-9.

5. A lightweight vehicle detection method according to claim 1, characterized in that: The traffic vehicle detection dataset includes a KITTI dataset, a UA-DETRAC dataset, and an artificially collected urban road dataset, and the KITTI dataset is preprocessed and converted into a VOC format dataset.

6. A lightweight vehicle detection method according to claim 1, characterized in that: In step S100, the vehicle detection data set is preprocessed using Mosaic data enhancement.

Citation Information

Patent Citations

  • Universal lightweight deep learning vehicle detection method

    CN113177560A

  • Vehicle detection method based on improved YOLOv4 model

    CN114283390A

  • Road vehicle detection system and method based on YOLOv4

    CN114821492A

  • Context feature fusion method based on MobileNet lightweight network

    CN115019279A

  • Lightweight embedded real-time vehicle detection algorithm

    CN117671618A