Traffic sign detection method and device based on YOLOv5 and medium
By optimizing the prior anchor box in the YOLOv5 model, introducing Bi-FPN structure and attention mechanism, and using SIoUloss loss function, the problems of low traffic sign detection accuracy and high leakage detection rate in complex road environments are solved, and a higher detection accuracy and real-time performance.
Patent Information
- Application Number
- CN202411421716.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-14
AI Technical Summary
In complex road environments, traffic signs are dense due to small pixels, resulting in low detection and positioning accuracy and high leakage detection rate. It is difficult for the existing technology to effectively solve this problem.
The traffic sign detection method based on YOLOv5 is adopted, and the prior anchor box is optimized through genetic algorithm and K-means algorithm, Bi-FPN structure is introduced to perform feature fusion of semantic and position information, integrate attention mechanism GAM, and use SIoUloss as the border regression loss function.
Significantly improve the accuracy of small target detection, reduce the missed detection rate, and improve the detection performance of traffic signs. The improved YOLOv5 model has significantly improved mAP, accuracy, recall and F1 score, and meets the real-time detection requirements. .
Smart Images

Figure CN119445528A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic sign detection, and in particular to a traffic sign detection method, device and medium based on YOLOv5. Background Art
[0002] In recent years, the intelligent networked vehicle industry, dominated by new energy vehicles, has shown a rapid growth trend. A complete and safe intelligent networked vehicle control system is an important direction for the research and development of intelligent vehicles. It can assist driving and even realize unmanned driving, effectively ensure driving safety, improve driving experience, reduce traffic accidents, and improve traffic efficiency. As an important component in the field of vehicle control systems, the Traffic Sign Recognition System (TSRS) has received extensive attention from academia and industry in recent years.
[0003] Traditional traffic sign detection mainly relies on hand-designed traditional features, such as the shape and color of traffic signs. Appropriate features of the image are extracted according to the classification target, and then the extracted features are used to train the machine learning classifier. After the classifier is trained offline, it can be used to classify the image to be identified. Hand-designed features are often unable to adapt to complex driving environments. Multi-stage feature extraction and classification result in huge computational complexity, which cannot meet actual needs in terms of recognition accuracy and speed. Thanks to the improvement of computer hardware and the development of deep learning, a large number of excellent target detection algorithms have been proposed and successfully applied to the detection and recognition of traffic signs.
[0004] The target detection algorithms based on deep learning are mainly divided into two categories: two-stage algorithms (such as RCNN, fastRCNN, faster-RCNN) and one-stage algorithms (such as SSD, YOLO). In the recognition of traffic signs, a fast detection algorithm for traffic signs with a three-scale nested residual structure is proposed, and experiments are conducted on the traffic sign detection dataset. The F1 scores of the three categories of traffic signs, instructions, prohibitions, and warnings are 92.41%, 93.91%, and 92.03% respectively, and the detection time is 5.0ms. At the same time, the model adds shortcuts between the FireModule layers to enhance the feature extraction capability of the network, and the average accuracy on the traffic sign detection dataset reaches 85.56%.
[0005] In actual complex road environments, traffic sign pixels are small and dense, resulting in low detection and positioning accuracy and high missed detection rate. Therefore, how to improve the detection accuracy of small targets, reduce the missed detection rate, and thus improve the detection performance of traffic signs is a technical problem that needs to be solved urgently. Summary of the invention
[0006] The technical task of the present invention is to provide a traffic sign detection method, device and medium based on YOLOv5 to solve the problem of how to improve the detection accuracy of small targets, reduce the missed detection rate, and thus improve the detection performance of traffic signs.
[0007] The technical task of the present invention is achieved in the following way: a traffic sign detection method based on YOLOv5, the method is as follows:
[0008] Genetic algorithm and K-means algorithm are used to optimize the prior anchor point box to enhance the detection accuracy of small targets;
[0009] The Bi-FPN structure is introduced to achieve the feature fusion of semantic and position information and improve the representation ability of the network;
[0010] By integrating the attention mechanism GAM, the network's anti-interference and feature extraction capabilities in complex environments are enhanced;
[0011] SIoUloss is used as the bounding box regression loss function to improve positioning accuracy.
[0012] As a preferred method, the Bi-FPN structure adopts a weighted bidirectional feature pyramid network Bi-FPN, which introduces learnable weights to measure the importance of different input features, balances feature information of different scales, and repeatedly applies top-down and bottom-up multi-scale feature fusion.
[0013] Among them, the weighted bidirectional feature pyramid network Bi-FPN formula is as follows:
[0014]
[0015] Among them, P represents the fused feature layer; P i Represents different feature layers; ω i is a learnable weight parameter; parameter ε = 0.0001, to avoid numerical calculation problems caused by division by zero; through the self-learning of the weighted bidirectional feature pyramid network Bi-FPN, key information can be extracted at different feature layers to promote feature fusion;
[0016] In the Bi-FPN structure, multiple weighted bidirectional feature pyramid networks Bi-FPN can fuse features from multiple layers, such as the 13th layer, the 17th layer, the 21st layer, and the 25th layer, and balance semantic and location information through network training weights, thereby improving the classification and positioning accuracy of the target.
[0017] More optimally, the attention mechanism GAM extracts key information of interest by observing the global information of the image, suppresses or filters out useless background and redundant information, and improves the efficiency of information processing and the accuracy of extracting key information.
[0018] Preferably, the GAM attention mechanism includes a channel attention submodule and a spatial attention submodule;
[0019] The channel attention submodule uses a three-dimensional arrangement to retain information in three dimensions, and uses a two-layer multi-layer perceptron MLP to amplify the cross-dimensional channel-space dependency. For the input feature map, the dimension conversion is first performed, and then the dimension-converted feature map is input into the multi-layer perceptron MLP, and then converted to the original dimension, and the final feature map is output after Sigmoid processing.
[0020] The spatial attention submodule uses two convolutional layers to fuse spatial information, removes the loss of spatial position information caused by the pooling layer, and uses channel reduction and 7*7 convolution to reduce the number of channels, thereby reducing the amount of computation while focusing on the extraction of spatial dimension information.
[0021] Preferably, the bounding box regression loss function includes classification loss (classificationloss), target confidence loss (objectloss) and positioning box bbox regression loss (boundingboxregressionloss);
[0022] Among them, the positioning box bbox regression loss uses the complete intersection-over-union loss function (Complete-IoUloss, CIoULoss) to achieve target box prediction, the formula is as follows:
[0023] LCIoU = 1-CIoU;
[0024]
[0025] Among them, B, Bgt represent the predicted box and the real box; ρ represents the Euclidean distance between the center point coordinates of the predicted box and the real box; C represents the diagonal distance of the minimum closure area that contains both the predicted box and the real box; wgt, hgt represent the width and height of the real box; w, h represent the width and height of the predicted box; v represents the normalization of the difference between the length and width ratio of the predicted box and the real box; α is a balance factor used to balance the loss caused by the length and width ratio and the loss caused by the IoU part.
[0026] Better yet, the bounding box regression loss function introduces the SIoU loss function, which is used for the vector angle between the real box and the predicted box, and redefines the penalty index;
[0027] SIoU loss function includes angle loss (Anglecost), distance loss (Distancecost), shape loss (Shapecost) and IoU loss (IoUcost);
[0028] The angle loss is as follows:
[0029]
[0030] Where ∧ represents the angle loss; (b cx, b cy ) is the coordinate of the center point of the prediction box; (b cx gt , b cy gt ) is the coordinate of the center point of the real box; σ represents the distance between the center point of the real box and the predicted box; ch is the height difference between the center point of the real box and the predicted box;
[0031] The distance loss formula is as follows:
[0032] Δ=Σt=x,y(1-e-rρt);
[0033]
[0034] r = 2-∧;
[0035] Among them, Δ represents the distance loss; cw and ch are the width and height of the minimum external matrix of the real box and the predicted box;
[0036] The shape loss formula is as follows:
[0037]
[0038]
[0039] Among them, Ω represents shape loss; w, h, wgt, hgt are the width and height of the predicted box and the true box respectively; θ is a hyperparameter that controls the degree of attention to shape loss, in order to avoid paying too much attention to shape loss and reducing the movement of the predicted box;
[0040] The final SIoU loss function formula is as follows:
[0041]
[0042] An electronic device comprising: a memory and at least one processor;
[0043] Wherein, the memory stores a computer program;
[0044] The at least one processor executes the computer program stored in the memory, so that the at least one processor performs the traffic sign detection method based on YOLOv5 as described above.
[0045] A computer-readable storage medium stores a computer program, which can be executed by a processor to implement the traffic sign detection method based on YOLOv5 as described above.
[0046] The traffic sign detection method, device and medium based on YOLOv5 of the present invention have the following advantages:
[0047] (I) The present invention improves the detection accuracy of small targets by optimizing the prior anchor box through genetic algorithm and K-means algorithm, and introduces Bi-FPN structure to fuse semantic information and position information to enhance the network representation ability; it also adds attention mechanism GAM to improve the network's anti-interference ability and feature extraction ability in complex environments; at the same time, it changes the frame regression loss function SIoUloss to achieve rapid convergence and accuracy of the model; compared with the standard YOLOv5 algorithm, the average precision mean mAP, precision P, recall rate, and F1 improvement values of the improved algorithm of the present invention are 10.03 percentage points, 4.7 percentage points, 2.6 percentage points, and 3.48 percentage points, respectively, which verifies the effectiveness of the algorithm for traffic sign detection, and the FPS reaches 208.33FPS, meeting the real-time detection requirements;
[0048] (ii) Based on the YOLOv5 model, the present invention aims to improve the detection accuracy of traffic signs and accelerate the convergence of model training by adding an attention mechanism, introducing multi-scale fusion, and changing the border regression loss function, in view of the fact that traffic signs are densely packed in images and account for a small proportion. The improved YOLOv5s model improves the mAP index by 10.03 percentage points, the accuracy by 4.7 percentage points, and the recall by 2.6 percentage points compared with the original YOLOv5 network, and performs well in the detection of small targets.
[0049] (III) The present invention solves the problem of detecting small and dense traffic signs in complex road environments. It optimizes the anchor box through genetic algorithm and K-means algorithm to improve the detection accuracy of small targets, introduces Bi-FPN structure and attention mechanism GAM to enhance feature fusion and extraction, and uses SIoUloss to optimize the bounding box regression. The experimental results show that the algorithm significantly improves mAP, precision, recall rate and F1 score, and meets the real-time requirements with 208.33FPS, effectively improving the detection performance of Chinese traffic signs.
[0050] (IV) Aiming at the characteristics of small and dense targets and complex and changeable background in traffic sign datasets, the present invention introduces the GAM attention mechanism to improve the feature extraction capability of the network and ignores irrelevant features. The Bi-FPN structure is introduced to strengthen the balance and fusion between high-level semantics and low-level features. The convergence speed of the model is accelerated by replacing the bounding box regression loss function. Experiments show that compared with the original algorithm, the present invention can significantly improve the target positioning accuracy and reduce missed detections. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The present invention is further described below in conjunction with the accompanying drawings.
[0052] Attached Figure 1 This is a schematic diagram of the improved YOLOv5 network model structure;
[0053] Attached Figure 2 Schematic diagram of the original YOLOV5 model;
[0054] Attached Figure 3 Schematic diagram of the feature fusion structure Bi-FPN;
[0055] Attached Figure 4 Schematic diagram of GAM attention mechanism;
[0056] Attached Figure 5 Schematic diagram of the working process of the channel attention submodule;
[0057] Attached Figure 6 Schematic diagram of the working process of the spatial attention submodule;
[0058] Attached Figure 7 is a schematic diagram of angle loss;
[0059] Attached Figure 8 Schematic diagram of distance loss;
[0060] Attached Fig. 9 It is a schematic diagram for comparing the detection results (from left to right: the original image, the image after detection by the original YOLOV5 model, and the image after detection by the present invention). DETAILED DESCRIPTION
[0061] The traffic sign detection method, device and medium based on YOLOv5 of the present invention are described in detail below with reference to the accompanying drawings and specific embodiments of the specification.
[0062] Embodiment 1:
[0063] As attached Figure 2As shown in the figure, the original YOLOV5 model: The core idea of YOLO is to regard target detection as a regression problem of spatially separated prediction boxes and associated class probabilities. The YOLOv5 model structure can be divided into four main parts: Input, Backbone, Neck, and Head. According to the depth and width of the model, four models, YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x, are derived. According to different devices and adapted to different data sets, the balance between accuracy and speed is achieved.
[0064] The input end mainly includes three methods: Mosaic data enhancement, adaptive anchor calculation, and adaptive image scaling. Mosaic data enhancement stitches 4 different images by random scaling, random cropping, and random arrangement. It can not only enrich the background of the detected target and improve the detection effect of small targets, but also reduce the use of video memory and enhance the BN effect. Adaptive anchor calculation refers to the use of K-Means clustering and genetic algorithms to adaptively calculate the best anchor box values in different training sets. The prediction box generated according to the best anchor box can better match GroundTruth, thereby accelerating model convergence and improving positioning accuracy. Adaptive image scaling is to adaptively add the least black border to images with different aspect ratios, reduce redundant information and improve reasoning speed.
[0065] Backbone mainly includes C3 and SPPF modules. The C3 module is based on the BottleneckCSP module, which integrates the gradient changes from beginning to end into the feature map, supports feature propagation, encourages the network to reuse features, enhances the network's ability to extract features, and reduces the number of network parameters. SPPF extracts features through the maximum pooling of different pooling kernels to improve the network's receptive field.
[0066] Neck mainly includes feature pyramid networks (FPN ) The structure is combined with a path aggregation network (PAN). FPN is top-down, transferring and fusing high-level feature information through upsampling. PAN is bottom-up, transferring and fusing low-level location information. The FPN layer conveys strong semantic features from top to bottom, while the feature pyramid conveys strong positioning features from bottom to top, realizing the fusion and complementarity of high-level features and low-level features, so that the model obtains rich positioning and classification feature information.
[0067] The head sets up three detection heads, and the images are downsampled by 32 times, 16 times, and 8 times in the three detection layers. Feature maps of different sizes are used to detect target objects of different sizes, and regression prediction is performed using the calculated prior boxes, which is beneficial for the detection of targets of different sizes, especially small targets.
[0068] As attached Figure 1 As shown, this embodiment provides a traffic sign detection method based on YOLOv5, and the method is specifically as follows:
[0069] S1. Genetic algorithm and K-means algorithm are used to optimize the prior anchor box to enhance the detection accuracy of small targets, as shown in the following table:
[0070]
[0071] S2. Introduce Bi-FPN structure to realize the feature fusion of semantic and position information and improve the representation ability of the network; among them, the convolutional neural network continuously extracts the features of the image through convolution. As the depth of the network increases, high-level semantic features are extracted, which can greatly improve the network's recognition of the image, but at the same time, the position information of the target is also continuously weakened in the process of feature extraction. Yolov5 adopts the structure of FPN+PAN combination to realize feature fusion. The bottom-up FPN structure can provide stronger semantic information (conducive to object classification), and the top-down PAN structure can provide stronger position information (conducive to object positioning). In this way, the predicted feature layer has both higher semantic information and position information, which improves the accuracy of the target detection task. As shown in the attached figure, Figure 3 shown.
[0072] S3, enhance the network's anti-interference and feature extraction capabilities in complex environments by integrating the attention mechanism GAM;
[0073] S4. Use SIoUloss as the bounding box regression loss function to improve positioning accuracy.
[0074] The Bi-FPN structure in step S2 of this embodiment adopts a weighted bidirectional feature pyramid network Bi-FPN, introduces learnable weights to measure the importance of different input features, balances feature information of different scales, and repeatedly applies top-down and bottom-up multi-scale feature fusion;
[0075] Among them, the weighted bidirectional feature pyramid network Bi-FPN formula is as follows:
[0076]
[0077] Among them, P represents the fused feature layer; P i Represents different feature layers; ωi is a learnable weight parameter; parameter ε = 0.0001, to avoid numerical calculation problems caused by division by zero; through the self-learning of the weighted bidirectional feature pyramid network Bi-FPN, key information can be extracted at different feature layers to promote feature fusion;
[0078] In the Bi-FPN structure, multiple weighted bidirectional feature pyramid networks Bi-FPN can fuse features from multiple layers, such as the 13th layer, the 17th layer, the 21st layer, and the 25th layer, and balance semantic and location information through network training weights, thereby improving the classification and positioning accuracy of the target.
[0079] The attention mechanism GAM in step S3 of this embodiment extracts key information of interest by observing the global information of the image, suppresses or filters out useless background and redundant information, and improves the information processing efficiency and the accuracy of extracting key information.
[0080] The GAM attention mechanism (Global Attention Mechanism) is different from the CBAM module (Convolutional Block Attention Module). It not only considers the injection of attention maps along the two independent dimensions of the channel and space of the feature map, but also considers the interaction between the channel and space, introduces and amplifies the cross-dimensional interaction, and captures important features in all three dimensions, such as the attached Figure 4 shown.
[0081] The GAM attention mechanism in step S3 of this embodiment includes a channel attention submodule and a spatial attention submodule;
[0082] The channel attention submodule uses a three-dimensional arrangement to retain information in three dimensions, and uses a two-layer multi-layer perceptron MLP to amplify the cross-dimensional channel-space dependency. For the input feature map, the dimension conversion is first performed, and then the dimension-converted feature map is input into the multi-layer perceptron MLP, and then converted to the original dimension, and the final feature map is output after Sigmoid processing, as shown in the attached figure. Figure 5 As shown;
[0083] The spatial attention submodule uses two convolutional layers to fuse spatial information, removes the loss of spatial position information caused by the pooling layer, and uses channel reduction and 7*7 convolution to reduce the number of channels, while reducing the amount of calculation and focusing on the extraction of spatial dimension information. Figure 6 shown.
[0084] The border regression loss function in step S4 of this embodiment includes classification loss (classificationloss), target confidence loss (objectloss) and positioning box bbox regression loss (boundingboxregressionloss);
[0085] Among them, the positioning box bbox regression loss uses the complete intersection-over-union loss function (Complete-IoUloss, CIoULoss) to achieve target box prediction, the formula is as follows:
[0086] LCIoU = 1-CIoU;
[0087]
[0088]
[0089] Among them, B, Bgt represent the predicted box and the real box; ρ represents the Euclidean distance between the center point coordinates of the predicted box and the real box; C represents the diagonal distance of the minimum closure area that contains both the predicted box and the real box; wgt, hgt represent the width and height of the real box; w, h represent the width and height of the predicted box; v represents the normalization of the difference between the length and width ratio of the predicted box and the real box; α is a balance factor used to balance the loss caused by the length and width ratio and the loss caused by the IoU part.
[0090] The traditional IoU loss only considers the result loss caused by the intersection and union between the predicted box and the true box, while ignoring the impact of the IoU loss of the predicted box on the model convergence during the regression process. For example, there is no difference in the calculation of IoU loss when the predicted box and the true box are completely overlapped or not overlapped, which cannot help the model converge. GIoU introduces the smallest box that can frame both the true box and the predicted box at the same time, solving the problem that IoU cannot measure the distance between the true box and the predicted box when they are completely separated. DIoU introduces penalty parameters p and c that measure the distance difference between the center point coordinates, solving the problem that when the predicted box and the true box are completely overlapped, the center point of the predicted box quickly converges to the center point of the true box. YOLOv5 uses the CIoU loss function, which takes into account the length and width ratio of the predicted box and the true box on the basis of DIoU, and better solves the convergence inefficiency caused by the problem of regional overlap. However, none of the methods proposed so far consider the direction between the true box and the predicted box, resulting in slow convergence. This deficiency leads to slow convergence and low efficiency, because the predicted box may "wander around" during training and ultimately produce a worse model. Gevorgyan Z. et al. proposed a new SIoU loss function.
[0091] The frame regression loss function in step S4 of this embodiment introduces the SIoU loss function, which is used for the vector angle between the real frame and the predicted frame, and redefines the penalty index;
[0092] SIoU loss function includes angle loss (Anglecost), distance loss (Distancecost), shape loss (Shapecost) and IoU loss (IoUcost);
[0093] Among them, as attached Figure 7 As shown, the angle loss is as follows:
[0094]
[0095] Where ∧ represents the angle loss; (b cx, b cy ) is the coordinate of the center point of the prediction box; (b cx gt , b cy gt ) is the coordinate of the center point of the real box; σ represents the distance between the center point of the real box and the predicted box; ch is the height difference between the center point of the real box and the predicted box;
[0096] The distance loss formula is as follows:
[0097] Δ=Σt=x,y(1-e-rρt);
[0098]
[0099] r = 2-∧;
[0100] Among them, Δ represents the distance loss; cw and ch are the width and height of the minimum external matrix of the real box and the predicted box;
[0101] As attached Figure 8 As shown, the shape loss formula is as follows:
[0102]
[0103] Among them, Ω represents shape loss; w, h, wgt, hgt are the width and height of the predicted box and the true box respectively; θ is a hyperparameter that controls the degree of attention to shape loss, in order to avoid paying too much attention to shape loss and reducing the movement of the predicted box;
[0104] The final SIoU loss function formula is as follows:
[0105]
[0106] In the border regression loss, SIOULoss takes all losses into consideration, which makes the convergence faster and the accuracy higher, which is better than CIOULoss in the original network. Therefore, this patent adopts the SIOULoss border regression loss function with better performance.
[0107] In order to verify the target recognition performance of the improved YOLOv5 network model, this patent reproduced the performance of the original YOLOv5 (v6.1) model in the traffic sign dataset (experimental Repo), using this as the reference baseline, conducted ablation experiments on all the improved points, and compared the improved YOLOv5 network model (experimental Imp-YOLO) that integrated all the improved points with the reference baseline. The experimental results are shown in the following table.
[0108]
[0109] The experimental data show that the improved YOLOv5 model has achieved significant improvements in all indicators. The GAM attention model is introduced on the basis of the original model, which can better utilize the spatial position information and feature channel information and the interaction between the two, capture feature information in three dimensions, and has better detection effect for dense detection tasks that rely on position information. The recall rate R is improved by 3.23%, and the positioning mAP is improved by 3.2%. The Bi-FPN structure uses a weighted method to fuse features, which can effectively balance and fuse low-level features with high-level features. In view of the fact that there are many small targets in the target data set, efficient feature fusion effectively improves the model's ability to extract features, and improves the model accuracy P by 4.0%. Finally, SIoU is introduced as the loss function for prediction box regression, which solves the problem that the original CIoU does not consider the different directions between the real box and the prediction box, resulting in slow convergence, and improves the positioning accuracy of the model boundary box by 3.27%, and the detection speed is also improved by 3.72FPS.
[0110] In general, compared with the original model YOLOv5, the accuracy P reached 92.8%, an increase of 4.4%, the recall rate was 75.6%, an increase of 2.6%, and the F1-socore was 83.32, an increase of 3.48%. mAP@0.5:0.95 increased by 10.03%, and the model's high-precision boundary fitting ability was significantly enhanced. While ensuring high detection accuracy, the detection rate reached 208.33FPS to meet real-time requirements. The experimental results show that the joint optimization of the attention mechanism, feature fusion, and border regression loss function can effectively improve the detection effect of traffic signs.
[0111] As attached Fig. 9As shown in the figure, the model trained by the original YOLOv5 algorithm has some omissions in the detection, especially in the case of continuous dense small targets and complex night environments, the detection effect is poor. The leftmost image misses one indicator sign, the middle image misses two prohibition signs at night, and the rightmost image misses the middle prohibition sign. The improved YOLOv5 algorithm in this embodiment successfully detects all the traffic signs marked in the data set on the image, and accurately locates them without omissions.
[0112] In terms of detection of different categories, the improved YOLOv5 model has a more obvious improvement in positioning accuracy compared to the original YOLOv5 (see the table below).
[0113]
[0114] The mAP@0.5:0.95 for positioning the three major categories of traffic signs reached 62.5%, 61.2% and 58.9% respectively. The positioning accuracy of prohibition signs was improved by 9.7%, the positioning accuracy of warning signs was improved by 8.27%, and the positioning accuracy of instruction signs was improved by 12.1%. In the detection of objects of different sizes, the improvement for dense small objects is more obvious than that for large objects (see the table below). For XS objects with a size less than 210 pixels, the improvement reached 13.83%. The introduced attention mechanism and feature fusion pay more attention to a large number of dense small objects, which makes them significantly improved compared to large objects.
[0115]
[0116] Embodiment 2:
[0117] This embodiment also provides an electronic device, including: a memory and a processor;
[0118] Wherein, the memory stores computer-executable instructions;
[0119] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the traffic sign detection method based on YOLOv5 in any embodiment of the present invention.
[0120] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or any conventional processor, etc.
[0121] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory can also include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage period, a flash memory device, or other volatile solid-state storage devices.
[0122] Embodiment 3:
[0123] This embodiment also provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions are loaded by a processor, so that the processor executes the traffic sign detection method based on YOLOv5 in any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code that implements the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.
[0124] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0125] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0126] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0127] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A traffic sign detection method based on YOLOv5, characterized in that: The method is as follows: Genetic algorithm and K-means algorithm are used to optimize the prior anchor point box to enhance the detection accuracy of small targets; The Bi-FPN structure is introduced to achieve the feature fusion of semantic and position information and improve the representation ability of the network; By integrating the attention mechanism GAM, the network's anti-interference and feature extraction capabilities in complex environments are enhanced; SIoUloss is used as the bounding box regression loss function to improve positioning accuracy.
2. The traffic sign detection method based on YOLOv5 according to claim 1, characterized in that: The Bi-FPN structure uses a weighted bidirectional feature pyramid network Bi-FPN, which introduces learnable weights to measure the importance of different input features, balances feature information of different scales, and repeatedly applies top-down and bottom-up multi-scale feature fusion. Among them, the weighted bidirectional feature pyramid network Bi-FPN formula is as follows: Among them, P represents the fused feature layer; P i Represents different feature layers; ω i is a learnable weight parameter; parameter ε = 0.0001, to avoid numerical calculation problems caused by division by zero; through the self-learning of the weighted bidirectional feature pyramid network Bi-FPN, key information can be extracted at different feature layers to promote feature fusion; In the Bi-FPN structure, multiple weighted bidirectional feature pyramid networks Bi-FPN can fuse features from multiple strata and balance semantic and location information through network training weights, thereby improving the classification and positioning accuracy of the target.
3. The traffic sign detection method based on YOLOv5 according to claim 1 or 2, characterized in that: The attention mechanism GAM extracts key information of interest by observing the global information of the image, suppresses or filters out useless background and redundant information, and improves the efficiency of information processing and the accuracy of extracting key information.
4. The traffic sign detection method based on YOLOv5 according to claim 3, characterized in that: The GAM attention mechanism includes a channel attention submodule and a spatial attention submodule; The channel attention submodule uses a three-dimensional arrangement to retain information in three dimensions, and uses a two-layer multi-layer perceptron MLP to amplify the cross-dimensional channel-space dependency. For the input feature map, the dimension conversion is first performed, and then the dimension-converted feature map is input into the multi-layer perceptron MLP, and then converted to the original dimension, and the final feature map is output after Sigmoid processing. The spatial attention submodule uses two convolutional layers to fuse spatial information, removes the loss of spatial position information caused by the pooling layer, and uses channel reduction and 7*7 convolution to reduce the number of channels, thereby reducing the amount of computation while focusing on the extraction of spatial dimension information.
5. The traffic sign detection method based on YOLOv5 according to claim 4, characterized in that: The bounding box regression loss function includes classification loss, target confidence loss and positioning box bbox regression loss; Among them, the positioning box bbox regression loss uses the complete intersection-over-union loss function to realize the target box prediction, and the formula is as follows: LCIoU = 1-CIoU; Among them, B, Bgt represent the predicted box and the real box; ρ represents the Euclidean distance between the center point coordinates of the predicted box and the real box; C represents the diagonal distance of the minimum closure area that contains both the predicted box and the real box; wgt, hgt represent the width and height of the real box; w, h represent the width and height of the predicted box; v represents the normalization of the difference between the length and width ratio of the predicted box and the real box; α is a balance factor used to balance the loss caused by the length and width ratio and the loss caused by the IoU part.
6. The traffic sign detection method based on YOLOv5 according to claim 5, characterized in that: The SIoU loss function is introduced into the bounding box regression loss function. The SIoU loss function is used for the vector angle between the real box and the predicted box, and the penalty index is redefined. SIoU loss function includes angle loss, distance loss, shape loss and IoU loss; The angle loss is as follows: Where ∧ represents the angle loss; (b cx, b cy ) is the coordinate of the center point of the prediction box; (b cx gt , b cy gt ) is the coordinate of the center point of the real box; σ represents the distance between the center points of the real box and the predicted box; ch is the height difference between the center points of the real box and the predicted box; The distance loss formula is as follows: Δ=Σt=x,y(1-e-rρt); r=2-∧; Among them, Δ represents the distance loss; cw and ch are the width and height of the minimum external matrix of the real box and the predicted box; The shape loss formula is as follows: Among them, Ω represents shape loss; w, h, wgt, hgt are the width and height of the predicted box and the true box respectively; θ is a hyperparameter that controls the degree of attention to shape loss, in order to avoid paying too much attention to shape loss and reducing the movement of the predicted box; The final SIoU loss function formula is as follows:
7. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores a computer program; The at least one processor executes the computer program stored in the memory, so that the at least one processor performs the traffic sign detection method based on YOLOv5 as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which can be executed by a processor to implement the traffic sign detection method based on YOLOv5 as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Rare antinuclear antibody karyotype detection method based on YOLO and attention neural network
CN116893162A
Unmanned aerial vehicle image detection method based on multi-scale feature fusion and context enhancement
CN117037004A
Improved YOLOv5s small target cloth flaw detection method
CN117152484A
Rice pest detection method and device based on YOLOv5s algorithm
CN117523354A
Lightweight smoke and fire detection method based on YOLOv8
CN118570721A
Cited By
Power transmission tower bolt detection method based on improved yov5s, electronic equipment and storage medium
CN120563938A
Power transmission tower bolt detection method based on improved yolov5s, electronic device and storage medium
CN120563938B