A traffic sign recognition method based on YOLO v4-tiny

By introducing a combined module of channel and spatial attention mechanisms into the YOLO v4-tiny network, the accuracy of traffic sign recognition and the generalization ability of the model are improved, and the problem of low recognition accuracy in complex traffic scenes in the existing technology is solved. Suitable for edge devices, ensuring the safety of autonomous driving technology.

CN112464910BActive Publication Date: 2024-09-27HUAIAN KUNBO INFORMATION TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202011510258.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-18
Publication Date
2024-09-27
Estimated Expiration
2040-12-18

AI Technical Summary

Technical Problem

Existing traffic sign recognition based on the YOLO series of algorithms has low recognition accuracy in complex traffic scenes that contain many targets and small targets. It is difficult to achieve high accuracy on edge devices that maintain real-time performance and have limited computing resources.

Method used

A combined channel attention mechanism and spatial attention mechanism (CBAM) is introduced into the YOLO v4-tiny network to improve the model's detection accuracy of traffic signs, enhance attention to areas of interest, and ignore irrelevant information.

Benefits of technology

It improves the accuracy of traffic sign detection, maintains the speed of target detection, and is suitable for use on edge devices without significantly increasing the number of model parameters, providing stronger generalization capabilities and recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112464910B
    Figure CN112464910B
Patent Text Reader

Abstract

The invention discloses a traffic sign recognition method based on YOLO v4‑tiny. First, a traffic sign data set is collected. Then, data enhancement operation is performed on the initial sample traffic sign data set, and the data is divided into a training set, a validation set, and a test set. Six a priori frame sizes of different sizes are clustered with intersection-over-union ratio as an indicator for the real target frame in the training set. A channel attention mechanism and a spatial attention mechanism are embedded in the YOLO v4‑tiny framework to obtain a YOLO v4‑tiny‑CBAM network model. The network model is trained by the training set and verified by the validation set. Finally, the performance of the network model is tested by the test set. The method of the invention introduces the channel attention and spatial attention mechanisms in the YOLO v4‑tiny lightweight network, and has stronger generalization ability and higher recognition accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to an improved traffic sign recognition method based on a YOLO v4-tiny lightweight network. Background Art

[0002] With the development of AI intelligence, many breakthroughs have been made in the field of autonomous driving technology. For example, intelligent vision systems have achieved a qualitative leap in recognition effects in just a few years. Technological breakthroughs have enabled more and more prototype smart cars to step out of the laboratory and be tested in real road environments, gradually moving towards practical applications. Traffic signs are used to convey instructions to vehicles and pedestrians, and are a key factor in ensuring the smoothness and safety of traffic routes. Therefore, accurate and rapid recognition of traffic signs is a key link in achieving the safety of autonomous driving. For tasks such as traffic sign recognition, more deployment is required in edge and mobile devices, which is a challenge for the computing power and memory of edge devices, so traffic sign detection algorithms that take into account both accuracy and real-time performance have become the first choice.

[0003] At present, the development of object detection algorithms based on convolutional neural networks can be roughly divided into two directions: two-stage detectors based on candidate regions and one-stage detectors based on regression. Two-stage detectors are generally characterized by slow speed and high precision, while one-stage detectors are generally characterized by fast speed and low precision. Although the two-stage object detection method based on candidate regions, the R-CNN (Region-based Convolutional Neural Network) series (including R-CNN, Fast R-CNN and Faster R-CNN) has achieved very good detection results, due to the relatively high precision and speed required for traffic sign recognition, this series of algorithms is still far from real-time effects in terms of speed. Unlike the R-CNN series of algorithms, the one-stage algorithms represented by SSD (Single Shot MultiBox Detector) and YOLO (You Only Look Once: Unified, Real-Time Object Detection) have relatively few network model parameters, and are superior in real-time performance, but are a bit unsatisfactory in accuracy. With the update of the YOLO series, the fourth-generation algorithm YOLO v4 has been able to achieve higher recognition accuracy while maintaining recognition speed. In particular, the lightweight network YOLO v4-tiny series model has fewer parameters and is more suitable for deployment on edge devices such as vehicle systems. However, its recognition accuracy for traffic scenes with many targets and small traffic signs needs to be improved. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a traffic sign recognition method based on YOLO v4-tiny.

[0005] The present invention improves the lightweight framework YOLOv4-tiny and introduces a combined module of channel attention mechanism and spatial attention mechanism (CBAM), so that the network model YOLO v4-tiny-CBAM can learn to focus on places of interest, ignore irrelevant information and focus on key information, thereby improving the accuracy of the model in detecting traffic signs while ensuring the target detection speed and not significantly increasing the number of model parameters.

