Traffic sign identification method and system

By adding the attention mechanism and Transformer network to the YOLOv5 network, combined with Mosaic data enhancement and CBAM attention module, the problem of traditional traffic sign recognition methods affected by light color difference is solved, and the recognition accuracy and adaptability are significantly improved.

CN118629007APending Publication Date: 2024-09-10NANTONG INST OF TECH
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410757934.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The traditional traffic sign recognition method is based on the color characteristics of the image, which is easily affected by factors such as light color difference, resulting in large detection errors.

Method used

Using the improved YOLOv5 network, by adding attention mechanism and Transformer network, combined with Mosaic data enhancement and CBAM attention module, the adaptability and generalization ability of the model are improved, and the accuracy of traffic sign recognition is improved.

Benefits of technology

It significantly improves the detection accuracy of traffic sign recognition, improves the adaptability and generalization ability of the model, and enhances the detection effect of small targets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118629007A
    Figure CN118629007A
Patent Text Reader

Abstract

The invention relates to a traffic sign recognition method and system, and the method comprises the steps: obtaining a traffic sign picture; performing data enhancement on the traffic sign picture to form an enhanced traffic sign picture; marking the enhanced traffic sign picture to form a training sample; using the training sample to train an improved YOLOv5 network to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network in which an attention mechanism is added; and detecting a target traffic sign picture by using the traffic sign recognition model to obtain a recognition result. According to the method, the attention mechanism is added in the YOLOv5 network, so that the YOLOv5 network can be helped to better capture important feature information in the image, the YOLOv5 network has better adaptability and generalization ability, and the detection precision of the model is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and in particular to a traffic sign recognition method and system. Background Art

[0002] With the rapid development of science and technology, assisted driving technology continues to improve. As an important part of assisted driving technology, the traffic sign recognition system can identify the traffic sign information ahead and inform the driver, reminding the driver of the current road conditions so that the driver can make correct judgments on the information obtained, which can reduce a large number of traffic accidents caused by ignoring traffic signs. Therefore, traffic sign recognition has become the core research direction in the field of assisted driving.

[0003] Traditional visual recognition relies on the extraction of information such as appearance, color, and edge features. For example, Zhang Jing (Circular Traffic Sign Detection Method Based on Integrated Color and Shape [J]. Computer Engineering and Applications, 2011, 47(2): 233-236, 241) proposed a circular traffic sign detection algorithm based on color segmentation and curve fitting. First, the color of the traffic sign is divided, then the circular contour is used as the research object, and finally the nonlinear least squares technology is used to accurately identify the circular traffic sign on the image. Chu Xiumin (Binarization of Highway Scene Images and Traffic Sign Location Detection Method [J]. China Journal of Highway and Transport, 2006, 19(6): 102-106) proposed to use the brightness component in the HSV color model and the optimal threshold method to binarize the sign area in the scene image, and finally achieve the positioning effect. First, the RGB value of the image is converted to HSV, and the color saturation is binarized and segmented using a threshold-based method. Then, the shape feature is used to remove the non-target area, and the sign is accurately located by searching for the mutation point of the directional projection value sequence of the scene binary image. However, since the above method is implemented based on the color features of the image, it is easily affected by factors such as light color difference during detection, resulting in large errors. Summary of the invention

[0004] To solve the above problems, an object of the embodiments of the present invention is to provide a traffic sign recognition method and system.

[0005] A traffic sign recognition method, comprising:

[0006] Step 1: Get traffic sign images;

[0007] Step 2: performing data enhancement on the traffic sign image to form an enhanced traffic sign image;

[0008] Step 3: Annotate the enhanced traffic sign image to form a training sample;

[0009] Step 4: Using the training samples to train the improved YOLOv5 network to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added;

[0010] Step 5: Use the traffic sign recognition model to detect the target traffic sign image to obtain a recognition result.

[0011] Preferably, the step 2: performing data enhancement on the traffic sign image to form an enhanced traffic sign image comprises:

[0012] The Mosaic algorithm is used to perform data enhancement on the traffic sign image to form an enhanced traffic sign image.

