Vehicle identification method under complex illumination condition based on improved YOLOV5s
By improving the YOLOV5s algorithm, combined with the BDD100K data set and feature fusion technology, the missed detection and misdetection problem of vehicle detection under complex lighting conditions is solved, the detection accuracy and sensitivity are improved, and the generalization ability of the model is enhanced.
Patent Information
- Application Number
- CN202411214561.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-01
- Publication Date
- 2024-12-27
AI Technical Summary
Existing vehicle detection algorithms are prone to missed and missed detection problems under complex lighting conditions, and are difficult to transplant in different detection tasks, with low detection accuracy and poor model generalization capabilities.
Using the improved YOLOV5s algorithm, by building the YOLOv5s model under the PyTorch framework, processing the BDD100K dataset, designing the backbone network structure, including CSPDarknet, C3 module and SPPF module, combining shallow graphic features and deep semantic features, Detect module is used for vehicle identification , and eliminate boxes with low confidence and high overlap by non-maximum value suppression to improve detection accuracy.
It improves vehicle detection accuracy and sensitivity under complex lighting conditions, enhances the generalization ability and robustness of the model, reduces false detection and missed detection, and improves the accuracy of vehicle identification.
Smart Images

Figure CN119206637A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a vehicle recognition method, and in particular to a vehicle recognition method under complex lighting conditions based on improved YOLOV5s. Background Art
[0002] Intelligent traffic management can effectively alleviate traffic congestion and reduce the frequency of traffic accidents, among which vehicle recognition technology is an important component of intelligent traffic. At present, there are many methods to realize vehicle recognition technology. In actual detection, due to complex lighting conditions, inaccurate detection, missed detection or false detection of vehicle models may occur.
[0003] The most widely used traditional image recognition methods are frame difference method and background difference method. Although traditional image recognition methods can detect image targets, they rely heavily on artificially designed features. When the detection object is changed, the artificial features need to be redesigned and cannot be transplanted in different detection tasks. The extracted features are limited to shallow information such as local texture, color, and contrast, and it is difficult to express high-level semantic information such as posture and morphology, resulting in low detection accuracy and poor model generalization ability. Therefore, traditional vehicle detection methods have limitations in actual detection. With the rapid development of the Internet, the training of neural networks has a huge data driving force, coupled with the continuous improvement of computer parallel computing power, many favorable conditions have led to the rise of AlexNet in 2012. Thanks to the powerful feature representation ability of convolutional neural networks, target detection algorithms based on deep learning have flourished and gradually occupied the dominant position of network architecture in the field of target detection. Many excellent detection models have also been launched one after another.
[0004] Compared with traditional algorithms, the YOLO algorithm does not need to generate a prediction box during detection. It directly extracts features in the grid to classify and identify targets, which greatly reduces the calculation speed. In addition, the YOLO algorithm has a simple structure and an amazing detection speed. It can be better deployed on hardware and better applied in practice. In vehicle detection systems, many problems that cannot be solved by traditional methods have been solved in methods based on deep learning. However, when facing traffic road conditions under complex lighting conditions, existing vehicle detection algorithms still have the problems of missed detection and false detection. Moreover, most vehicle detection is based on binary classification detection, and the vehicle categories are not subdivided. Therefore, in view of the problem of identifying vehicles under complex light conditions studied by the present invention, the present invention uses an improved YOLOV5s algorithm to identify road vehicles to improve the detection accuracy of vehicles. Summary of the invention
[0005] The purpose of the present invention is to solve the problem of missed detection and false detection in the existing vehicle detection algorithm when facing traffic road conditions under complex lighting conditions, and to propose a vehicle recognition method under complex lighting conditions based on improved YOLOV5s.
[0006] The above purpose is achieved through the following technical solutions:
[0007] A vehicle recognition method under complex lighting conditions based on improved YOLOV5s, the method is implemented by the following steps:
[0008] Step 1: Build the network structure of the YOLOv5s model based on the PyTorch framework;
[0009] Step 2: Process the public dataset BDD100K and train the built YOLOv5s model with the processed BDD100K dataset;
[0010] Step 3: Use the trained YOLOv5s model to identify vehicles in the target image.
[0011] Furthermore, the processing of the public data set BDD100K data set described in step 2 refers to removing the data with a lot of noise in the BDD100K data set, that is, pictures with no identification targets at all, blurred pictures or non-existent picture data; then, adjusting the data set format and annotating the pictures through annotation tools to generate the txt format required by the YOLOv5s model.
[0012] Furthermore, the steps of training the YOLOv5s model built in step 2 are specifically as follows:
[0013] First, build the model's operating environment, including: preparing weight files;
[0014] Then, based on the YOLOV5s model, the module or network structure is improved; the YOLOV5s model network framework is designed to include the backbone layer, neck layer, and head layer;
[0015] The backbone layer is the backbone network, which uses CSPDarknet to extract feature information. The CSPNet structure is also added to the backbone network. The backbone structure includes Conv module, C3 module and SPPF module. Among them:
[0016] The Conv module includes a Conv2d, a BatchNorm2d and an activation function; the Conv module is used to extract features and organize feature maps; the paddingg of Conv2d in the Conv module is automatically calculated, and the reduction factor of the feature map is determined by modifying the stride; in the backbone, the stride of the Conv module is all 2, and the kernel is all 3; therefore, Conv will halve the width and height of the feature map each time, downsample the feature map, and extract the target features at the same time; the backbone and neck both use the Conv module to increase or decrease the dimension of the feature map, and there are many 1*1 convolutions; BatchNorm2d is a batch normalization layer, which normalizes each batch of data;
[0017] The C3 module includes three Conv modules and one Bottleneck module. After the feature map enters C3, it will be divided into two paths. The left path passes through Conv and a Bottleneck, and the right path passes through only one Conv. Finally, the two paths are concat and then pass through another Conv. The three Conv modules in the C3 module are all 1*1 convolutions. Bottleneck uses residual connections in the backbone. There are two Convs in Bottleneck. The first Conv is a 1*1 convolution, which reduces the channel to half of the original, and the second is a 3*3 convolution, which doubles the number of channels. Finally, the residual structure is used to add the input and output.
[0018] The SPPF module is a spatial pyramid pooling module. The SPPF module integrates multi-scale features in the YOLOV5s model and concats the feature representations of different scales of the same feature map together.
[0019] The structure of the Neck layer is a feature pyramid, which combines shallow graphic features with shallow semantic features. That is, the Neck layer of the YOLOv5 model obtains relatively shallow features from the backbone and concats them with deep semantic features to obtain more complete features.
[0020] The head layer uses the Detect module. The network structure of the Detect module includes three 1*1 convolutions, corresponding to three detection feature layers. The role of 1*1 convolution is to increase or decrease the dimension. The number of channels of the 1*1 convolution kernel corresponds to the number of channels of the input feature map, and the number of output channels corresponds to the number of convolution kernels. Using 1*1 convolution does not change the size of the feature map, but changes the channels of the feature map.
[0021] Furthermore, in the step of using the trained YOLOv5s model to identify the vehicle in the target image in step 3,
[0022] When the YOLOV5s model predicts the confidence in the prediction stage, it eliminates the boxes with low confidence and high overlap through non-maximum suppression;
[0023] First, pred is filtered according to the set classification threshold to obtain the prediction box, and then it is sorted according to the classification probability of the classifier category, from small to large, the probability of belonging to the target to be detected;
[0024] (1) Starting from the maximum probability rectangular box, determine whether the overlap IOU with the maximum probability rectangular box is greater than a certain set threshold; if it is greater than the threshold, it is regarded as the object corresponding to the regression F prediction box; otherwise, it is regarded as other objects of regression;
[0025] (2) Suppress the boxes that exceed the threshold. The suppression method is to set the score of the detection box to 0 and mark the first rectangular box with the maximum probability as the retained one;
[0026] (3) Select the one with the highest probability from the remaining rectangles, and then determine the overlap between the remaining rectangles. If the overlap is greater than the threshold, discard it. Mark the largest rectangle as the second rectangle retained.
[0027] (4) Repeat this process to find all the retained rectangular boxes.
[0028] Furthermore, the step of processing the public dataset BDD100K dataset also includes a positive sample matching step, specifically:
[0029] The YOLOv5s model is judged by calculating the extreme values of the width and height of the annotation box and the width and height of the anchor. As long as the extreme value is between 1 / 4 and 4, it means that the anchor grows into the annotation box. At this time, the anchor is set as a positive sample, and a annotation box is assigned multiple anchors as positive samples, which increases the number of positive samples. By increasing the labels in the process of increasing positive samples, it can be understood that many annotation boxes are generated for the same target.
[0030] The beneficial effects of the present invention are:
[0031] In view of the false detection and missed detection problems in existing algorithms during recognition, the present invention proposes a vehicle recognition method based on an improved YOLOV5s model, which can improve the accuracy and sensitivity of detection under complex lighting conditions.
[0032] Through a large number of data samples, the model performance is adjusted and continuously optimized to keep the model in a stable state, so that the innovative modules or adjusted structures can be better integrated into the model network, so that the model can achieve better performance than before; in response to the existing false detection and missed detection problems, a new improved model is constructed and tested to improve the detection accuracy and sensitivity of the model;
[0033] The present invention establishes a model of the improved algorithm, uses the deep learning framework pytorch, builds the network structure and training process of the improved algorithm, and uses the processed data set for training and testing. By selecting actual pictures or scenes for actual testing, the generalization of the improved algorithm and the performance and effect of the improved model of the present invention are verified. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a flow chart of the method of the present invention;
[0035] Figure 2 The YOLOV5s model involved in the present invention includes a detailed structural diagram of the modules;
[0036] Figure 3 is a conceptual diagram of the method of the present invention;
[0037] Figure 4 is the form of confusion matrix involved in the method of the present invention;
[0038] Figure 5 is a confidence curve involved in the method of the present invention;
[0039] Figure 6 Schematic diagram of labels involved in the method of the present invention;
[0040] Figure 7 A diagram of a visualization tool or indicator for evaluating the performance of a target detection model involved in the method of the present invention;
[0041] Figure 8 A curve showing the variation of the precision (Precision) with the confidence (Confidence) involved in the method of the present invention;
[0042] Fig. 9 It is the performance evaluation of the binary classification model involved in the method of the present invention (Precision-Recall Curve);
[0043] Fig.10 The recall_curve curve involved in the method of the present invention is a precision-recall curve;
[0044] Fig.11 It is a graphical representation of the results of the calculations involved in the method of the present invention;
[0045] Fig.12 A training batch of data involved in the method of the present invention;
[0046] Fig.13 A training batch of data involved in the method of the present invention;
[0047] Fig.14 A training batch of data involved in the method of the present invention;
[0048] Fig.15 The labels of the first batch of the validation set involved in the method of the present invention;
[0049] Fig.16 The prediction result of the batch data (val_batch) for verifying the performance of the model involved in the method of the present invention;
[0050] Fig.17 The label portion of the data set for verifying the performance of the model involved in the method of the present invention;
[0051] Fig.18 The prediction results of the first batch of data in the validation set involved in the method of the present invention;
[0052] Fig.19 The true labels of the second batch in the validation data set involved in the method of the present invention;
[0053] Fig. 20 It is the prediction result of the second batch in the validation set involved in the method of the present invention. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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. Specific implementation method one:
[0056] This embodiment is a vehicle recognition method under complex lighting conditions based on improved YOLOV5s, such as Figure 1 As shown, the method is implemented by the following steps:
[0057] Step 1: Build the network structure of the YOLOv5s model based on the PyTorch framework;
[0058] Step 2: Process the public dataset BDD100K and train the built YOLOv5s model with the processed BDD100K dataset;
[0059] Step 3: Use the trained YOLOv5s model to identify vehicles in the target image. Specific implementation method 2:
[0061] Different from the specific implementation method 1, the vehicle recognition method under complex lighting conditions based on the improved YOLOV5s in this implementation method, the processing of the public data set BDD100K data set in step 2 refers to cleaning the BDD100K data set to obtain some clean data sets. In the actual data, there are always some pictures that are relatively blurred or missing, so data cleaning and preprocessing are very necessary. By obtaining open source data sets, a lot of data have been cleaned, but it is still necessary to clean and observe part of them. Generally speaking, data cleaning includes removing the data with a lot of noise in the BDD100K data set, that is, pictures with no identification targets, blurred pictures or non-existent picture data; then, adjust the data set format. The deep learning model based on yolov5 is a supervised learning, which requires labels. The labels here are different from the labels of traditional machine learning. They are a specific category, which is annotated by some annotation tools to generate some fixed formats. The format required by the YOLOv5s model is txt format, and the label format in the BDD100K data set is .json format, so format conversion is required. Specific implementation method three:
[0063] Different from the second specific implementation mode, in this implementation mode, a vehicle recognition method under complex lighting conditions based on improved YOLOV5s, the steps of training and building the YOLOv5s model described in step 2 are specifically:
[0064] First, build the model's operating environment; including: first running the original algorithm, ensuring that the configuration environment supports the operation of the algorithm model, and preparing the required weight files;
[0065] Then, based on the understanding of the algorithm's network structure, training strategy, etc., as well as the modules and strategies of other algorithms in the YOLO series and the modules and implementation methods of other algorithms, combined with the subject task, improve the module or network structure or adjust the parameters on the basis of the YOLOV5s model to achieve the desired effect. This process is a very long process, requiring continuous attempts to modify the module or structure, and to continuously verify the function of the modified module and the impact and changes on the entire network; design the YOLOV5s model network framework including the backbone layer, neck layer and head layer;
[0066] The Backbone layer includes convolution module, C3 module and SPPF module, which are used to extract features from images. The entire backbone layer uses CSPDarknet53 as its backbone network, which has strong feature extraction capabilities and computational efficiency. However, the amount of calculation in this part is large and there are many parameters, which affects the processing efficiency of the entire model. At the same time, the feature extraction capability of the module in this part can also be improved. Therefore, the backbone layer mainly improves the extraction efficiency and accuracy of the module.
[0067] The Neck layer is mainly composed of convolutional layers and C3 modules. The feature fusion method mainly adopts the fusion idea of FPN. FPN uses the high resolution of shallow features and the semantic information of deep features at the same time, and achieves the prediction effect by fusing features of different layers. FPN upsamples the deep features and adds them to the shallow information element by element, thereby constructing a feature pyramid structure of different sizes. This fusion method can well fuse shallow information and deep information, but the fusion method has a single direction and the fused features have certain limitations. The improved algorithm of the subject will improve the fusion method of this part, so that the improved neck part can fuse more information and improve the generalization ability and robustness of the model.
[0068] The backbone layer is the backbone network, which is one of the most important modules in the target detection algorithm. It directly determines the feature extraction capability of the input image. The backbone network of YOLOV5s uses CSPDarknet to extract feature information. The CSPNet structure is also added to the backbone network to enhance the extraction effect of feature information. The backbone structure includes Conv module, C3 module and SPPF module. Among them:
[0069] The Conv module includes a Conv2d, a BatchNorm2d and an activation function; the Conv module is used to extract features and organize feature maps; the paddingg of Conv2d in the Conv module is automatically calculated, and the reduction factor of the feature map is determined by modifying the stride; in the backbone, the stride of the Conv module is all 2, and the kernel is all 3; therefore, Conv will halve the width and height of the feature map each time, downsample the feature map, and extract the target features at the same time; the backbone and neck both use the Conv module to increase or decrease the dimension of the feature map, and there are many 1*1 convolutions; BatchNorm2d is a batch normalization layer, which normalizes each batch of data;
[0070] The C3 module includes three Conv modules and one Bottleneck module, hence the name C3; in the backbone, C3 is a more important module for extracting features. After the feature map enters C3, it will be divided into two paths. The left path passes through Conv and a Bottleneck, and the right path only passes through one Conv. Finally, the two paths are concat and then pass through another Conv; the three Conv modules in the C3 module are all 1*1 convolutions, which play a role in dimensionality reduction or dimensionality increase; Bottleneck uses residual connections in the backbone. There are two Convs in Bottleneck. The first Conv is a 1*1 convolution, which reduces the channel to half of the original, and the second is a 3*3 convolution, which doubles the number of channels; reducing the dimension first will help the convolution kernel to better understand the feature information, and increasing the dimension will help to extract more and more detailed features. Finally, use the residual structure to add the input and output to avoid the problem of gradient disappearance;
[0071] The SPPF module is spatial pyramid pooling. The author of yolov5 improved it to SPPF based on SPP. SPPF is faster when the output is the same. Spatial pyramid pooling can convert feature maps with non-fixed scales to a uniform scale. However, according to the source code, in yolov5, SPP and SPPF actually do the same pooling through padding, and the sizes of the feature maps before and after are equal. Therefore, the main role of the SPPF module in the YOLOV5s model is to fuse multi-scale features and concat the feature representations of the same feature map at different scales together.
[0072] Before talking about Neck, I would like to mention two concepts: graphic features and semantic features. As convolution continues, the neural network extracts more and more features, and the layers become deeper and deeper. In the shallow layer of the convolutional neural network, the features extracted by the network are relatively simple, such as color, contour, texture, shape, etc. These features are only reflected in the graphics, so they are called graphic features; and as the network continues to deepen, the neural network will continue to fuse these features, upgrade the dimension, and generate new features, such as how to combine color and texture, where is the sky and where is the land in the picture, and even contain some features that humans cannot understand, which are called semantic features. Graphic features are features from the shallow layer of the convolutional neural network, but they are just simple graphics and not semantically strong enough; semantic features are features from the deep layer of the convolutional neural network, with strong semantics, but some simple graphics are lost, and the Neck structure realizes the fusion of shallow graphic features and deep semantic features.
[0073] The structure of the Neck layer is a feature pyramid (FPN), which combines shallow graphic features with shallow semantic features. That is, the Neck layer of the YOLOv5 model obtains relatively shallow features from the backbone and concats them with deep semantic features. Figure 2 As can be seen in the figure, the neck interpolates the feature map by upsampling on the left side, making the scale of the feature map larger, so as to facilitate the fusion of the feature map from the backbone, and to perform upward fusion of features, so that the feature map continues to grow; the neck continues to perform downsampling on the right side, firstly to obtain feature maps of different scales, and secondly to make the shallow graphic features and deep semantic features better integrated, rather than just a simple concat. The role of the neck layer is to combine the shallow graphic features with the deep semantic features to obtain more complete features.
[0074] The head layer uses the Detect module. The network structure of the Detect module includes three 1*1 convolutions, corresponding to three detection feature layers. The role of 1*1 convolution is to increase or decrease the dimension. The number of channels of the 1*1 convolution kernel corresponds to the number of channels of the input feature map, and the number of output channels corresponds to the number of convolution kernels. Using 1*1 convolution does not change the size of the feature map, but changes the channels of the feature map.
[0075] First, let's analyze the three feature maps output by neck: the three feature maps are 80*80*256, 40*40*512, and 20*20*1024. Taking the 80*80*256 feature map as an example, this feature map can be understood as having 80*80 pixels, and each pixel has 256 information. These 256 information are highly concentrated feature information within the receptive field of this pixel. The 80*80 feature map has a relatively small receptive field, so the concentrated feature information is also small. The 20*20 feature map has a large receptive field, so it needs to condense more information. The smaller the size of the feature map, the larger the number of channels, and this design is reasonable enough. Specific implementation method four:
[0077] Different from the third specific implementation, in the vehicle recognition method under complex lighting conditions based on the improved YOLOV5s in the present implementation, in the step of using the trained YOLOv5s model to recognize the vehicle in the target image in step three, the YOLOV5s model uses the concept of grids, dividing the image into multiple grids, each grid is responsible for predicting one or more objects, and in simple terms, each grid can generate a prediction box. The reason why the grid can generate a prediction box is also very simple. There are several (usually three) prediction box templates in the grid memory, that is, "anchors". Each anchor has a preset width, height, coordinates, and confidence. The confidence indicates the probability of an object existing in the grid. During the training process, the anchor in whichever grid the midpoint of the real artificial annotation box falls on will "grow" or "shrink" crazily towards this real box, and the confidence is set to 1 because there is an object, indicating that the grid where the anchor is located has an object, and the confidence of other anchors without prediction boxes is 0. If the difference in width and height between the anchor and the real box, and the difference in coordinates are regarded as losses, and the binary cross entropy is regarded as the loss of confidence, then the object detection problem will be greatly simplified to a simple regression prediction and classification problem. Figure 3 shown.
[0078] When the YOLOV5s model predicts the confidence level in the prediction stage, it also predicts the width and height of the prediction box together with the category information. Although the network has a certain abstract concept of the shape and size of the target, it still cannot determine the exact position of the prediction box center in the case of parallel prediction. Simply put, for a certain size and shape feature, different grids in a certain area will think that its midpoint should be inside itself. This causes the same target to be predicted by multiple grids, and non-maximum suppression eliminates the boxes with low confidence and high overlap;
[0079] During the target recognition inference process, many detection boxes are generated. Many of these detection boxes detect the same target, but ultimately only one detection box is needed for each target. When performing NMS, first filter the preds according to the set classification threshold (usually 0.1). Suppose 6 prediction boxes are obtained after filtering. Then sort them according to the classification probability of the classifier. The probabilities of belonging to the target to be detected from smallest to largest are A < B < C < D < E < F, that is, there are 6 boxes;
[0080] (1) Starting from the rectangle box F with the highest probability, respectively judge whether the overlap degree IOU between A, B, C, D, E and the rectangle box F with the highest probability is greater than a set threshold (commonly set to 0.5, often set to 0.7 in target detection); if it is greater than the threshold, regard it as the object corresponding to the regression F prediction box; otherwise, regard it as the object of other regression;
[0081] (2) Suppose the overlap degrees of B and D with F exceed the threshold, then discard B and D, that is, suppress the boxes that exceed the threshold. The way of suppression is to set the score of the detection box to 0 and mark the first rectangle box F with the highest probability, which is the one retained (the four prediction boxes B, F, D regress the same object. For the same object, select the prediction box F with the largest score);
[0082] (3) From the remaining rectangle boxes A, C, E, select E with the highest probability, and then judge the overlap degree between the remaining rectangle boxes A, C and E. If the overlap degree is greater than the set threshold, then discard it; and mark the largest rectangle box E here as the second rectangle box retained (the reason for retention is the same as above);
[0083] (4) Repeat this process to find all the rectangle boxes that are retained. Specific implementation method five:
[0085] Different from the specific implementation method four, a vehicle recognition method under complex lighting conditions based on improved YOLOV5s in this implementation method, the steps of processing the public dataset BDD100K dataset further include the step of positive sample matching, specifically:
[0086] When calculating the loss, the imbalance between the number of positive samples and negative samples often makes the training effect unsatisfactory. In the YOLO algorithm, the anchors that are not responsible for predicting objects are regarded as negative samples, and the anchors that are responsible for predicting objects are regarded as positive samples, which results in a very large number of negative samples and a very small number of positive samples.
[0087] The YOLOv5s model is judged by calculating the extreme value of the width and height of the annotation box and the width and height of the anchor. As long as the extreme value is between 1 / 4 and 4, it means that the anchor grows into the annotation box. At this time, the anchor is set as a positive sample. Multiple anchors are assigned to a annotation box as positive samples, which increases the number of positive samples. The process of increasing positive samples is actually increasing labels, which can be understood as generating many annotation boxes for the same target. However, this will lead to a phenomenon: if there are more annotation boxes for the same target, the prediction results for this annotation box will also increase. However, compared with the case where no positive samples are added, the output label difference will not be too large.
[0088] In the category loss function, YOLOv5s uses the binary cross entropy loss function instead of the softmax loss function. This is because the softmax loss function is mutually exclusive for each category. However, YOLO takes into account the situation where the categories are not mutually exclusive. For example, a category can be a car, but it can also be a car or a truck. If softmax is used, a car cannot be a car, but a binary cross entropy can be both a car and a truck.
[0089] YOLOv5s adds different weights to the loss of each feature layer when calculating the loss of each feature layer. The weights of the three different feature layers, small, medium, and large, are 4.0, 1.0, and 0.4 respectively. The weight of the feature layer for detecting small targets is relatively large because small targets are more difficult to predict, so their loss is increased. The weight of the feature layer may have different values for different data sets and can be adjusted according to needs. When YOLOv5s calculates the loss of the predicted box, it does not take the square difference between x, y, w, h and the label value as the loss. Instead, it calculates the 1-CIoU between the predicted box and the annotated box as the loss. The larger the CIoU, the smaller the loss. When YOLOv5s calculates the confidence loss, the confidence label value is the CIoU of the anchor in which it is located. The larger the CIoU, the greater the probability that there is an object in this box.
[0090] The relevant diagrams of the experimental simulation process using the method of the present invention are as follows: Figure 4-20 .
[0091] Figure 4 is the form of confusion matrix involved in the method of the present invention;
[0092] Figure 5 is a confidence curve involved in the method of the present invention;
[0093] Figure 6 Schematic diagram of labels involved in the method of the present invention;
[0094] Figure 7A diagram of a visualization tool or indicator for evaluating the performance of a target detection model involved in the method of the present invention;
[0095] Figure 8 A curve showing the variation of the precision (Precision) with the confidence (Confidence) involved in the method of the present invention;
[0096] Fig. 9 It is the performance evaluation of the binary classification model involved in the method of the present invention (Precision-Recall Curve);
[0097] Fig.10 The recall_curve curve involved in the method of the present invention is a precision-recall curve;
[0098] Fig.11 It is a graphical representation of the results of the calculations involved in the method of the present invention;
[0099] Fig.12 A training batch of data involved in the method of the present invention;
[0100] Fig.13 A training batch of data involved in the method of the present invention;
[0101] Fig.14 A training batch of data involved in the method of the present invention;
[0102] Fig.15 The labels of the first batch of the validation set involved in the method of the present invention;
[0103] Fig.16 The prediction result of the batch data (val_batch) for verifying the performance of the model involved in the method of the present invention;
[0104] Fig.17 The label portion of the data set for verifying the performance of the model involved in the method of the present invention;
[0105] Fig.18 The prediction results of the first batch of data in the validation set involved in the method of the present invention;
[0106] Fig.19 The true labels of the second batch in the validation data set involved in the method of the present invention;
[0107] Fig. 20 It is the prediction result of the second batch in the validation set involved in the method of the present invention.
[0108] The embodiments of the present invention disclose preferred embodiments, but are not limited thereto. A person skilled in the art can easily understand the spirit of the present invention based on the above embodiments and make different extensions and changes. However, as long as they do not deviate from the spirit of the present invention, they are all within the protection scope of the present invention.
Claims
1. A vehicle recognition method under complex lighting conditions based on improved YOLOV5s, characterized by: The method is implemented by the following steps: Step 1: Build the network structure of the YOLOv5s model based on the PyTorch framework; Step 2: Process the public dataset BDD100K and train the built YOLOv5s model with the processed BDD100K dataset; Step 3: Use the trained YOLOv5s model to identify vehicles in the target image.
2. According to claim 1, a vehicle recognition method under complex lighting conditions based on improved YOLOV5s is characterized in that: The processing of the public data set BDD100K data set described in step 2 refers to removing the data with a lot of noise in the BDD100K data set, that is, pictures with no identification targets at all, blurred pictures or non-existent picture data; then, adjusting the data set format and annotating the pictures through the annotation tool to generate the txt format required by the YOLOv5s model.
3. A vehicle recognition method under complex lighting conditions based on improved YOLOV5s according to claim 1 or 2, characterized in that: The steps for training the YOLOv5s model described in step 2 are as follows: First, build the model's operating environment, including: preparing weight files; Then, based on the YOLOV5s model, the module or network structure is improved; the YOLOV5s model network framework is designed to include the backbone layer, neck layer, and head layer; The backbone layer is the backbone network, which uses CSPDarknet to extract feature information. The CSPNet structure is also added to the backbone network. The backbone structure includes Conv module, C3 module and SPPF module. Among them: The Conv module includes a Conv2d, a BatchNorm2d and an activation function; the Conv module is used to extract features and organize feature maps; the paddingg of Conv2d in the Conv module is automatically calculated, and the reduction factor of the feature map is determined by modifying the stride; in the backbone, the stride of the Conv module is all 2, and the kernel is all 3; therefore, Conv will halve the width and height of the feature map each time, downsample the feature map, and extract the target features at the same time; the backbone and neck both use the Conv module to increase or decrease the dimension of the feature map, and there are many 1*1 convolutions; BatchNorm2d is a batch normalization layer, which normalizes each batch of data; The C3 module includes three Conv modules and one Bottleneck module. After the feature map enters C3, it will be divided into two paths. The left path passes through Conv and a Bottleneck, and the right path passes through only one Conv. Finally, the two paths are concat and then pass through another Conv. The three Conv modules in the C3 module are all 1*1 convolutions. Bottleneck uses residual connections in the backbone. There are two Convs in Bottleneck. The first Conv is a 1*1 convolution, which reduces the channel to half of the original, and the second is a 3*3 convolution, which doubles the number of channels. Finally, the residual structure is used to add the input and output. The SPPF module is a spatial pyramid pooling module. The SPPF module integrates multi-scale features in the YOLOV5s model and concats the feature representations of different scales of the same feature map together. The structure of the Neck layer is a feature pyramid, which combines shallow graphic features with shallow semantic features. That is, the Neck layer of the YOLOv5 model obtains relatively shallow features from the backbone and concats them with deep semantic features to obtain more complete features. The head layer uses the Detect module. The network structure of the Detect module includes three 1*1 convolutions, corresponding to three detection feature layers. The role of 1*1 convolution is to increase or decrease the dimension. The number of channels of the 1*1 convolution kernel corresponds to the number of channels of the input feature map, and the number of output channels corresponds to the number of convolution kernels. Using 1*1 convolution does not change the size of the feature map, but changes the channels of the feature map.
4. According to claim 3, a vehicle recognition method under complex lighting conditions based on improved YOLOV5s is characterized in that: In the step of using the trained YOLOv5s model to identify the vehicle in the target image as described in step 3, When the YOLOV5s model predicts the confidence in the prediction stage, it eliminates the boxes with low confidence and high overlap through non-maximum suppression; First, pred is filtered according to the set classification threshold to obtain the prediction box, and then it is sorted according to the classification probability of the classifier category, from small to large, the probability of belonging to the target to be detected; (1) Starting from the maximum probability rectangular box, determine whether the overlap IOU with the maximum probability rectangular box is greater than a certain set threshold; if it is greater than the threshold, it is regarded as the object corresponding to the regression F prediction box; otherwise, it is regarded as other objects of regression; (2) Suppress the boxes that exceed the threshold. The suppression method is to set the score of the detection box to 0 and mark the first rectangular box with the maximum probability as the retained one; (3) Select the one with the highest probability from the remaining rectangles, and then determine the overlap between the remaining rectangles. If the overlap is greater than the threshold, discard it. Mark the largest rectangle as the second rectangle retained. (4) Repeat this process to find all the retained rectangular boxes.
5. According to claim 4, a vehicle recognition method under complex lighting conditions based on improved YOLOV5s is characterized in that: The step of processing the public data set BDD100K data set also includes the step of positive sample matching, specifically: The YOLOv5s model is judged by calculating the extreme values of the width and height of the annotation box and the width and height of the anchor. As long as the extreme value is between 1 / 4 and 4, it means that the anchor grows into the annotation box. At this time, the anchor is set as a positive sample, and a annotation box is assigned multiple anchors as positive samples, which increases the number of positive samples. By increasing the labels in the process of increasing positive samples, it can be understood that many annotation boxes are generated for the same target.
Citation Information
Patent Citations
Vehicle detection and identification method based on YOLOv5 improvement
CN114723992A
Vehicle-mounted target detection method based on improved YOLOv5
CN115731533A
Vehicle target identification method based on improved YOLO multi-scale detection
CN116246059A
Vehicle detection method in haze weather based on improved YOLOv5
CN116503709A
Night vehicle detection method and system based on improved YOLOv5 convolutional neural network
CN116524319A
