Traffic sign detection method, detection device, electronic equipment and storage medium
By introducing the residual fusion attention module and multi-scale feature processing in YOLOv5, combined with the square root reweighted loss and data enhancement, the problem of insufficient robustness of YOLOv5 in traffic sign detection is solved, and the detection accuracy and Adaptability.
Patent Information
- Application Number
- CN202410364314.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-03-28
AI Technical Summary
YOLOv5 is not robust enough in traffic sign detection, and has low accuracy when adapting to complex backgrounds and traffic signs of different shapes and sizes.
On the basis of YOLOv5, the residual fusion attention module is introduced into the neck network, combined with multi-scale feature extraction and fusion, using the root reweighted category loss function and data enhancement technology to improve the detection model to improve robustness and adaptability. sex.
It significantly improves the accuracy and robustness of traffic sign detection, improves the adaptability to different sizes and complex backgrounds, and enhances the model's generalization ability and detection efficiency.
Smart Images

Figure CN118212626B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of vehicle technology, and in particular, relates to a traffic sign detection method, a traffic sign detection device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the field of computer vision, object detection is an important task that can accurately detect the specified target object in an image or video. Object detection methods based on deep learning have attracted much attention due to their accuracy and scalability. Among them, the YOLO (You Only Look Once) algorithm is an end-to-end object detection algorithm. Its basic idea is to divide the image into S×S grids and predict the category, location and confidence of the target on each grid. Compared with other object detection algorithms, YOLO has the advantages of high speed and high accuracy. Among the YOLO algorithms, YOLOv5 has outstanding performance in both detection accuracy and speed.
[0003] YOLOv5 still has some problems when detecting traffic signs, such as insufficient robustness to complex backgrounds and limited adaptability to traffic signs of different shapes and sizes, which will lead to its low detection accuracy. Summary of the invention
[0004] The present application provides a traffic sign detection method, a traffic sign detection device, an electronic device and a computer-readable storage medium. The method can accurately detect different traffic signs and improve the robustness of the detection model.
[0005] In a first aspect, the present application provides a method for detecting a traffic sign, comprising:
[0006] The backbone network of the pre-trained detection model extracts features from the image to be processed to obtain image features;
[0007] The image features are fused based on a neck network provided with a residual fusion attention module to obtain fusion features; the residual fusion attention module includes at least two attention modules, and each attention module is connected through a residual structure;
[0008] The fused features are detected based on the detection module to obtain the detection results of the traffic signs in the image to be processed.
[0009] In a second aspect, the present application provides a traffic sign detection device, comprising:
[0010] An extraction module is used to extract features from the image to be processed based on the backbone network of the pre-trained detection model to obtain image features;
[0011] A fusion module, used for fusing image features based on a neck network provided with a residual fusion attention module to obtain fusion features; the residual fusion attention module includes at least two attention modules, and each attention module is connected by a residual structure;
[0012] The detection module is used to detect the fused features based on the detection module to obtain the detection result of the traffic sign in the image to be processed.
[0013] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method of the first aspect when executing the computer program.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect are implemented.
[0015] In a fifth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by one or more processors, it implements the steps of the method of the first aspect.
[0016] Compared with the prior art, the present application has the following beneficial effects: by improving the network structure of the detection model, a residual fusion attention module is introduced into the neck network, and the residual fusion attention module includes at least two attention modules, and each attention module is connected through a residual structure. Through this improvement, the image features extracted by the backbone network of the detection model can be fully fused in the neck network to obtain more distinguishable important features, namely, fusion features; the detection module is used to detect the fusion features, which can accurately and quickly distinguish different traffic signs in the image to be processed, improve the accuracy of the traffic sign detection results, and thus make the detection model more robust.
[0017] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1It is a schematic diagram of the network structure of YOLOv5 provided in an embodiment of the present application;
[0020] Figure 2 This is a schematic diagram of the network structure of the optimal TS-YOLOv5 provided in an embodiment of the present application;
[0021] Figure 3 is a schematic flow chart of the TS-YOLOv5 training method provided in an embodiment of the present application;
[0022] Figure 4 is a schematic flow chart of a method for detecting a traffic sign provided in an embodiment of the present application;
[0023] Figure 5 It is a schematic diagram of the network structure of TS-YOLOv5 with a scale of 3 provided in an embodiment of the present application;
[0024] Figure 6 It is a structural diagram of the Coordinate Attention module provided in an embodiment of the present application;
[0025] Figure 7 is a schematic diagram of the structure of the residual fusion attention module provided in an embodiment of the present application;
[0026] Figure 8 is a schematic diagram of the structure of a single detection head provided in an embodiment of the present application;
[0027] Fig. 9 It is a performance comparison chart of the optimal detection model TS-YOLOv5 and YOLOv5 provided in the embodiment of the present application;
[0028] Fig.10 is a schematic diagram of the structure of a traffic sign detection device provided in an embodiment of the present application;
[0029] Fig.11 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0031] In the related art, the current traffic signs have a low accuracy in detection due to their diversity in size and type.
[0032] In order to solve this problem, the present application proposes a traffic sign detection method, which can accurately detect different traffic signs and improve the robustness of the detection model. The control method proposed in the present application will be described below through specific embodiments.
[0033] The traffic sign detection method provided in the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, vehicle-mounted equipment, augmented reality (AR) / virtual reality (VR) equipment, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0034] In some embodiments, in order to implement the technical solution proposed in this application, this application is based on YOLOv5 as the basic network, and improves the detection model used in this application. The network structure of YOLOv5 can be found in Figure 1 Since the improved model is mainly used to detect traffic signs, the improved YOLOv5 is recorded as TS-YOLOv5, which is the abbreviation of TrafficSigns-YOLOv5.
[0035] Optionally, in the process of improving YOLOv5, firstly, in order to better distinguish the importance of different features, TS-YOLOv5 adds a residual fusion attention module to the neck network, wherein the residual fusion attention module includes at least two attention modules, and each attention module is connected by a residual structure. By introducing the residual fusion attention module, the neck network can better distinguish the importance of features and fuse image features with higher discrimination.
[0036] Optionally, given that traffic signs vary in size, and in different application scenarios, even the same traffic signs may have different sizes in the image to be processed. Therefore, in order to detect traffic signs of different sizes, the multi-scale feature extraction and multi-scale feature fusion in YOLOv5 are retained. Among them, the neck network can divide different feature fusion networks according to the feature scales to be fused, that is, each scale corresponds to a feature fusion network. In order to ensure that the features at each scale can be fused according to their importance to highlight the feature information with high discrimination, a residual fusion attention module can be added to each feature fusion network.
[0037] Optionally, the residual fusion attention module can be added after the C3_2 module of each feature fusion network. As a result, the fused features output by each feature fusion network will be more discriminative, which will help improve the detection results of traffic signs and improve the robustness of TS-YOLOv5.
[0038] Optionally, in order to reduce network parameters and network computation, TS-YOLOv5 can remove the CBS module originally after the C3_2 module while introducing the residual fusion attention module (RFA). The convolution kernel K=1 and stride S=1 of the CBS module are as follows. C represents convolution (conv), B represents batch normalization (BatchNormalization, BN), and S represents the activation function SiLU. TS-YOLOv5 also retains some CBS modules, which have the same meaning as the removed CBS modules, except for the size of the convolution kernel and stride.
[0039] Optionally, for the retained CBS module, its convolution block can be a channel separation convolution block, which can greatly reduce the parameters of the convolution and improve the computational efficiency.
[0040] Optionally, in order to improve the operation speed of the network, that is, to improve the detection efficiency of traffic signs, the stem part in the YOLOv5 backbone network can be improved by changing the convolution kernel size from K=6 to K=3. This can speed up the operation speed of the network without affecting feature extraction.
[0041] Optionally, in order to better detect traffic signs of different scales, the detection module of YOLOv5 can be decoupled to obtain the same number of detection heads as the number of scales, that is, each detection head is used to detect traffic signs at one scale. By decoupling the detection module, not only can the network structure be simplified and the model convergence speed be accelerated, but also the detection accuracy can be improved.
[0042] As an example only, the improved optimal TS-YOLOv5 network structure is as follows Figure 2 As shown. Among them, three scales are divided, which are used to detect small (1 / 8 scale), medium (1 / 16 scale) and large (1 / 32 scale) traffic signs. It can be understood that in order to further improve the detection accuracy, more scales can be divided to meet different actual needs. That is, the specific scales of traffic signs to be detected can be set according to actual conditions and are not limited in this application.
[0043] Based on the network structure of TS-YOLOv5, in order to illustrate the technical solution proposed in this application, each embodiment will be described below with an electronic device as the execution subject.
[0044] In view of the fact that there is still a problem of imbalanced categories in the training process of each traffic sign, in order to solve this problem, we can start with conventional solutions. There are usually two ways to solve category imbalance in related technologies, namely resampling and reweighting.
[0045] Among them, the resampling method either undersamples the majority class, that is, deletes some samples; or oversamples the minority class, that is, adds duplicate samples; or both are performed at the same time to directly change the number of training samples. However, when learning features through convolutional neural networks (CNN), the resampling method may introduce a large number of duplicate samples, increase training time, and oversampling is prone to overfitting, and undersampling may lose sample data that is helpful for feature learning.
[0046] The reweighting method starts from the classification loss function, assigns a relatively high weight to the minority class loss, and balances the losses of each class. The reweighting series of methods has gradually become the mainstream method for solving class imbalance. For example, LIN et al. proposed the FocalLoss algorithm to solve the problem of imbalanced foreground and background classes in single-stage target detection. It adds two weight parameters, one weight parameter balances the imbalance of positive and negative samples, and the other weight parameter balances the imbalance of difficult and easy classification samples. The team of CHEN et al. has shown through a large number of experiments that the use of FocalLoss in the region proposal network (RPN) can alleviate the overfitting problem caused by class imbalance. CUI et al. believe that there is information overlap between samples, propose the effective number of samples for a class, and then propose class-balanced loss (CBLoss). TAN et al. proposed equalization loss (EQLLoss) based on back-propagation gradient, introduced weights for each sample, reduced the impact of negative samples on minority classes, and thus protected the learning of minority classes from being affected.
[0047] However, this application has been verified through experiments that the above reweighting method is not ideal when it is directly applied to the traffic sign dataset. Therefore, this application solves the problem of sample imbalance by designing a classification loss function that is more suitable for the traffic sign set. It can be understood that the loss function of the detection model is not only the classification loss function, but also other loss functions. Since only the classification loss function is improved, only the classification loss function is explained.
[0048] It is known through statistics that the number of traffic signs in the four categories of unspeed, livestock, no pass, and l_lane in the traffic sign dataset is much smaller than that in other categories, and there is a serious class imbalance. During the training process, the gradients of the minority categories are overwhelmed by the gradients of the majority categories, resulting in poor training results. Secondly, since the classification loss used by the basic network YOLOv5 used in this application is a binary cross entropy loss, it is difficult to solve the problem caused by sample imbalance, and it is not friendly to the detection effect of traffic signs of minority categories.
[0049] Based on this situation, this application combines the basic idea of reweighted loss, that is, assigning different weights to training samples, and directly determines the sample weight based on the number of categories, such as the inverse of the class frequency, which can be recorded as:
[0050]
[0051] in, L WBCE is the sample weight, C is the number of traffic sign categories, N i For the i The number of samples of the traffic sign type; L BCE is the binary cross entropy loss for traffic signs.
[0052] Among them, the binary cross entropy loss as follows:
[0053]
[0054] In the above formula, is the number of samples of all traffic signs, For the i The true category of samples; For the i The predicted category of samples.
[0055] In view of the problems of weak stability, serious accuracy fluctuation and unsatisfactory detection effect of the current reweighted series loss function for solving category imbalance, this application proposes a square root reweighted category loss (SR-WBCELoss) based on the reweighted loss (weightbinarycrossentroryloss, WBCELoss) based on YOLOv5 as the benchmark network, thereby improving the detection effect of traffic signs with fewer categories.
[0056] By using this classification loss function, TS-YOLOv5 can pay more attention to minority categories (such as the four types of traffic signs: speed limit release, livestock warning, no passage, and keep left), and improve the recognition accuracy of minority traffic signs. L SR-WBCE It can be written as follows:
[0057]
[0058]
[0059] In the above formula, C is the number of traffic sign categories, N C For the C+ The number of samples of Class 1 traffic signs, L BCE is the binary cross entropy loss for traffic signs.
[0060] Based on all loss functions of the detection model, Figure 3 A schematic flow chart of a training method of TS-YOLOv5 provided in the present application is shown, and the training method may include:
[0061] Step 310: The electronic device performs a data enhancement operation on each training sample in the pre-constructed training set.
[0062] In order to enrich the data samples and train a robust TS-YOLOv5, the electronic device can perform data augmentation on each data sample in the training set after obtaining the training set. Data augmentation is a technique used to improve the generalization ability of a model. It creates new data by adding artificial noise and / or transformation to the original data set. The reason for performing data augmentation on sample data is that data augmentation has many benefits, which are listed as follows:
[0063] 1. Expand the amount of sample data: Data enhancement can generate more training samples, thereby effectively expanding the amount of sample data.
[0064] 2. Improve model performance: Data augmentation can improve model performance by increasing the diversity of sample data. For example, by rotating and translating images, the model's ability to detect traffic signs at different angles and locations can be increased.
[0065] 3. Reduce the risk of overfitting: Data augmentation can introduce noise and changes, thereby reducing the risk of the model overfitting the training data, helping to improve the generalization ability of the model and making it better adapt to new data and tasks.
[0066] 4. Capturing more complex patterns: Through data enhancement, more complex patterns and relationships can be captured. For example, in image classification tasks, by rotating and scaling the image, the changes in different perspectives and sizes in the image can be captured.
[0067] 5. Enhance the robustness of the model: Data augmentation can enhance the robustness of the model by introducing noise and variation. This allows the model to perform traffic sign detection stably and accurately in the face of noise and interference.
[0068] 6. Improve computational efficiency: Data augmentation can enhance data online or offline without increasing the size of the training dataset. This helps improve computational efficiency and makes the training process faster and more efficient.
[0069] In summary, data augmentation operations can improve the performance, generalization ability, and robustness of the model while reducing overfitting and computational costs and capturing more complex patterns and relationships.
[0070] Data enhancement can be divided into online enhancement and offline enhancement. Among them, online enhancement is a data enhancement operation performed before the sample data is input into the model. Online enhancement increases the diversity of data by performing random enhancement operations (such as flipping, rotating, etc.) on the data. This enhancement method is suitable for sample data with a small amount. Offline enhancement is to preprocess the set of collected sample data, and increase the number and diversity of sample data through a series of data transformation operations. This enhancement method is suitable for sample data with a large amount. The specific data enhancement operation to be selected can be determined according to actual needs. The number of sample data used in this application is small, and the enhancement operation of online enhancement is preferred.
[0071] For the task of detecting traffic signs, this application uses color perturbation HSV, perspective transformations such as rotation and translation, and mosaic data enhancement operations to increase the diversity of training samples. It is particularly noteworthy that mosaic data enhancement can solve the "small target problem" in network training to a certain extent by splicing and scaling four randomly selected images. In the actual detection process, most traffic signs are small targets, so the use of mosaic data enhancement can effectively improve the model accuracy and the recall rate of small traffic sign detection.
[0072] Preferably, due to the particularity of traffic signs, the data augmentation operation does not include left-right flipping and up-down flipping. This is because if the left-right flipping data augmentation operation is performed on the two samples of turn left (turn_l) and turn right (turn_r), the category attributes of the samples will be directly changed, which is easy to confuse the model and cause model detection errors.
[0073] To facilitate training and verification, all sample data collected can be divided into two sets according to a certain ratio. For example, the training data and verification data can be divided into two sets at a ratio of 8:2, and then the training sample set is enhanced online to train a robust detection model; while the verification sample set is not enhanced and is only used to verify the performance of the detection model.
[0074] Step 320: The electronic device iterates the pre-built detection model through the training sample set until the pre-built detection model converges.
[0075] The pre-built detection model is TS-YOLOv5. The training sample set is input into TS-YOLOv5, and TS-YOLOv5 is continuously iterated to make TS-YOLOv5 converge, that is, TS-YOLOv5 can accurately detect traffic signs. This process is achieved by continuously optimizing the model parameters of TS-YOLOv5, adjusting the weights and biases, and minimizing the loss function using the back propagation algorithm.
[0076] In the iterative process, TS-YOLOv5 gradually improves the detection accuracy of traffic signs by learning the features in the training sample set. By comparing the predicted labels with the true labels, TS-YOLOv5 continuously adjusts its own parameters to better capture key features and reduce detection errors. This iterative process is always performed on the training set, and is continuously evaluated and verified on the validation set until TS-YOLOv5 converges to a stable state, that is, TS-YOLOv5 reaches a satisfactory level of detection of traffic signs.
[0077] In some embodiments, after TS-YOLOv5 is trained based on the training set each time, in order to accurately evaluate the performance of TS-YOLOv5, it can be evaluated through the validation set and the evaluation result of this time can be obtained. When the evaluation result meets the conditions, TS-YOLOv5 has converged. In order to be able to use the robust TS-YOLOv5 as a detection model, even if it is determined by the evaluation results that TS-YOLOv5 has converged, it can continue to optimize and iterate to obtain more different versions of TS-YOLOv5 for selection. Finally, the different versions of TS-YOLOv5 that have converged are compared, and the TS-YOLOv5 with the best evaluation result is used as the detection model that has been trained.
[0078] Ideally, the trained TS-YOLOv5 has a high generalization ability and can accurately identify traffic signs on unlearned data sets. This provides a reliable foundation for the automatic detection of traffic signs, enabling it to perform well in various scenarios.
[0079] In some embodiments, the performance of TS-YOLOv5 on the validation set can be evaluated according to preset conditions. For example, these preset conditions may include performance indicators such as the detection accuracy and recall rate of the model for traffic signs. If the performance of TS-YOLOv5 on the validation set reaches the best value of these preset conditions, the version of TS-YOLOv5 can be used as a candidate version of the trained model. After obtaining multiple candidate versions, the TS-YOLOv5 with the best performance can be selected for subsequent application and deployment.
[0080] If you find that the model performs poorly on the validation set, you may need to review various aspects of the training process. Perhaps you need more training data, adjust the model architecture, or try different hyperparameter configurations. Overfitting problems may also need further treatment, such as introducing stronger regularization methods to ensure that the model better adapts to unknown data.
[0081] This TS-YOLOv5 can be applied in practical scenarios, such as the field of intelligent driving. Its high generalization ability and accuracy provide a reliable solution for the automatic detection of traffic signs.
[0082] In some embodiments, in order to accurately evaluate the model performance, the present embodiment uses the following evaluation indicators:
[0083] Precision (P), also known as the precision rate, refers to the proportion of correct positive predictions to all positive predictions, as shown in the formula:
[0084]
[0085] Recall (R), also known as recall rate, refers to the proportion of correctly predicted positives to all actual positives, as shown in the formula:
[0086]
[0087] The average precision (AP) is calculated from the precision and recall. A line graph of the precision is drawn based on the recall value, and the area under the line is calculated, as shown in the formula:
[0088]
[0089] The mean average precision (mAP) refers to the average of the average precision AP of C different categories, as shown in the formula:
[0090]
[0091] In some embodiments, based on the trained TS-YOLOv5, Figure 4 A schematic flow chart of a traffic sign detection method provided by the present application is shown, and the traffic sign detection method includes:
[0092] Step 410: The electronic device extracts features of the image to be processed based on the backbone network of the pre-trained detection model to obtain image features.
[0093] The electronic device uses the backbone network of TS-YOLOv5 to extract features from the image to be processed. The backbone network is usually composed of CNN, which is used to capture high-level features in the image. That is, the purpose of this step is to obtain a high-level representation of the image to be processed through the backbone network of TS-YOLOv5 for subsequent processing.
[0094] Step 420: The electronic device fuses the image features based on the neck network provided with the residual fusion attention module to obtain fused features.
[0095] After obtaining the image features, the electronic device can fuse the image features through the neck network equipped with the residual fusion attention module, so that the neck network can better distinguish the importance of the features, fuse the image features with higher discrimination, and generate a more comprehensive feature representation, namely, the fused feature. The fused feature has stronger expression ability and helps the model to accurately detect different types of traffic signs.
[0096] Step 430: The electronic device detects the fused features based on the detection module to obtain a detection result of the traffic sign in the image to be processed.
[0097] The detection module generally includes a neural network structure for target detection, which can locate and identify a specific category of targets, i.e., traffic signs, in an image. Thus, the electronic device can output the detection results of the traffic signs in the processed image through the detection module, such as the location and category information of the traffic signs.
[0098] The electronic device of the embodiment of the present application fully fuses the image features extracted by the backbone network of the detection model through the neck network of TS-YOLOv5 to obtain a more discriminative comprehensive feature identification, namely, a fused feature; the fused feature is detected by the detection module, which can accurately and quickly distinguish different traffic signs in the image to be processed, thereby improving the accuracy of the traffic sign detection results, and making the detection model more robust.
[0099] In some embodiments, it can be seen from the embodiments of the network structure improvement part that there are at least three scales of image features; the neck network includes at least three feature fusion networks, and each feature fusion network is provided with a residual fusion attention module; each scale of image features corresponds to a feature fusion network. Based on this, step 420 specifically includes:
[0100] Step 421: For the image features at each scale, the electronic device fuses the image features at different levels at the current scale based on the corresponding feature fusion network to obtain the fused features corresponding to the current scale.
[0101] In image processing, scale refers to the size or spatial resolution of traffic signs in an image. Different scales may correspond to traffic signs at different distances or resolutions. Therefore, image features at each scale are processed in order to accurately detect traffic signs at various scales.
[0102] For each scale, a specific feature fusion network is used. This network may include a residual fusion attention mechanism to ensure that important information in the image is better captured during the fusion process. Each feature fusion network is designed to fuse image features of different levels at the current scale.
[0103] The image features at different levels refer to the image features obtained by different convolutional layers in the backbone network. For scale k, upsampling the image features at different levels to scale k for fusion can make the fusion features at scale k more expressive.
[0104] In some embodiments, assuming that there are m scales of the image feature, where m is greater than or equal to 3, for each scale of the image feature, step 421 may specifically include:
[0105] Step 421: for the first image feature at the first scale, concatenate the first image feature with the first deep feature at the same scale, and input the concatenation result into the first feature fusion module for feature fusion to obtain the first fused feature at the first scale; the first deep feature includes feature information from the second to the mth scales.
[0106] See also Figure 5 , if m=3, then for the first image feature of the first scale, it is first spliced with the first deep feature. Among them, the third image feature of the third scale after upsampling is spliced with the second image feature of the second scale to obtain the first spliced feature; the first spliced feature is fused by the second feature fusion module and then downsampled again to obtain the first deep feature. The first image feature and the first deep feature are at the same scale and can be directly spliced along the depth direction.
[0107] For example, assume that the shape of the first image feature is (H, W, C1), where H represents height, W represents width, and C1 represents depth (number of channels), and the shape of the first deep feature is (H, W, C2), where C2 represents depth. When splicing, we splice these two features together in the depth dimension, and the shape of the spliced feature is (H, W, C1+C2).
[0108] It is understandable that the splicing operations mentioned later all have this meaning and will not be described in detail in the following text.
[0109] The splicing result is input into the first feature fusion module for feature fusion to obtain the first fused feature at the first scale. If the shape of the input image to be processed is H×W×C, then after step 421, the shape of the output first fused feature is H / 8×W / 8×(4+1+C).
[0110] Step 422: for the k-th image feature at the k-th scale, concatenate the k-th image feature with the k-th deep feature at the same scale, input the concatenation result into the k-th feature fusion module, concatenate the fusion result with the k-th fused feature after convolution and input the concatenation result into the k+1-th feature fusion module to obtain the k-th fused feature at the k-th scale; 2≤k≤m-1; the k-th deep feature includes feature information from the k+1-th to the m-th scales.
[0111] When m=3, k=2. For the second image feature of the second scale, it is first combined with the second deep feature. Among them, the third image feature of the third scale after upsampling is the second deep feature. After splicing with the second image feature, the corresponding splicing result can be input into the second feature fusion module to output the fusion result. The fusion result can be spliced with the first fusion feature after downsampling to input the third feature fusion module to obtain the second fusion feature. Among them, the reason for downsampling the first fusion feature is to allow the fusion result to be spliced with the first fusion feature at the same scale.
[0112] Step 423: for the mth image feature of the mth scale, concatenate the mth image feature with the m-1th fusion feature after convolution, and input the concatenation result into the 2m-2th fusion module for fusion to obtain the mth fusion feature of the mth scale.
[0113] When m=3, the third image feature can be directly concatenated with the downsampled second fusion feature, and the concatenated result is input into the fourth fusion module for fusion to obtain the third fusion feature at the third scale.
[0114] In the embodiment of the present application, the fusion features at each scale bring together feature information at different levels, which helps the model to better understand the local and global features in the image, helps to utilize feature information at different depths to obtain comprehensive features with stronger expressive power, and thus helps to improve the model's ability to detect traffic signs of different sizes.
[0115] In some embodiments, the attention modules in the residual fusion attention module include a coordinate attention module, a spatial attention module and a channel attention module, and the coordinate attention module, the spatial attention module and the channel attention module are connected through a residual structure.
[0116] Among them, the coordinate attention mechanism is a self-attention mechanism that enhances the model's attention to features at different locations by learning the relationship between traffic signs in spatial coordinates. Compared with the traditional attention mechanism, the coordinate attention mechanism not only considers the horizontal and vertical relationship of features on the graph, but also introduces spatial coordinate information, allowing the model to pay more attention to features at different locations.
[0117] The core idea of the coordinate attention mechanism is to encode the position information into attention weights, thereby affecting the final output. It maps the spatial coordinates into a pair of attention weights, one along the horizontal direction and one along the vertical direction. This pair of weights can be applied separately to each position in the input feature map to enhance the model's attention to features at different positions.
[0118] The implementation process of the coordinate attention mechanism is relatively simple, and it can be flexibly inserted into classic mobile networks such as MobileNetV2, MobileNeXt, and EfficientNet, with almost no computational overhead. A large number of experiments have shown that the coordinate attention mechanism is not only beneficial for ImageNet classification tasks, but also performs better in downstream tasks such as object detection and semantic segmentation.
[0119] Embedding position information into channel attention proposes a novel mobile network attention mechanism, namely Coordinate Attention, whose network structure can be found in Figure 6 Among them, Coordinate Attention encodes channel relationships and long-distance relationships based on two steps: Coordinate Information Embedding and Coordinate Attention Generation.
[0120] (1)Coordinate Information Embedding
[0121] Channel Attention often uses global pooling operations to encode global spatial information, compressing global information into a scalar, which makes it difficult to retain important spatial information. To this end, this embodiment transforms the global pooling operation into an encoding operation of two 1-dimensional vectors. Input X , using the pooling kernel ( H, 1) and (1, W ) respectively encode the horizontal features and the vertical features. n The output of the dimension feature is:
[0122]
[0123]
[0124] in, It uses the pooling kernel ( H, 1) Encode the features obtained horizontally, It uses the pooling kernel (1, W ) encodes the features obtained in the vertical and horizontal directions. Integrate features from different directions and output a pair of direction-aware feature maps. Compared with the compression method of global pooling, this encoding operation allows the attention block to capture long-distance relationships in a single direction while retaining spatial information in another direction, helping the model to locate traffic signs more accurately.
[0125] (2)Coordinate Attention Generation
[0126] In order to better utilize the above-mentioned Coordinate Attention, this application proposes a matching Coordinate Attention Generation operation, which is designed mainly based on three criteria, namely, being simple and lightweight enough, being able to fully utilize the extracted position information, and being able to equally efficiently handle the relationship between channels.
[0127] Based on this criterion, the horizontal and vertical coding features are first spliced, and the splicing results are sequentially passed through Convolution, BN and nonlinear activation functions are used to transform features:
[0128]
[0129] in, It is an intermediate feature that includes horizontal and vertical spatial information. r is the reduction factor. Here, the features in the two directions are not intensively fused. The main purpose of concatenate is to perform a unified BN operation. f Divided into two separate features and , use another two 1×1 convolutions and sigmoid functions to transform the features so that their dimensions are the same as the input X Consistent:
[0130]
[0131]
[0132] The output and Merge into a weight matrix for calculating the coordinate attention block output:
[0133]
[0134] Among them, the biggest difference between Coordinate Attention Generation and se block is that each weight of Coordinate Attention Generation contains inter-channel information, horizontal spatial information and vertical spatial information, which can help the model locate target information more accurately and enhance detection capabilities.
[0135] In this embodiment, since traffic signs of the same category have the same shape and size and are installed at approximately the same height, the above-mentioned network structure can focus on the coordinate position of the traffic signs in the picture, so that the model can better understand the location information of the traffic signs and show better performance in the detection task.
[0136] In some embodiments, based on Coordinate Attention, channel attention and spatial attention can also be introduced in a residual manner to extract important and effective features to improve the accuracy and robustness of the model. Figure 7 .
[0137] Among them, for the channel attention mechanism, on the one hand, it can better explore the relationship between channels, focus on relevant information and ignore irrelevant information, thereby improving model performance; on the other hand, it can well construct sequence data with variable length, further enhancing its ability to capture long-range dependency information, reducing the depth of the hierarchy while effectively improving the accuracy.
[0138] For input X , where the maximum pooling and average pooling operations are used to compress and extract features from the spatial dimension, then the n The output of the dimension feature is:
[0139]
[0140] Two compressed effective features are extracted through the above formula. For each effective feature, 1×1 convolution, nonlinear activation and 1×1 convolution are performed for feature transformation. The two output results are added together to obtain the following formula:
[0141] The formula is activated by the sigmoid function to obtain the importance weights of different channels.
[0142]
[0143] For the spatial attention mechanism, it can not only more accurately locate and weight the regions of interest in the feature map and extract more discriminative features, but also help the detection model ignore irrelevant information, so that the model can focus on important features and regions.
[0144] Similarly, for the input X , performing maximum pooling and average pooling operations on the channel dimension of each spatial position respectively, can focus attention on a certain area. That is, the spatial position ( i,j ) will output:
[0145]
[0146] First, concatenate the output results of the above two formulas, and then use 1×1 convolution for feature transformation:
[0147]
[0148] The formula is activated by the sigmoid function to obtain the importance weights of different regions in space.
[0149] The output of the improved residual fusion attention module is:
[0150]
[0151] in, x n ( i,j ) are input features, is the output of the spatial attention module, is the output of the channel attention module, is the output of the coordinate attention module, It is the output result of the improved residual fusion attention module.
[0152] In this embodiment, the residual attention module introduces residual connections, which enables the model to pay attention to more feature information, thereby improving the robustness of the model. In addition, residual connections can also help the network learn features better, avoid overfitting, and increase the generalization ability of the model. The residual attention mechanism has better performance than the attention mechanism. Based on this, on the basis of the coordinate attention mechanism Coordinate Attention, channel attention and spatial attention are introduced in a residual manner. By multiplying the weight matrices of the three, more important and more effective features will be obtained to improve the accuracy and robustness of the model.
[0153] In some embodiments, the residual fusion attention module processes each input feature in a similar manner, but the output results are different due to the difference in input features. X The residual fusion attention module takes the input X The processing steps include:
[0154] Step A1: Input X Input the coordinate attention module, spatial attention module and channel attention module respectively to obtain the output results corresponding to each attention module.
[0155] Step A2: re-weight each output result to obtain the initial fusion feature.
[0156] Step A3: Concatenate the initial fused features with the input features to obtain fused features corresponding to the input features.
[0157] First, for the input X , and input them into three attention modules respectively, namely the coordinate attention module, the spatial attention module and the channel attention module. Each attention module produces corresponding output results. These output results contain the information that the input features are emphasized in terms of position, spatial area and channel. Secondly, reweight the output results of each attention module. The purpose of reweighting is to adjust the output weights of each attention module so that the model can better pay attention to the information learned in each attention module, which helps to optimize the fusion process, make the contribution of each attention module more balanced, and improve the expression ability of the fusion features. Finally, the output result after the reweighting operation is compared with the input X To splice. The input X The corresponding fusion feature contains the information adjusted and re-weighted by various attention mechanisms and has stronger expressive power.
[0158] In this embodiment, different attention mechanisms are used to focus on and adjust different aspects of the input features to obtain more informative and expressive fusion features. The fusion features help improve the detection capability of the model and make the model more robust.
[0159] In some embodiments, for fusion features of different scales, in order to simplify the network structure, speed up the model convergence speed, and improve the detection accuracy, the detection module includes at least 3 detection heads, each detection head corresponds to each scale. The above step 430 specifically includes:
[0160] Step 431: For the fusion features of each scale, detection is performed based on the corresponding detection head to obtain the detection result corresponding to the current scale.
[0161] Step 432: splice the detection results corresponding to each scale to obtain the recognition result of the traffic sign in the image to be processed.
[0162] Taking three scales as an example, the detection module includes three detection heads. The first, second and third fusion networks are input into the corresponding detection heads in turn, and three detection results corresponding to each scale can be obtained. The three detection results are spliced together to obtain the recognition result of the traffic sign in the image to be processed. If the image to be processed contains traffic signs of large, medium and small scales, the detection boxes and category information of the traffic signs of these three scales will also appear in the recognition result. For example, the network structure of a single detection head is as follows: Figure 8 shown.
[0163] See also Fig. 9 Traffic signs can include 19 categories, namely electronic eye, minimum speed limit, maximum speed limit, speed limit release, danger, obstacles, livestock, detour, turn left, turn right, no entry, no pass, crossing, temporary construction sign, pedestrian ban, no honking, turn around, drive on the right lane, and drive on the left lane. The 19 types of traffic signs are detected by the optimal detection models TS-YOLOv5 and YOLOv5 respectively. The optimal detection model TS-YOLOv5 used in this application has the following improvements compared to YOLOv5:
[0164] (1) Compared with YOLOv5, TS-YOLOv5 improves precision P by 8.1%, recall R by 4.0%, and mAP by 4.5%. Obviously, the improved TS-YOLOv5 network can significantly improve the detection and accuracy of traffic signs.
[0165] (2) For YOLOv5, the detection accuracy of the three categories of electronic eye, no pass, and driving on the left lane is not high, which are difficult categories. The improved TS-YOLOv5 has increased mAP by 6.3%, 22.7%, and 32.6% in these three categories, among which the no pass and driving on the left lane categories have been greatly improved.
[0166] (3) Compared with YOLOv5, TS-YOLOv5 can improve the detection accuracy of small objects, and the problem of category imbalance is better solved.
[0167] In addition, on a sunny day, TS-YOLOv5 can detect small targets better than YOLOv5; on a rainy day, the poor lighting conditions cause low recognition of traffic signs in the image and a blurred background, making the detection task more difficult. Under such conditions, TS-YOLOv5 shows stronger robustness and adaptability than YOLOv5.
[0168] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0169] Corresponding to the traffic sign detection method of the above embodiment, Fig.10 A structural block diagram of a traffic sign detection device 10 provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0170] Reference Fig.10 , the traffic sign detection device 10 comprises:
[0171] An extraction module 101 is used to extract features of an image to be processed based on a backbone network of a pre-trained detection model to obtain image features;
[0172] A fusion module 102, configured to fuse image features based on a neck network provided with a residual fusion attention module to obtain fusion features; the residual fusion attention module includes at least two attention modules, and each attention module is connected by a residual structure;
[0173] The detection module 103 is used to detect the fused features based on the detection module to obtain the detection result of the traffic sign in the image to be processed.
[0174] Optionally, there are at least three scales of image features; the neck network includes at least three feature fusion networks, and each feature fusion network is provided with a residual fusion attention module; each scale of image features corresponds to a feature fusion network, and the fusion module 102 can be used to: for each scale of image features, based on the corresponding feature fusion network, fuse image features of different levels at the current scale to obtain fused features corresponding to the current scale.
[0175] Optionally, there are m scales of image features, where m is greater than or equal to 3, and the fusion module 92 is specifically used for:
[0176] For the first image feature at the first scale, the first image feature is spliced with the first deep feature at the same scale, and the splicing result is input into the first feature fusion module for feature fusion to obtain the first fused feature at the first scale; the first deep feature includes feature information of the second to mth scales;
[0177] For the kth image feature at the kth scale, the kth image feature is concatenated with the kth deep feature at the same scale, and the concatenated result is input into the kth feature fusion module, and the fusion result is concatenated with the kth fused feature after convolution and then input into the k+1th feature fusion module to obtain the kth fused feature at the kth scale; 2≤k≤m-1; the kth deep feature includes the feature information of the k+1th to mth scales;
[0178] For the mth image feature of the mth scale, the mth image feature is concatenated with the m-1th fusion feature after convolution, and the concatenated result is input into the 2m-2th fusion module for fusion to obtain the mth fusion feature of the mth scale.
[0179] Optionally, the detection module includes at least three detection heads, each detection head corresponding to each scale one by one; the above detection module 102 is specifically used for:
[0180] For each scale of fusion features, detection is performed based on the corresponding detection head to obtain the detection result corresponding to the current scale;
[0181] The detection results corresponding to each scale are spliced to obtain the recognition result of the traffic sign in the image to be processed.
[0182] Optionally, the attention module in the residual fusion attention module includes a coordinate attention module, a spatial attention module and a channel attention module, and the coordinate attention module, the spatial attention module and the channel attention module are connected through a residual structure; the fusion module includes a fusion unit, and the fusion unit is specifically used for:
[0183] For any input feature of the input residual fusion attention module, the input feature is input into the coordinate attention module, the spatial attention module and the channel attention module respectively to obtain the output results corresponding to each attention module;
[0184] Perform re-weighting operation on each output result to obtain the initial fusion feature;
[0185] Concatenate the initial fused features with the input features to obtain the fused features corresponding to the input features.
[0186] Optionally, the detection device 10 may also include a training module, and the training module is specifically used for:
[0187] Before the backbone network based on the pre-trained recognition model extracts features from the processed image,
[0188] Perform data augmentation operations on each training sample in the pre-constructed training set; the data augmentation operations do not include left-right flipping operations and up-down flipping operations;
[0189] The pre-built detection model is iterated through the training sample set until the pre-built detection model converges, thereby obtaining a trained detection model.
[0190] Optionally, the classification loss function of the pre-built recognition model is a class imbalance loss function, and the class imbalance loss function is as follows:
[0191]
[0192]
[0193] in, L SR-WBCE is the class imbalance loss; C is the number of traffic sign categories, N C For the C+ The number of samples of Class 1 traffic signs, L BCE is the binary cross entropy loss for traffic signs; n is the number of samples of all traffic signs; For the i The true labeled category of each sample; For the i The predicted category of samples.
[0194] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0195] Fig.11 This is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present application. Fig.11 As shown, the electronic device 11 of this embodiment includes: at least one processor 110 ( Fig.11 Only one is shown in the figure) a processor, a memory 111, and a computer program 112 stored in the memory 111 and executable on at least one processor 110. When the processor 110 executes the computer program 112, the steps in any of the above-mentioned traffic sign detection method embodiments are implemented, for example Figure 4 Steps 410-430 are shown.
[0196] The processor 110 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. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0197] In some embodiments, the memory 111 may be an internal storage unit of the electronic device 11, such as a hard disk or memory of the electronic device 11. In other embodiments, the memory 111 may also be an external storage device of the electronic device 11, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device 11.
[0198] Furthermore, the memory 111 may include both an internal storage unit of the electronic device 11 and an external storage device. The memory 111 is used to store operating devices, applications, boot loaders, data, and other programs, such as program codes of computer programs, etc. The memory 101 may also be used to temporarily store data that has been output or is to be output.
[0199] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0200] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0201] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0202] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0203] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0204] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0205] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0206] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0207] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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 make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for detecting a traffic sign, characterized in that: include: The backbone network of the pre-trained detection model extracts features from the image to be processed to obtain image features; The image features are fused based on a neck network provided with a residual fusion attention module to obtain fusion features; the residual fusion attention module includes at least two attention modules, and each of the attention modules is connected by a residual structure; Detecting the fused features based on a detection module to obtain a detection result of a traffic sign in the image to be processed; The image features have at least three scales; the neck network includes at least three feature fusion networks, and each feature fusion network is provided with the residual fusion attention module; the image features of each scale correspond to a feature fusion network; the image features are fused based on the neck network provided with the residual fusion attention module to obtain fused features, including: For the image features of each scale, image features of different levels at the current scale are fused based on the corresponding feature fusion network to obtain fused features corresponding to the current scale; The attention modules in the residual fusion attention module include a coordinate attention module, a spatial attention module and a channel attention module, and the coordinate attention module, the spatial attention module and the channel attention module are connected through a residual structure; For any input feature input into the residual fusion attention module, the input feature is respectively input into the coordinate attention module, the spatial attention module and the channel attention module to obtain the output results corresponding to each of the attention modules; Perform re-weighting operation on each output result to obtain the initial fusion feature; The initial fused feature is concatenated with the input feature to obtain a fused feature corresponding to the input feature.
2. The method for detecting a traffic sign according to claim 1, characterized in that: There are m scales of the image features, where m is greater than or equal to 3. For the image features of each scale, image features of different levels at the current scale are fused based on the corresponding feature fusion network to obtain fused features corresponding to the current scale, including: For the first image feature at the first scale, the first image feature is spliced with the first deep feature at the same scale, and the splicing result is input into the first feature fusion module for feature fusion to obtain the first fused feature at the first scale; the first deep feature includes feature information from the second to the mth scales; For the kth image feature at the kth scale, the kth image feature is spliced with the kth deep feature at the same scale, and the splicing result is input into the kth feature fusion module, and the fusion result is spliced with the k-1th fusion feature after convolution and then input into the k+1th feature fusion module to obtain the kth fusion feature at the kth scale; 2≤k≤m-1; the kth deep feature includes feature information from the k+1th to the mth scales; For the mth image feature of the mth scale, the mth image feature is spliced with the m-1th fusion feature after convolution, and the splicing result is input into the 2m-2th fusion module for fusion to obtain the mth fusion feature of the mth scale.
3. The method for detecting a traffic sign according to claim 1, characterized in that: The detection module includes at least three detection heads, each of which corresponds to each of the scales; the detection module detects the fusion features to obtain the detection result of the traffic sign in the image to be processed, including: For the fusion features of each scale, detection is performed based on the corresponding detection head to obtain the detection result corresponding to the current scale; The detection results corresponding to each scale are spliced to obtain the detection result of the traffic sign in the image to be processed.
4. The method for detecting a traffic sign according to any one of claims 1 to 3, characterized in that: Before the backbone network based on the pre-trained detection model extracts features from the processed image, it also includes: Performing a data augmentation operation on each training sample in the pre-constructed training set; the data augmentation operation does not include a left-right flip operation and an up-down flip operation; The pre-built detection model is iterated through the training set until the pre-built detection model converges, thereby obtaining a trained detection model.
5. The method for detecting a traffic sign according to claim 4, characterized in that: The classification loss function of the pre-built detection model is a class imbalance loss function, and the class imbalance loss function is as follows: Among them, the is the class imbalance loss; C is the number of traffic sign categories, For the first (1,2,…, C ) type of traffic sign samples; is the binary cross entropy loss of traffic signs; n is the number of samples of all traffic signs; For the i The true labeled categories of samples; For the i The predicted category of samples.
6. A traffic sign detection device, characterized in that: include: An extraction module is used to extract features from the image to be processed based on the backbone network of the pre-trained detection model to obtain image features; A fusion module, used for fusing the image features based on a neck network provided with a residual fusion attention module to obtain a fusion feature; the residual fusion attention module includes at least two attention modules, and each of the attention modules is connected by a residual structure; the attention module includes a coordinate attention module; A detection module, used for detecting the fusion feature based on the detection module to obtain a detection result of the traffic sign in the image to be processed; The image features have at least three scales; the neck network includes at least three feature fusion networks, and each feature fusion network is provided with the residual fusion attention module; the image features of each scale correspond to a feature fusion network; the fusion module is specifically used for fusing the image features of different levels at the current scale based on the corresponding feature fusion network for the image features of each scale to obtain the fusion features corresponding to the current scale; The attention modules in the residual fusion attention module include a coordinate attention module, a spatial attention module and a channel attention module, and the coordinate attention module, the spatial attention module and the channel attention module are connected through a residual structure; the fusion module includes a fusion unit, and the fusion unit is used to: For any input feature input into the residual fusion attention module, the input feature is respectively input into the coordinate attention module, the spatial attention module and the channel attention module to obtain the output results corresponding to each of the attention modules; Perform re-weighting operation on each output result to obtain the initial fusion feature; The initial fused feature is concatenated with the input feature to obtain a fused feature corresponding to the input feature.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the traffic sign detection method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the traffic sign detection method according to any one of claims 1 to 5 is implemented.