[0013] Preferably, in step 4, the YOLOv5 network includes an input layer, a feature extraction backbone network, a feature enhancement fusion network and a Head layer; a CBAM attention module is added after the CSP2_n module of the feature extraction backbone network, and the encoder block module of the Transformer network is applied to the YOLOv5 network to form an improved YOLOv5 network.

[0014] Preferably, in step 4, the loss function of the improved YOLOv5 network is:

[0015]

[0016] Among them, L conf ij represents the target confidence loss, L cls ij represents the target classification loss, L reg ij represents the target coordinate frame regression loss, λ1 represents the weight of the target confidence loss, λ2 represents the weight of the target classification loss, and λ3 represents the weight of the target coordinate frame regression loss.

[0017] Preferably, the target coordinate frame regression loss is:

[0018]

[0019] Among them, IoU represents the intersection-over-union loss, Δ represents the distance loss, Ω represents the shape loss, σ represents the center distance between the real box and the predicted box, and c h is the vertical distance between the center point of the real box and the predicted box, ω h is the height h of the real frame gt The absolute value of the difference between the height h of the predicted box and max(h gt ,h) ratio,ω w is the width w of the real frame gThe absolute value of the difference between the width w of the prediction box and max(w gt ,w) ratio, ρ x is the ratio of the horizontal distance of the center point to the width of the minimum bounding rectangle of the real box and the predicted box, ρ y is the ratio of the vertical distance of the center point to the height of the minimum bounding rectangle of the real box and the predicted box, and θ is the cost of the shape loss.

[0020] The present invention also provides a traffic sign recognition system, comprising:

[0021] Image acquisition module, used to acquire traffic sign images;

[0022] A data enhancement module, used for performing data enhancement on the traffic sign image to form an enhanced traffic sign image;

[0023] An image annotation module, used to annotate the enhanced traffic sign image to form a training sample;

[0024] A training module, used to train the improved YOLOv5 network using the training samples to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added;

[0025] The image detection module is used to detect the target traffic sign image using the traffic sign recognition model to obtain a recognition result.

[0026] The present invention also provides an electronic device, comprising a bus, a transceiver, a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the transceiver, the memory and the processor are connected via the bus, and wherein the computer program, when executed by the processor, implements the steps in the above-mentioned traffic sign recognition method.

[0027] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps in the above-mentioned traffic sign recognition method when executed by a processor.

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

[0029] The present invention relates to a traffic sign recognition method. Compared with the prior art, the present invention can help the YOLOv5 network better capture important feature information in an image by adding an attention mechanism in the YOLOv5 network, so that the YOLOv5 network has better adaptability and generalization ability, and greatly improves the detection accuracy of the model.

[0030] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0032] Figure 1 A flow chart of a traffic sign recognition method provided by the present invention;

[0033] Figure 2 A schematic diagram of the YOLOv5 network structure provided by the present invention;

[0034] Figure 3 A schematic diagram of the CBL structure provided by the present invention;

[0035] Figure 4 A schematic diagram of the Focus structure provided by the present invention;

[0036] Figure 5 A schematic diagram of the CSP structure provided by the present invention;

[0037] Figure 6 A schematic diagram of the SPP structure provided by the present invention;

[0038] Figure 7 A schematic diagram of the CBAM attention module provided by the present invention;

[0039] Figure 8 A structural diagram of the channel attention module provided by the present invention;

[0040] Fig. 9 A structural diagram of the spatial attention module provided by the present invention;

[0041] Fig.10 Backbone network structure diagram after adding CBAM to YOLOv5 provided by the present invention;

[0042] Fig.11 The overall architecture diagram of the Transformer provided by the present invention;

[0043] Fig.12 The network structure diagram after adding the Transformer module to YOLOv5 provided by the present invention;

[0044] Fig.13A schematic diagram of the angle loss function calculation scheme provided by the present invention;

[0045] Fig.14 The Precision-Recall curve diagram provided by the present invention;

[0046] Fig.15 This is an experimental effect diagram provided by the present invention. DETAILED DESCRIPTION

[0047] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.

[0048] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0049] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0050] See also Figure 1 , a traffic sign recognition method, comprising:

[0051] Step 1: Get traffic sign images;

[0052] Step 2: performing data enhancement on the traffic sign image to form an enhanced traffic sign image;