[0006] In order to achieve the above invention purpose, the technical solution adopted is:

[0007] A traffic sign recognition method based on YOLO v4-tiny includes the following steps:

[0008] S1. Collect traffic sign dataset.

[0009] Traffic sign images of fixed types of traffic signs are collected in different weather conditions, different scenes, and different times to create an initial sample traffic sign dataset.

[0010] Further, step S1 comprises:

[0011] S11. Using a driving recorder or a high-definition camera installed on a vehicle, a picture of a traffic sign in a real road scene is captured in real time.

[0012] S12. Screening the image sequence containing traffic signs obtained in step S11, selecting images under different road sections, different weather conditions, different lighting conditions, and different traffic time periods, averaging the number of screened traffic sign data images in terms of categories, and eliminating images in which traffic signs are obscured.

[0013] S13. Rename the selected traffic sign images according to the serial number to form a new image ID, then annotate the traffic sign images, frame the target area where each traffic sign is located, that is, the position of the real target frame, and then use the annotated traffic sign images as the initial sample data set.

[0014] S2. Performing data enhancement operations on the initial sample traffic sign data set, wherein the data enhancement operations include random cropping, distortion, amplification, mirroring, and deformation.

[0015] S3, divide the data set obtained after data augmentation in S2 into training set, validation set, and test set.

[0016] S4. Cluster six different sizes of prior box sizes based on the intersection-over-union (IOU) ratio for the real target boxes in the training set, and use the obtained six prior box sizes as initial parameters.

[0017] S5. Embed the channel attention mechanism and spatial attention mechanism in the YOLO v4-tiny framework to obtain the YOLOv4-tiny-CBAM network model.

[0018] The specific operations of step S5 are as follows:

[0019] S51. Combine the channel attention mechanism and the spatial attention mechanism into a module CBAM, as follows:

[0020] Through the channel attention mechanism, the input feature map is sent to a global pooling layer, a fully connected layer (for dimensionality reduction), a ReLU activation layer, and then a fully connected layer (for dimension restoration). Then, it passes through the Sigmoid activation function, and finally the result is multiplied with the original input feature map to obtain the final output of the channel attention mechanism.

[0021] The spatial attention mechanism first uses the output of the channel attention mechanism as the input feature for global pooling and maximum pooling respectively, and then concatenates the results of global pooling and maximum pooling to obtain a new feature layer. The new feature layer is convolved and then multiplied with the output of the channel attention after a Sigmoid activation function to obtain a feature map after the attention mechanism.

[0022] S52. In the existing YOLO v4-tiny network structure, the backbone network CSPDarknet53-tiny includes three CSPResblocks with residual edges, and the CBAM module is inserted behind these three CSPResblock modules.

[0023] S53, insert the CBAM module sequentially after the two output feature layers of the backbone network, after the convolution layer before upsampling of the feature pyramid part, and after the splicing operation.

[0024] S6, training the YOLO v4-tiny-CBAM network model through the training set and verifying the model through the verification set during the training process. Specifically, step S6 includes:

[0025] S61 prepares three folders according to the VOOC2007 format: the label file Annotations, the picture folder JPEGImages and the data set division folder ImageSets. In the subfolder Main of ImageSets, the divided training set, validation set, and test set image ID names are stored row by row (the images are named with serial numbers).

[0026] S62 configures the network environment and selects the Ubuntu system and PyTorch framework for training.

[0027] S63 sets the network model parameters. According to the size of the computer memory and video memory, it sets the size of the input image of the YOLO v4-tiny-CBAM network model, the sizes of the six prior boxes, the number of recognized categories and the names of the various categories annotated, the pre-trained weight file, the number of iterations, the initial learning rate, and the learning rate adjustment strategy.

[0028] S64 trains until the network model converges. During the training process, the validation set is used for verification, and the weight files obtained after each epoch training are saved.

[0029] S7. Test the performance of the YOLO v4-tiny-CBAM network model using the test set;

[0030] Specifically, step S7 includes:

[0031] S71. Load the trained network model weight file obtained in step S6, input the test set into the trained YOLOv4-tiny-CBAM network model, extract features by adding the CBAM backbone network, and fuse the deep and shallow features of the feature pyramid network (FPN) layer to obtain all prediction results belonging to the two feature layers of the network.