[0053] In order to improve the detection effect of small targets, the YOLOv5 algorithm will filter and enhance the data set before the training data enters the network. YOLOv5 uses Mosaic for data enhancement. Four pictures that have undergone conventional enhancements such as random flipping, translation, and scaling are spliced ​​together to obtain a picture with a richer number of samples. Through the picture enhanced by Mosaic, processing one picture is equivalent to processing four pictures, which greatly enriches the number of positive and negative samples in the data set, indirectly reducing the demand for video memory, reducing computing resources, and increasing the robustness of the network.

[0054] Step 3: Annotate the enhanced traffic sign image to form a training sample;

[0055] Among them, the marking information is divided into three categories: prohibitory signs, warning signs, and mandatory signs.

[0056] Step 4: Using the training samples to train the improved YOLOv5 network to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added;

[0057] In step 4, the YOLOv5 network includes an input layer, a feature extraction backbone network, a feature enhancement fusion network and a Head layer; a CBAM attention module is added after the CSP2_n module of the feature extraction backbone network, and the encoder block module of the Transformer network is applied to the YOLOv5 network to form an improved YOLOv5 network.

[0058] See also Figure 2 , the traditional YOLOv5 backbone network consists of downsampling Focus, convolution module CSPNet and downsampling CBL convolution. The structure of CBL is as follows Figure 3 As shown, it is used to replace the pooling layer to downsample and adjust the channels of the feature map.

[0059] The Focus downsampling layer performs preliminary downsampling on the input image, which is essentially a slicing operation on the image. Figure 4 As shown in the figure, an input feature map of 4×4×3 is cut every other pixel in width and height, and then spliced ​​to output a new feature map. Then the output feature map after slice splicing is subjected to a conventional convolution operation to obtain a 2x downsampling result and fix the output dimension. Compared with conventional multi-layer convolution for downsampling, Focus's slicing operation retains more information.

[0060] YOLOv5 uses a cross-stage partial network (CSP) for design. Different from the CSP structure in YOLOv3, YOLOv5 designs two different CSP structures to further reduce the number of parameters. The backbone network uses CSP1_n with a residual structure, and the Neck feature enhancement network uses a CSP2_n structure composed of conventional convolutions. The two CS structures are as follows: Figure 5 As shown in the figure. The Bottleneck structure in CSP1_n is a conventional residual structure, which consists of two layers of 3×3 convolution and residual edges. CSP2_n is used in feature enhancement networks, which cancels the residual structure and uses multi-layer convolution to adjust and enhance features. The YOLOv5 backbone network adopts a simple structure, strengthens the information transmission between the upper and lower layers of the network, improves the network fitting speed, and increases the network's feature extraction capabilities.

[0061] The feature enhancement network Neck in YOLOv5 is composed of Feature Pyramid Network (FPN)

[52] Path Aggregation Network (PANet)

[35] The SPP structure is constructed by two different networks. FPN uses a top-down approach to fuse the semantic features of the top layer of the network with the bottom layer features between channels. PANet uses a bottom-up approach to shorten the connection path between the shallow network and the deep network, and enhance the top-level semantic information and the bottom-level edge and color features of the feature map. Figure 6 As shown. Figure 6 It can be seen that it consists of two CBL convolutional layers and four maximum pooling layers with scales of 1×1, 5×5, 9×9, and 13×13, and uses feature maps of different scales to obtain a richer receptive field.

[0062] The Head layer of YOLOv5 is the part that performs target detection and classification on the three feature maps of different scales output by the previous feature enhancement fusion network. The feature maps of three different scales, 20×20, 40×40, and 80×80, are sent to the detection layer for corresponding coordinate regression prediction and classification. After non-maximum suppression, redundant detection frames are eliminated, and different types of targets, large, medium, and small, are predicted respectively, which improves the network's detection performance for dense objects.

[0063] The CBAM (Convolutional Block Attention Module) attention mechanism is a lightweight module that can be inserted into the YOLOv5 network. It consists of a channel attention module (CAM) and a spatial attention module (SAM), which respectively enhance the required features in the channel and spatial dimensions. Then, the weight result obtained by the attention mechanism is multiplied by the input feature map to obtain a feature enhancement. The CBAM attention module is as follows: Figure 7 shown.

[0064] from Figure 7 It can be seen that the feature map is first merged with the input feature map through channel attention and weighted multiplication, and then the obtained feature map is merged with the Mc feature map through spatial attention, and finally a feature map that has passed both channel attention and spatial attention is obtained. For a feature map of a certain layer of input, the feature map Mc is first obtained through channel attention, and then Mc and the original input feature map are weighted summed to obtain the feature map, and the feature map is sent to the spatial attention channel to obtain the feature map Ms. Finally, the obtained Ms is weighted summed with the feature map F' to obtain the feature map F'. The expressions are shown in equations (1) and (2).

[0065]

[0066]

[0067] from Figure 8 As can be seen from the structure diagram of the channel attention module, the channel attention module first performs maximum pooling and average pooling operations on the input feature map F, and then sends it to the MLP convolutional neural network to obtain two output feature maps. After summing them up, they are activated with the Sigmoid function to obtain the final Channel Attention, i.e. Mc, as shown in formula (3).

[0068]

[0069] Where W0 and W1 are the weight information in MLP; F c avg and F c max Represent average pooling and maximum pooling operations respectively.

[0070] from Fig. 9As can be seen from the structure of the spatial attention module, SAM uses the feature map F' output by CAM as the input feature map. Similar to the CAM module, it first performs a maximum pooling and average pooling operation to obtain feature maps of H×W×1, and then concatenates the two feature map channels through the Concat operation, and then converts the feature map into 1 channel through a 7×7 convolution operation. Finally, the feature map Ms is output through the Sigmoid activation function, and the expression is shown in formula (4).

[0071]

[0072] Where, is the Sigmoid activation function; is the convolution kernel of size 7×7; F s avg and F s max Represent average pooling and maximum pooling operations respectively.

[0073] The effect of adding CBAM modules to different locations is different. The experimental results show that adding CBAM network structure to the backbone network can improve the model's feature extraction ability and improve the model's accuracy. After adding CBAM module to the YOLOv5 network model, the Backbone network structure diagram is as follows: Fig.10 shown.

[0074] Transformer is a model that uses the attention mechanism to improve the model training speed. Transformer can be said to be a deep learning model based entirely on the self-attention mechanism. Because it is suitable for parallel computing and the complexity of its own model, it has higher accuracy and performance than the previously popular RNN recurrent neural network. The overall architecture of Transformer is shown in the figure below. Fig.11 , mainly composed of two parts: Encoder and Decoder. The Encoder module in the classic Transformer structure contains 6 Encoder Blocks. Each Encoder Block contains two sub-modules, namely the multi-head self-attention layer and the feedforward fully connected layer. The multi-head self-attention layer uses a ScaledDot-Product Attention calculation method. Experimental results show that Multi-head can extract features of different heads at a more detailed level, which is better than the effect of extracting features with a single head. The feedforward fully connected layer is composed of two fully connected layers, and a Relu activation function is added in the middle of the linear transformation. The specific dimension adopts a 4-fold relationship, that is, the d_model of the multi-head self-attention is 512, and the transformation dimension d_ff in the layer is 2048.

[0075] The Decoder module in the classic Transformer architecture contains 6 Decoder Blocks. Each DecoderBlock contains 3 submodules, namely the multi-head self-attention layer, the Encoder-Decoder Attention layer, and the feedforward fully connected layer. The multi-head self-attention layer uses the same Scaled Dot-Product Attention calculation method as the Encoder module. The biggest difference is that a look-ahead-mask needs to be added, that is, to cover up "future information". The main difference between the Encoder-Decoder Attention layer and the previous multi-head self-attention layer is that Q! = K = V, the matrix Q comes from the output of the previous Decoder Block, and K and V come from the output of the Encoder. The feedforward fully connected layer is exactly the same as in the Encoder.

[0076] The Add&Norm module is connected to each sub-layer in each Encoder Block and Decoder Block. For each Encoder Block, there is Add&Norm behind the two sub-layers. For each DecoderBlock, there is Add&Norm behind the three sub-layers. Add represents residual connection, which is used to transmit information deeper without loss to enhance the fitting ability of the model. Norm represents LayerNorm, a layer-level numerical standardization operation, which is used to prevent the learning process from being abnormal due to excessively large or small parameters, and the model converges very slowly.