[0032] S72: By judging the confidence threshold, the bounding box coordinates, confidence and category probability of all prediction boxes that may contain traffic signs are obtained. Then, redundant detection boxes are removed through non-maximum suppression processing to generate the final detection result.

[0033] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0034] Aiming at the problem that the existing target detection methods have low recognition accuracy in complex traffic scenes with many small targets on mobile terminal devices, the channel attention and spatial attention mechanisms are introduced into the YOLO v4-tiny lightweight network, and the YOLO v4-tiny-CBAM model with stronger generalization ability and higher recognition accuracy is trained. The whole model proposed by the present invention has a small number of parameters and is suitable for embedding into terminal devices. It can be applied in the field of intelligent transportation with good development prospects, and provides technical guarantee for the safety of future autonomous driving technology.

[0035] Invention drawings

[0036] Figure 1 is a flow chart of the method of the present invention;

[0037] Figure 2This is the structure diagram of the channel attention module in the CBAM module;

[0038] Figure 3 This is the structure diagram of the spatial attention module in the CBAM module;

[0039] Figure 4 This is the improved YOLO v4-tiny-CBAM model;

[0040] Figure 5 These are the 6 anchor size results obtained after clustering the collected traffic sign dataset;

[0041] Figure 6 This is the recognition effect diagram of a single traffic sign by the improved YOLO v4-tiny network model;

[0042] Figure 7 This is the recognition effect diagram of multiple traffic signs by the improved YOLO v4-tiny network model;

[0043] Figure 8 The detection accuracy of the mandatory category signs in the dataset by the YOLO v4-tiny model;

[0044] Fig. 9 The detection accuracy of the improved YOLO v4-tiny-CBAM model for the mandatory category signs in the dataset. DETAILED DESCRIPTION

[0045] The specific implementation details of the invention patent are further elaborated below. In order to make the technology involved in the invention easier to understand and implement, the subsequent content will be explained in conjunction with the drawings.

[0046] First combine Figure 1 The specific implementation steps of the YOLOv4-tiny-CBAM model proposed in the present invention are as follows:

[0047] S1. Under different weather conditions, including sunny, rainy, snowy and foggy days, collect images of different scenes containing traffic signs on urban roads, and collect pictures of fixed types of traffic signs under different conditions such as daytime and nighttime lighting to ensure the adequacy and practicality of the data. Then, the collected pictures are used to create the initial sample data set.

[0048] The specific method of step S1 is as follows:

[0049] S11. Using a driving recorder or a high-definition camera installed on a vehicle, a traffic sign in a real road scene is photographed in real time to obtain a picture containing the traffic sign.

[0050] S12. Filter the image sequence containing traffic signs obtained in step S11, and select images under different road sections, different weather conditions, different lighting conditions, and different traffic time periods. Note that the number of traffic sign images filtered out should be averaged across categories, and images with blocked traffic signs should be eliminated.

[0051] S13. Rename the selected traffic sign images according to the serial number to obtain a new image ID, and then use the labeling software LabelImg to label each traffic sign image, frame the target area where each traffic sign is located, that is, the position of the real target frame, and generate an XML label file in VOC format. The label file name corresponds to the image ID, and the labeled traffic sign image is used as the initial sample data set.

[0052] S2. Performing data enhancement operations on the initial sample traffic sign data set obtained in step S1, wherein the data enhancement operations include random cropping, distortion, amplification, mirroring and deformation.

[0053] S3. Divide the data set after data enhancement in step S2 into a training set, a validation set, and a test set in a ratio of 7:1:2, and generate txt files with the image IDs of the training set, validation set, and test set, respectively, named train_txt, val_txt, and test_txt.

[0054] S4. Cluster 6 different sizes of prior box sizes based on the IOU of the real target box in the training set. In order to avoid the scale sensitivity between large and small targets, the Euclidean distance used in the kmeans algorithm is improved, and IOU (intersection-over-union ratio of two boxes) is used as the reference indicator of the clustering algorithm. The new objective function S is constructed as follows:

[0055]

[0056] Among them, k is the number of prior boxes, box is the coordinates of the target box predicted by the model output, and truth is the coordinates of the real target box. According to this objective function, k=6 prior box sizes required by the model are clustered.

[0057] S5, embedding the channel attention mechanism and the spatial attention mechanism in the YOLOv4-tiny framework. Specifically, step S5 includes:

[0058] S51, construct a channel attention module. Figure 2As shown in the figure, the input feature map is sent to a global pooling layer to be compressed into a feature of 1*1 size, and then reduced to half of the original number of channels through a fully connected layer, and then ReLU activation is performed. After that, it is sent to a fully connected layer to restore the original dimension, and then activated by the Sigmoid function. Finally, the result is multiplied by the original input feature map channel by channel to complete the recalibration of the original features in the channel dimension.