[0077] Positional Encoding: Transformer directly uses sine and cosine functions to encode position information, as shown in formulas (5) and (6).

[0078]

[0079]

[0080] An important advantage of using trigonometric functions here is that any PE(pos+k) can be expressed as a linear function of PE(pos), which greatly facilitates calculation. In addition, periodic functions are not limited by sequence length, which can also enhance the generalization ability of the model. See formulas (7) and (8) below.

[0081] sin(α+β)=sin(α)cos(β)+cos(α)sin(β) (7)

[0082] cos(α+β)=cos(α)cos(β)-sin(α)sin(β) (8)

[0083] Based on YOLOv5, the Transformer encoder block is applied to form the Transformer Predictionhead (TPH) and backbone end. Because the feature map resolution at the end of the network is low, applying TPH to low-resolution feature maps can reduce computing and storage costs. In addition, when the resolution of the input image is enlarged, some TPH blocks in the early layers can be removed to make the training process available. Specifically, the present invention uses a Transformer Encoder to replace some convolutional and CSP structures, and applies the Transformer in vision. The Transformer has a unique attention mechanism and better detection effect. The module structure diagram of YOLOv5 after adding the transformer is shown in the figure below. Fig.12 .

[0084] The loss function is an important tool used to measure the similarity between the predicted value and the expected value during the training process. In YOLOv5, the loss function is composed of the target confidence loss L conf ij , classification loss L cls ij and target coordinate box regression loss L reg ij The total loss is composed of three parts, and the total loss is the weighted sum of these three parts:

[0085]

[0086] Among them, L conf ij represents the target confidence loss, L cls ij represents the target classification loss, L reg ij represents the target coordinate frame regression loss, λ1 represents the weight of the target confidence loss, λ2 represents the weight of the target classification loss, and λ3 represents the weight of the target coordinate frame regression loss.

[0087] In the traditional YOLOv5, the target classification loss L cls ij CIoU is used for calculation, and the calculation process is as follows:

[0088]

[0089]

[0090]

[0091]

[0092] CIoU takes into account multiple factors, such as the area, center distance, and aspect ratio of the predicted box and the true box, and more accurately describes their positional relationship. In formula (10), the true center is represented by b gt The predicted center is represented by b, the diagonal distance of the minimum circumscribed rectangle is represented by c, and ρ represents b gt The distance between A and b. In formula (11), A and B represent the real box and the expected box respectively, and IoU is used to calculate the ratio of the intersection and union of two boxes. In formula (13), w gt and h gt is the width and height of the expected box, w and h are the width and height of the predicted box.

[0093] This paper optimizes the target classification loss and uses SIoU instead of CIoU to calculate the regression loss to improve the effect of small target detection. The CIoU loss function calculates the loss from the overlapping area, center point distance, and the aspect ratio of the predicted anchor box and the expected box. Compared with IoU, the effect is greatly improved. However, for the detection of small targets, the aspect ratio difference is small. In order to improve the convergence speed of the predicted box, SIoU with direction matching is used as the regression loss function. SIoU consists of four loss functions: angle loss (Angle cost), distance loss (Distance cost), shape loss (Shape cost) and IoU loss (IoU cost). Angle loss is the core idea of ​​the SIoU loss function. It is the part that enables the predicted box to be in the same direction as the real box faster. The angle loss calculation scheme is as follows: Fig.13 As shown, from Fig.13 It can be seen that the angles of the center points of the real frame and the predicted frame are α and β respectively. The purpose of the angle loss is to try to bring the center point of the predicted frame to the x or y axis closest to the center point of the real frame in the coordinate system where the center point is located, and continuously iterate the calculation to reduce the angle direction between the predicted frame and the real frame. During the convergence process, if α≤π / 4, try to minimize α, otherwise minimize β=π / 2-α. The angle loss function is shown in formula (14).

[0094]

[0095]

[0096]

[0097]

[0098] Where x is the sine value of angle α, σ is the center distance between the real box and the predicted box, and c hThen is the vertical distance between the center point of the real box and the predicted box. After combining the angle loss function, the distance loss of the two boxes is defined as formula (18):

[0099]

[0100] Where γ = 2-LF, ρ t It is the ratio of the horizontal and vertical distances of the center point to the width and height of the minimum bounding rectangle of the real box and the predicted box, which is used as a function to measure the distance between the predicted box and the real box. It can be concluded that when α approaches 0, the contribution of distance loss to the total loss is greatly reduced, and the larger the angle, the higher the loss. Shape loss is defined as:

[0101]

[0102] In the formula, ω h is the height h of the real frame gt The absolute value of the difference between the height h of the predicted box and max(h gt ,h) ratio,ω w is the width w of the real frame g The absolute value of the difference between the width w of the predicted box and max(w gt ,w). θ is the cost of shape loss, which is used to adjust the value of how much attention is paid to the shape cost. Usually this value is defined between 2 and 6. The SIoU loss function combines the loss calculation of four parts and is defined as the following formula (20):

[0103]

[0104] The experimental part of the present invention adopts the latest CCTSDB 2021 dataset. The dataset consists of multiple parts, namely training set, test set, classification test set and negative samples. In terms of training and testing, the training set and test set contain a total of 17,856 images and annotation information. Some pictures in the training set have changed the horizontal size, added salt and pepper noise, adjusted the brightness, etc. on the original pictures. The images with later serial numbers are obtained by extracting frames from driving videos, and the scenes are highly repetitive. The annotation information is divided into three categories: prohibitory signs, warning signs, and mandatory signs.

[0105] It has nearly 20,000 sample images of traffic signs, including nearly 40,000 traffic signs in total, and also contains image data sets classified by size and scene, with rich road background information. The images are collected from normal domestic roads, and the shooting angles are mostly street shots and driving recorders in the car, basically from the perspective of the driver and co-pilot seats in the car.

[0106] In order to objectively evaluate the performance of the network model, the experiment of this invention uses precision, recall and mean average precision (mAP) as evaluation indicators, where precision refers to the proportion of correct predictions among the targets predicted by the model; recall refers to the proportion of correct targets predicted by the model among all real targets; and mean average precision is the average of the prediction accuracy of all categories. The specific calculation formulas are shown in equations (21)-(23):

[0107]

[0108]

[0109]

[0110] Among them, TP represents the number of positive samples predicted correctly by the model, FP represents the number of positive samples predicted incorrectly by the model, and FN represents the number of negative samples predicted incorrectly by the model; AP is obtained by dividing the sum of all precision rates of a certain category in the set by the number of images containing targets of this category.

[0111] The present invention uses GPU RTX 3060 to train the model. Some hyperparameters set for the network during the training process are shown in Table 1.

[0112] Table 1 Some hyperparameter settings

[0113] Training parameters Parameter Value momentum 0.937 Weight decay 0.0005 Initial learning rate 0.01 Cyclic Learning Rate 0.2 Batch size 16 Training Algebra 300

[0114] Step 5: Use the traffic sign recognition model to detect the target traffic sign image to obtain a recognition result.

[0115] In order to verify the effectiveness of the above-mentioned improved method, this paper conducted experiments on the CCTSDB 2021 dataset, adding the CAMB attention mechanism and the transformer model to the model, and improving the global context connection and accuracy through the attention mechanism. The improved algorithm combining the two has better results in precision, recall and map. Fig.14 The figure shows the precision-recall curve obtained from training, which can intuitively show the performance of the algorithm. The larger the area of ​​the graph enclosed by the precision-recall curve, the better the algorithm performance. Fig.15 It can be seen that the trained model performs well. Compared with the original YOLOv5 algorithm, the improved YOLOv5 algorithm in this paper has improved the precision by 7.9%, the recall by 4.43%, and the map by 5.72%.

[0116] The present invention also provides a traffic sign recognition system, comprising:

[0117] Image acquisition module, used to acquire traffic sign images;

[0118] A data enhancement module, used for performing data enhancement on the traffic sign image to form an enhanced traffic sign image;

[0119] An image annotation module, used to annotate the enhanced traffic sign image to form a training sample;

[0120] A training module, used to train the improved YOLOv5 network using the training samples to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added;

[0121] The image detection module is used to detect the target traffic sign image using the traffic sign recognition model to obtain a recognition result.