[0059] S52, construct a spatial attention module. Figure 3 As shown in the figure, the output layer of the S51 channel attention is used as the input feature layer for global pooling and maximum pooling respectively, and then the two results are concatenated to obtain a new feature layer, and the feature layer is convolved with kernel_size=7, and then multiplied with the output layer of the channel attention after the Sigmoid activation function, and weighted to the previous feature to complete the recalibration of the original feature in the spatial dimension, that is, the feature map containing the original position weight after the attention mechanism is obtained.

[0060] S53. Connect the channel attention mechanism and the spatial attention mechanism in sequence into a module CBAM.

[0061] S54, press the CBAM module Figure 4 The main feature extraction part of the YOLOv4-tiny network is shown in the figure. The YOLOv4-tiny main network CSPDarknet53-tiny includes three CSPResblock modules with residual edges. The output feature map sizes of these three CSPResblocks are [76,76,128], [38,38,256], and [19,19,512], respectively. Connect the CBAM module constructed in step S53 to the output of these three CSPResblocks.

[0062] S55, press the CBAM module Figure 4 The feature fusion part of the YOLOv4-tiny network is shown in the figure. First, the attention mechanism CBAM module is added after the two output feature layers [38,38,256] and [19,19,512] of the backbone network, and then the CBAM module is introduced after the convolutional layer before upsampling and the fused convolutional layer obtained after the Concate operation corresponding to the feature fusion part of the feature pyramid.

[0063] S6, training the YOLOv4-tiny-CBAM network model built in step S5 on the training set and observing the training process with the validation set. Specifically, step S6 includes:

[0064] S61 prepares three folders according to the VOOC2007 format: label file Annotations, image file JPEGImages and dataset partition ImageSets folder, and its subfolder Main stores the partitioned training set, validation set, and test set image IDs (stored by row), namely train_txt, val_txt, and test_txt. Then, based on train_txt, val_txt, and test_txt, the summary dataset files voc_train_txt, voc_val_txt, and voc_test_txt are generated, which store the absolute path of the image and the label location and category by row.

[0065] S62 configures the network environment and selects the Ubuntu system and PyTorch framework for training.

[0066] S63 sets the network model parameters. According to the size of the computer memory and video memory, it sets the size of the YOLOv4-tiny-CBAM network input image, the size of the six prior boxes obtained by clustering in step S4, the number of recognized categories and the annotated class names classes_txt, the pre-trained weight file, batch_size, the number of iterations, the initial learning rate, and the learning rate adjustment strategy. The user needs to use a graphics card that supports cuda acceleration.

[0067] S64 loads the pre-trained weights and trains until the network model converges. During the training process, the validation set is used for verification. Gradients are not returned during verification. After the model converges, the weight files obtained after each epoch training are saved.

[0068] S7, test model performance. The performance of the YOLOv4-tiny-CBAM network model trained in step S64 is tested using the divided test set. Specifically, step S7 includes:

[0069] S71. Load the trained network model weight file, send the test set to the trained YOLOv4-tiny-CBAM network model, extract features through the backbone network CSPDarknet53-tiny-CBAM with CBAM added, and output two feature layer sizes [38,38,256] and [19,19,512]. Then, through the deep and shallow feature fusion of the feature pyramid fusion part, the adjustment results of all anchors in the network containing two feature layers, that is, all prediction results, are obtained.

[0070] Figure 5 These are the 6 anchor size results obtained after clustering the collected traffic sign dataset;

[0071] S72, set a confidence threshold, obtain the bounding box coordinates, confidence and category probability of all prediction boxes that may contain traffic signs, and then traverse each class through non-maximum suppression to remove redundant detection boxes and generate the final detection result.

[0072] Figure 6 This is the recognition effect diagram of a single traffic sign by the improved YOLO v4-tiny network model;

[0073] Figure 7 This is the recognition effect diagram of multiple traffic signs by the improved YOLO v4-tiny network model;

[0074] S8. Based on the real box position of the test set and the prediction results obtained by the model, calculate the mean average precision (mAP), accuracy (Precision), and recall (Recall) of the model, and conduct a systematic evaluation of the model. Figure 8 .、 Fig. 9 As shown in the figure, the comparison results of the recognition effect with YOLOv4-tiny show that the present invention can improve the accuracy of traffic sign recognition.

Claims