[0122] The present invention also provides an electronic device, comprising a bus, a transceiver, a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the transceiver, the memory and the processor are connected via the bus, and wherein the computer program, when executed by the processor, implements the steps in the above-mentioned traffic sign recognition method.

[0123] Compared with the prior art, the beneficial effects of the electronic device provided by the present invention are the same as the beneficial effects of the traffic sign recognition method described in the above technical solution, which will not be elaborated here.

[0124] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps in the above-mentioned traffic sign recognition method when executed by a processor.

[0125] Compared with the prior art, the beneficial effects of a computer-readable storage medium provided by the present invention are the same as the beneficial effects of a traffic sign recognition method described in the above technical solution, and will not be elaborated here.

[0126] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technical solution that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A traffic sign recognition method, characterized in that: include: Step 1: Get traffic sign images; Step 2: performing data enhancement on the traffic sign image to form an enhanced traffic sign image; Step 3: Annotate the enhanced traffic sign image to form a training sample; Step 4: Using the training samples to train the improved YOLOv5 network to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added; Step 5: Use the traffic sign recognition model to detect the target traffic sign image to obtain a recognition result.

2. A traffic sign recognition method according to claim 1, characterized in that: The step 2: performing data enhancement on the traffic sign image to form an enhanced traffic sign image, comprises: The Mosaic algorithm is used to perform data enhancement on the traffic sign image to form an enhanced traffic sign image.

3. A traffic sign recognition method according to claim 2, characterized in that: In step 4, the YOLOv5 network includes an input layer, a feature extraction backbone network, a feature enhancement fusion network and a Head layer; a CBAM attention module is added after the CSP2_n module of the feature extraction backbone network, and the encoderblock module of the Transformer network is applied to the YOLOv5 network to form an improved YOLOv5 network.

4. A traffic sign recognition method according to claim 3, characterized in that: In step 4, the loss function of the improved YOLOv5 network is: Among them, L conf ij represents the target confidence loss, L cls ij represents the target classification loss, L reg ij represents the target coordinate frame regression loss, λ1 represents the weight of the target confidence loss, λ2 represents the weight of the target classification loss, and λ3 represents the weight of the target coordinate frame regression loss.

5. A traffic sign recognition method according to claim 4, characterized in that: The target coordinate box regression loss is: Among them, IoU represents the intersection-over-union loss, Δ represents the distance loss, Ω represents the shape loss, σ represents the center distance between the real box and the predicted box, and c h is the vertical distance between the center point of the real box and the predicted box, ω h is the height h of the real frame gt The absolute value of the difference between the height h of the predicted box and max(h gt ,h) ratio,ω w is the width w of the real frame g The absolute value of the difference between the width w of the predicted box and max(w gt ,w) ratio, ρ x is the ratio of the horizontal distance of the center point to the width of the minimum bounding rectangle of the real box and the predicted box, ρ y is the ratio of the vertical distance of the center point to the height of the minimum bounding rectangle of the real box and the predicted box, and θ is the cost of the shape loss.

6. A traffic sign recognition system, characterized in that: include: Image acquisition module, used to acquire traffic sign images; A data enhancement module, used for performing data enhancement on the traffic sign image to form an enhanced traffic sign image; An image annotation module, used to annotate the enhanced traffic sign image to form a training sample; A training module, used to train the improved YOLOv5 network using the training samples to obtain a traffic sign recognition model; wherein the improved YOLOv5 network is a YOLOv5 network with an attention mechanism added; The image detection module is used to detect the target traffic sign image using the traffic sign recognition model to obtain a recognition result.

7. An electronic device, comprising a bus, a transceiver, a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the transceiver, the memory, and the processor are connected via the bus, wherein: When the computer program is executed by the processor, the steps of the traffic sign recognition method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of a traffic sign recognition method according to any one of claims 1 to 5 are implemented.

Citation Information

Cited By

  • Timing sequence picture recognition method and device for hanging archive bulk materials and medium

    CN120182730A

  • Time-sequence image recognition method, device and medium for archival bulk material attachment

    CN120182730B

  • Image target detection method and system based on improved dual-channel Transform

    CN121504916A

  • An image target detection method and system based on an improved dual-channel Transformer

    CN121504916B