1. A traffic sign recognition method based on YOLO v4-tiny, characterized in that: The steps include: S1, collect traffic sign dataset; Collect traffic sign images of fixed types of traffic signs in different weather conditions, different scenes, and different times to create an initial sample traffic sign dataset; S2. Performing data enhancement operations on the initial sample traffic sign dataset, wherein the data enhancement operations include random cropping, distortion, amplification, mirroring, and deformation; S3, divide the data set obtained after data augmentation in S2 into a training set, a validation set, and a test set; S4. Cluster 6 prior box sizes of different sizes based on the intersection-over-union (IOU) ratio for the real target box in the training set, and use the obtained 6 prior box sizes as initial parameters; S5. Embed the channel attention mechanism and spatial attention mechanism in the YOLO v4-tiny framework to obtain the YOLO v4-tiny-CBAM network model; S6. Train the YOLO v4-tiny-CBAM network model using the training set and verify the model using the validation set during the training process; S7. Test the performance of the YOLO v4-tiny-CBAM network model using the test set; The specific operations of step S1 are as follows: S11, taking pictures of traffic signs in real road scenes in real time using a driving recorder or a high-definition camera installed on the vehicle; S12, screening the image sequence containing traffic signs obtained in step S11, selecting images under different road sections, different weather conditions, different lighting conditions, and different traffic time periods, averaging the number of screened traffic sign data images in terms of categories, and eliminating images where traffic signs are obscured; S13, renaming the selected traffic sign images according to the serial number to form a new image ID, then marking the traffic sign images, framing the target area where each traffic sign is located, that is, the position of the real target frame, and then using the marked traffic sign images as the initial sample data set; The specific operations of step S5 are as follows: S51. Combine the channel attention mechanism and the spatial attention mechanism into a module CBAM, as follows: Through the channel attention mechanism, the input feature map is sequentially sent to a global pooling layer, a fully connected layer, a ReLU activation layer, and then a fully connected layer, and then passed through the Sigmoid activation function. Finally, the result is multiplied with the original input feature map to obtain the final output of the channel attention mechanism; The spatial attention mechanism first uses the output of the channel attention mechanism as the input feature for global pooling and maximum pooling, and then concatenates the results of global pooling and maximum pooling to obtain a new feature layer. The new feature layer is convolved and then multiplied with the output of the channel attention after the Sigmoid activation function to obtain the feature map after the attention mechanism. S52. In the existing YOLO v4-tiny network structure, the backbone network CSPDarknet53-tiny includes three CSPResblocks with residual edges, and the CBAM module is inserted behind these three CSPResblock modules; S53, inserting the CBAM module sequentially after the two output feature layers of the backbone network, after the convolution layer before upsampling of the feature pyramid part, and after the splicing operation; The specific operations of step S6 are as follows: S61 prepares three folders according to the VOOC2007 format: the label file Annotations, the image folder JPEGImages and the dataset partition folder ImageSets. In the subfolder Main of ImageSets, the ID names of the divided training set, validation set and test set images are stored row by row. S62 configures the network environment, selects the Ubuntu system and the PyTorch framework for training; S63 sets the network model parameters, and sets the size of the input image of the YOLO v4-tiny-CBAM network model, the sizes of the six priori boxes, the number of recognized categories and the names of the various categories annotated, the pre-trained weight file, the number of iterations, the initial learning rate, and the learning rate adjustment strategy according to the size of the computer memory and the video memory; S64 trains until the network model converges, verifies with the validation set during the training process, and saves the weight file obtained after each epoch training; The specific operations of step S7 are as follows: S71, loading the trained network model weight file obtained in step S6, inputting the test set into the trained YOLO v4-tiny-CBAM network model, extracting features by adding the CBAM backbone network, and fusing the deep and shallow features of the feature pyramid network FPN layer, to obtain all prediction results belonging to the two feature layers of the network; S72. By judging the confidence threshold, the bounding box coordinates, confidence and category probability of all prediction boxes that may contain traffic signs are obtained; then the redundant detection boxes are removed through non-maximum suppression processing to generate the final detection result.

Citation Information

Patent Citations

  • Relevant motion detection in video

    CA3016953A1

  • Novel deep convolution neural network moving vehicle detection method

    CN106407931A

  • Target identification method based on YOLOv3 lightweight framework improvement

    CN110929577A

  • Aerial image multi-scale target detection method based on spatial pyramid attention driving

    CN111401201A

  • Lithium battery defect detection method based on Tiny-yoxov3 network embedded with grouping attention module

    CN111612751A