Traffic sign detection method based on normalized attention mechanism YOLOv7

By introducing the FreLU activation function and normalized attention mechanism into the YOLOv7 network, the traffic sign detection method is improved, which solves the problem of low detection accuracy in complex backgrounds and achieves higher detection accuracy and robustness.

CN116740674BActive Publication Date: 2025-09-26XIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310623271.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-30
Publication Date
2025-09-26
Estimated Expiration
2043-05-30

AI Technical Summary

Technical Problem

The existing traffic sign detection method based on YOLOv7 has low detection accuracy in complex backgrounds or severe weather conditions.

Method used

The normalized attention mechanism YOLOv7 (NAM-YOLOv7) is adopted. By introducing the FreLU activation function in the backbone module and the neck module, and adding the normalized attention mechanism in the head module, including the channel and spatial attention mechanisms, the feature extraction and detection accuracy are improved.

Benefits of technology

The precision and accuracy of traffic sign detection are improved in complex backgrounds, which can better capture the fine features and long-distance dependencies of the target and enhance the robustness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116740674B_ABST
    Figure CN116740674B_ABST
Patent Text Reader

Abstract

The present invention discloses a traffic sign detection method based on the normalized attention mechanism YOLOv7, which is specifically as follows: Step 1, obtain a series of traffic sign images taken during autonomous driving; Step 2, crop or pad the series of traffic sign images obtained in Step 1 into fixed-size images and convert them into tensors; Step 3, feed the tensors obtained in Step 2 into the improved backbone module and neck module for feature extraction; Step 4, based on the improvement of the original YOLOv7 network in Step 3, further improve the original head module and feed the feature tensor obtained in Step 3 into the improved head module; Step 5, feed the feature tensor obtained in Step 4 into the REPConv layer of the improved head module, and then pass it through the inspection head to output the traffic sign detection result. This method solves the problem of low traffic sign detection accuracy under complex backgrounds in the existing technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing methods, and specifically relates to a traffic sign detection method based on the normalization-based attention mechanism YOLOv7 (Normalization-based Attention, NAM-YOLOv7). Background Art

[0002] Traffic sign detection technology, a crucial component of autonomous driving, helps drivers accurately and efficiently identify traffic signs, effectively preventing driver errors and reducing fatigue, thereby ensuring road safety. In real-world scenarios, the ability to detect traffic signs promptly and accurately is crucial for autonomous driving systems.

[0003] In recent years, many traffic sign detection methods based on YOLOv7 have emerged, achieving excellent detection results. However, these methods often suffer from low accuracy when detecting traffic signs in complex backgrounds or in windy, rainy, or foggy weather conditions. Summary of the Invention

[0004] The present invention provides a traffic sign detection method based on the normalized attention mechanism YOLOv7, which solves the problem of low traffic sign detection accuracy under complex background in the prior art.

[0005] The technical solution adopted by the present invention is a traffic sign detection method based on the normalized attention mechanism YOLOv7, which is as follows:

[0006] Step 1: Acquire a series of images of traffic signs taken during autonomous driving;

[0007] Step 2: crop or pad the series of traffic sign images obtained in step 1 into fixed-size images and convert them all into tensors;

[0008] Step 3: Improve the backbone module and neck module in the original YOLOv7 network, and send the tensor obtained in step 2 to the improved backbone module and neck module for feature extraction;

[0009] Step 4: Based on the improvement of the original YOLOv7 network in step 3, continue to improve the original head module, and send the feature tensor obtained in step 3 to the improved head module;

[0010] In step 5, the feature tensor obtained in step 4 is fed into the REPConv layer of the improved head module, and then passes through the inspection head to output the traffic sign detection result.

[0011] The present invention is also characterized in that

[0012] Step 1 is implemented as follows:

[0013] Step 1.1, obtain the video source of the driver's driving process through the OpenCV video acquisition operation function;

[0014] Step 1.2: After obtaining the video source of the driver's driving process in step 1.1, set the timer period and connect the slot function of the timer period overflow to display a frame of video. After loading it into an image frame, read each frame of the video to obtain a series of images of the traffic sign.

[0015] Step 2 is implemented as follows:

[0016] Step 2.1, cropping or padding the series of traffic sign images obtained in step 1 to keep the image sizes consistent;

[0017] Step 2.2, convert the arrays stored discontinuously in memory in the series of images obtained in step 2.1 into numpy arrays stored contiguously in memory;

[0018] Step 2.3, convert the numpy array processed in step 2.2 into a tensor in PyTorch.

[0019] Step 3 is implemented as follows:

[0020] In step 3.1, the activation function FreLU specifically for visual tasks is introduced into the Bconv layer and MPConv layer in the backbone module and the MPConv layer in the neck module of the original YOLOv7 network;

[0021] In step 3.2, we use the parameterized pooling window to create spatial dependencies and define the FreLU activation function as shown in equations (1) and (2):

[0022] f(x c,i,j )=max(x c,i,j ,T(x c,i,j )) (1)

[0023]

[0024] Among them, x c,i,j is a nonlinear activation, f(·) is the input pixel at the two-dimensional spatial position (i, j) on the c-th channel; the function T(·) represents the funnel condition, represents k h ×k w ; with x c,i,j The parameterized pooling window centered on Represents the coefficient shared by the window on the same channel, (·) represents the dot product;

[0025] Step 3.3: The tensor obtained in step 2 is fed into the improved backbone module for feature extraction to obtain the output feature tensor. The tensors are fed in one by one for real-time monitoring.

[0026] In step 3.4, the output feature tensor of the improved backbone module is fed into the improved neck module. In addition, the feature tensors of the second to third ELEN layers in the improved backbone module are fed into the improved neck module to perform feature map fusion to obtain the feature tensor.

[0027] Step 4 is implemented as follows:

[0028] Step 4.1: Based on the improvement of the original YOLOv7 network in step 3, a normalized NAM attention mechanism is added before the REPConv layer in the original head module;

[0029] In step 4.1, the NAM attention mechanism includes a channel attention mechanism module and a spatial attention mechanism module. Both the channel attention mechanism module and the spatial attention mechanism module use the scaling factor in batch normalization (BN), which is shown in the following formula (3):

[0030]

[0031] Among them, μ B and σ B is the mean and standard deviation of the mini-batch B, γ and β are trainable affine transformation parameters, B in is the input of batch B, B out is the output of batch B;

[0032] Step 4.2. The feature tensor obtained in step 3 will first enter the channel attention mechanism module to obtain the output feature Mc of the channel attention mechanism module;

[0033] In step 4.2, the output features of the channel attention mechanism module are shown in formula (4):

[0034] Mc=sigmoid(Wγ(BN(F1)))(4)

[0035] Among them, Mc represents the output feature of the channel attention mechanism module, W γ is the channel weight, γ is the scaling factor of each channel (the scaling factor reflects the size of the change in each channel), k is the number of channels, BN is the scaling factor, and F1 is the input feature entering the channel attention mechanism module;

[0036] Step 4.3: The output feature Mc of the channel attention mechanism module is input into the spatial attention mechanism module to obtain the output feature Ms of the spatial attention mechanism module.

[0037] In step 4.3, the output feature Ms of the spatial attention mechanism module is shown in formula (5):

[0038] Ms = sigmoid(W λ (BNs(F2))) (5)

[0039] Among them, Ms represents the output feature of the spatial attention mechanism module, W λ is the spatial pixel weight, λ is the scale parameter of each pixel, n is the number of pixels, BNs is the spatial scale factor, and F2 is the output feature of the channel attention mechanism module;

[0040] Step 5 is implemented as follows:

[0041] The output feature Ms of the spatial attention mechanism module obtained in step 4 is fed into the tensor a obtained by the REPConv layer, and the obtained tensor a is fed into the detection head. The detection head accepts the tensor a output by the input REPConv layer and returns the final output tensor list z; during prediction, the forward method is used to apply the convolution layer to each element in a; then, it reshapes the output tensor and applies the sigmoid activation function to it; finally, it appends the output tensor to the list z and returns it; the tensor list z is a tuple containing a box and a score tensor, and the score and box in the tuple are used to determine which type of traffic sign it is; then continue to loop through step 1 to judge the representation of the traffic sign in real time.

[0042] The beneficial effects of the present invention are:

[0043] Compared to some other traffic sign detection methods, this method replaces the SiLU activation function in the backbone BConv and MPConv layers of the YOLOv7 network and the neck MPConv layer of the network with the FreLU activation function. This improves the learning and feature extraction capabilities of the NAM-YOLOv7 network, enabling it to capture fine features of the target and perform pixel-level modeling even in complex backgrounds. Secondly, this method incorporates a normalized attention mechanism (NAM) before the REPConv layer of the network's head module. This attention mechanism consists of two modules: a channel attention module and a spatial attention module. This mechanism first uses non-local mean pooling (NMP) to calculate the similarity between different positions in each module's tensor, generating a weight matrix and then calculating its weighted average. By suppressing less significant weights, the feature tensors obtained by the channel attention module and the spatial attention module are fused. The normalized attention mechanism (NAM) further improves the NAM-YOLOv7 network's target detection accuracy in complex backgrounds, resulting in more accurate traffic sign detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a flow chart of a traffic sign detection method based on the normalized attention mechanism YOLOv7 of the present invention;

[0045] Figure 2 This is a network structure diagram of a traffic sign detection method based on the normalized attention mechanism YOLOv7 of the present invention;

[0046] Figure 3 Schematic diagram of the modified FreLU activation function in the method of the present invention;

[0047] Figure 4 This is a framework diagram after the NMA attention mechanism is added to the method of the present invention;

[0048] Figure 5 is the rendering of the prohibition sign finally detected by the method of the present invention in an actual scene;

[0049] Figure 6 It is the effect diagram of the indicator sign finally detected by the method of the present invention in the actual scene;

[0050] Figure 7 This is the warning sign effect diagram finally detected by the method of the present invention in an actual scenario. DETAILED DESCRIPTION

[0051] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0052] The present invention provides a traffic sign detection method based on the normalized attention mechanism YOLOv7, such as Figure 1 As shown, the specific steps include:

[0053] Step 1: Acquire a series of images of traffic signs taken during autonomous driving;

[0054] Step 1 is implemented as follows:

[0055] Step 1.1, obtain the video source of the driver's driving process through the OpenCV video acquisition operation function;

[0056] Step 1.2: After obtaining the video source of the driver's driving process in step 1.1, set the timer period and connect the slot function when the timer period overflows to display a frame of video. After loading it into image frames, read each frame of the video to obtain a series of images of traffic signs.

[0057] Step 2: crop or pad the series of traffic sign images obtained in step 1 into fixed-size images and convert them all into tensors;

[0058] Step 2 is implemented as follows:

[0059] Step 2.1, cropping or padding the series of traffic sign images obtained in step 1 to keep the image sizes consistent;

[0060] Step 2.2: Convert the discontinuously stored arrays in the series of images obtained in step 2.1 into numpy arrays that are continuously stored in memory, so as to run faster.

[0061] Step 2.3: Convert the numpy array processed in step 2.2 into a tensor in PyTorch, and the numpy array and the tensor in PyTorch share memory;

[0062] NAM-YOLOv7 improves the feature capture capability of the NAM-YOLOv7 network by introducing the FreLU activation function in the Bconv layer and MPConv layer of the backbone module and the MPConv layer of the neck module on the basis of the original YOLOv7 network; in the head module of the original YOLOv7 network, a normalized attention mechanism is added before the REPConv layer to improve the fineness of the NAM-YOLOv7 network in extracting traffic sign features, while suppressing its less obvious weights. The NAM-YOLOv7 network structure is shown in the figure below. Figure 2 shown.

[0063] Step 3: Improve the backbone module and neck module in the original YOLOv7 network, and send the tensor obtained in step 2 to the improved backbone module and neck module for feature extraction;

[0064] Step 3 is implemented as follows:

[0065] Step 3.1, the activation function FreLU specifically for visual tasks is introduced into the Bconv layer and MPConv layer in the backbone module and the MPConv layer in the neck module of the original YOLOv7 network. The improved backbone module and neck module can increase the model's ability to extract and fuse features, and enable the neural network to have the ability to delinearize, making the obtained features more expressive. The structure of the FreLU activation function is as follows: Figure 3 As shown;

[0066] In step 3.2, the FreLU activation function is an activation function specifically designed for visual tasks. It is also a nonlinear activation function. With only a slight increase in computational burden, it expands ReLU and PReLU into 2D activation functions, solving the spatial insensitivity problem in the activation function. This enables regular (ordinary) convolution to capture complex visual layouts and enables the model to have pixel-level modeling capabilities. To achieve spatial conditions, a parameterized pooling window is used to create spatial dependencies. The FreLU activation function is defined as shown in Equations (1) and (2):

[0067] f(x c,i,j )=max(x c,i,j ,T(x c,i,j )) (1)

[0068]

[0069] Among them, x c,i,j is a nonlinear activation, f(·) is the input pixel at the two-dimensional spatial position (i, j) on the c-th channel; the function T(·) represents the funnel condition, represents k h ×k w ; with x c,i,j The parameterized pooling window centered on Represents the coefficient shared by the window on the same channel, (·) represents the dot product;

[0070] In step 3.3, the tensor obtained in step 2 is fed into the improved backbone module of the NAM-YOLOv7 network for feature extraction to obtain the output feature tensor. The tensors are fed one by one for real-time monitoring.

[0071] In step 3.4, the output feature tensor of the improved backbone module is fed into the improved neck module. In addition, the feature tensors of the second to third ELEN layers in the improved backbone module are fed into the improved neck module for feature map fusion to obtain feature tensors. The feature tensors obtained by the backbone module and the neck module will be more refined and expressive, especially after the feature fusion operation.

[0072] Step 4: Based on the improvement of the original YOLOv7 network in step 3, the original head module is further improved to finally obtain the NAM-YOLOv7 network. The feature tensor obtained in step 3 is fed into the improved head module.

[0073] The specific process of step 4 is:

[0074] Step 4.1: Based on the improvement of the original YOLOv7 network in step 3, a normalized NAM attention mechanism is added before the REPConv layer in the original head module to improve the feature extraction ability of the model. The NAM attention mechanism framework is shown in the figure below: Figure 4 As shown in the figure, the NAM-YOLOv7 network is finally obtained. The feature tensor output by the improved neck module is fed into the NAM module in the improved head module for further feature extraction. Since the head module introduces the NAM attention mechanism, the traffic sign features output by it are further refined and more obvious.

[0075] In step 4.1, the NAM attention mechanism is a lightweight and efficient attention mechanism that highlights salient features by utilizing the variance measurement of the training model weights. The module integration of CBAM is adopted. The NAM attention mechanism includes a channel attention mechanism module and a spatial attention mechanism module. The channel and spatial attention submodules are redesigned. Both the channel attention mechanism module and the spatial attention mechanism module use the scaling factor in batch normalization (BN). The scaling factor is shown in the following formula (3):

[0076]

[0077] Among them, μ B and σ B is the mean and standard deviation of the mini-batch B, γ and β are trainable affine transformation parameters, B in is the input of batch B, B out is the output of batch B.

[0078] Step 4.2, the feature tensor obtained in step 3 will first enter the channel attention mechanism module,

[0079] Get the output feature Mc of the channel attention mechanism module;

[0080] In step 4.2, the output features of the channel attention mechanism module are shown in formula (4):

[0081] Mc=sigmoid(Wγ(BN(F1)))(4)

[0082] Among them, Mc represents the output feature of the channel attention mechanism module, W γ is the channel weight, γ is the scale parameter of each channel (the scaling factor reflects the size of the change in each channel), k is the number of channels, BN is the scaling factor, and F1 is the input feature entering the channel attention mechanism module;

[0083] In step 4.3, the output feature Mc of the channel attention mechanism module is input into the spatial attention mechanism module to obtain the output feature Ms of the spatial attention mechanism module. The BN scaling factor is applied in the spatial dimension to measure the importance of pixels, which is called pixel normalization.

[0084] In step 4.3, the output feature Ms of the spatial attention mechanism module is shown in formula (5):

[0085] Ms = sigmoid(W λ (BNs(F2))) (5)

[0086] Among them, Ms represents the output feature of the spatial attention mechanism module, W λ is the spatial pixel weight, λ is the scale parameter of each pixel, n is the number of pixels, BNs is the spatial scale factor, and F2 is the output feature of the channel attention mechanism module;

[0087] In step 5, the feature tensor obtained in step 4 (the output feature Ms of the spatial attention mechanism module) is fed into the REPConv layer of the improved head module, and then passes through the inspection head to output the traffic sign detection result.

[0088] The specific process of step 5 is:

[0089] The output feature Ms of the spatial attention mechanism module obtained in step 4 is fed into the tensor a obtained by the REPConv layer, and the obtained tensor a is fed into the detection head. The detection head accepts the tensor a output by the input REPConv layer and returns the final output tensor list z. During prediction, the forward method is used to apply a convolution layer to each element in a. Then, it reshapes the output tensor and applies a sigmoid activation function to it. Finally, it appends the output tensor to the list z and returns it. The tensor list z is a tuple containing a box and a score tensor. The score and box in the tuple are used to determine which type of traffic sign it is, and to avoid risks in advance. Then, step 1 is continued in a loop to judge the representation of the traffic sign in real time.

[0090] The present invention first crops the image containing the traffic sign into an image of fixed size and converts it into a tensor as the input of the NAM-YOLOv7 network; the backbone module of NAM-YOLOv7 performs feature extraction on the traffic sign image tensor; the output of the backbone module is sent to the neck module, and in addition, the feature tensors obtained by the second and third ELEN layers in the backbone module are sent to the neck module for feature fusion with the former, so that the feature tensor output by the neck module is more expressive; then, after passing through the head module, due to the introduction of the normalized attention mechanism (NAM) in the head module, the NAM-YOLOv7 network can better capture the long-range dependencies in the feature tensor, and make the feature map more obvious through the dependencies established between different positions (channel attention and spatial attention); finally, after passing through the REPConv layer, the detection head obtains the result.

[0091] Experimental results:

[0092] This research uses the new China Traffic Sign Detection Dataset (CCTSDB 2021). Traffic sign detection is a critical component of autonomous driving and intelligent transportation systems. In this dataset, many of the original easy-to-detect images are replaced with more difficult samples to adapt to the complex and changing detection environment. Due to the increased number of difficult samples, the new benchmark can improve the robustness of the detection network to a certain extent compared to the old version.

[0093] The software environment of the experiment is: operating system Linux, Python 3.9.13, Pytorch 1.8.1, CUDA 11.3.1, the hardware environment is: GPU 3070Ti, CPU is Intel (R) Xeon (R) Silver 4110 CPU @ 2.10GHz.

[0094] Experimental parameter settings: The optimizer uses stochastic gradient descent (SGD), the learning rate is 1e-4, the weight decay is 5e-4, the momentum is 0.8, the batch size is 8, the training is 300 epochs, and the default value of workers is 8.

[0095] Experimental evaluation indicators: This experiment uses the mean average accuracy of all categories mAP@0.5 (meanAverage Precision, IoU threshold is greater than 0.5) as the evaluation indicator. The results are shown in Table 1:

[0096] Table 1

[0097] mAP@.5(%) R(%) warning 90 85.7 prohibited 89.5 83.6 mandatory 94.8 88.5

[0098] The comparison between the NAM-YOLOv7 network and the original network is shown in Table 2, where different weight files are used for comparison. NAM-YOLOv7 uses the YOLOv7 weight file:

[0099] Table 2

[0100] Network Model P(%) R(%) mAP@.5(%) mAP@.5:.95(%) YOLOv7 82 80.2 86.7 62.7 YOLOv7-X 79.4 72.5 79.2 53.6 YOLOv7-W6 80.1 66.3 74.1 46.3 YOLOv7-E6 81.5 72.7 81.8 55.8 YOLOv7-D6 84.2 65.5 75.9 48.2 NAM-YOLOv7 87.5 85.9 91.4 68.5

[0101] Depend on Figure 5 It can be seen that prohibition signs generally have a white background, a red circle and a slash, and a black main body, which serve to prohibit or restrict a series of behaviors, such as prohibiting pedestrians or vehicles from passing.

[0102] Depend on Figure 6 It can be seen that the background of the sign is usually blue, with a white main body. The signboards are mainly circular, rectangular, and square, and serve the purpose of indicating and directing the way, such as guiding vehicles or pedestrians to pass, indicating the direction and distance of the road, etc.

[0103] Depend on Figure 7 It can be seen that the background of the warning sign is usually yellow, the border is black, the main body is black, and the shape is generally triangular. Its main function is to warn vehicles that there are dangers ahead, such as falling rocks or schools ahead.

[0104] The experimental results above demonstrate that the network improves the NAM-YOLOv7 network's feature capture capability by introducing the FreLU activation function into the Bconv and MPConv layers of the YOLOv7 backbone module and the MPConv layer of the neck module. By incorporating the Normalization Attention (NAM) mechanism into the YOLOv7 head module, the improved NAM-YOLOv7 network significantly improves the refinement of traffic sign feature extraction while suppressing less noticeable weights. This network addresses the existing issue of low traffic sign detection accuracy in complex backgrounds, while also ensuring real-time traffic sign detection using YOLOv7.

Claims

1. Traffic sign detection method based on normalized attention mechanism YOLOv7, characterized by: The details are as follows: Step 1: Acquire a series of traffic sign images taken during autonomous driving; Step 2: Crop or pad the series of traffic sign images acquired in Step 1 into fixed-size images and convert them into tensors; Step 3: Improve the backbone module and neck module in the original YOLOv7 network, and feed the tensors obtained in Step 2 into the improved backbone module and neck module for feature extraction; Step 4: Based on the improvement of the original YOLOv7 network in Step 3, continue to improve the original head module, and feed the feature tensor obtained in Step 3 into the improved head module; Step 5: Feed the feature tensor obtained in Step 4 into the REPConv layer of the improved head module, and then pass it through the inspection head to output the traffic sign detection result; Step 3 is implemented as follows: In step 3.1, the activation function FreLU specifically for visual tasks is introduced into the Bconv layer and MPConv layer in the backbone module and the MPConv layer in the neck module of the original YOLOv7 network; In step 3.2, we use the parameterized pooling window to create spatial dependencies and define the FreLU activation function as shown in equations (1) and (2): f(x c,i,j )=max(x c,i,j ,T(x c,i,j ))(1) Among them, x c,i,j is a nonlinear activation, f(·) is the input pixel at the two-dimensional spatial position (i, j) on the c-th channel; the function T(·) represents the funnel condition, represents k h ×k w ; with x c,i,j The parameterized pooling window centered on Represents the coefficient shared by the window on the same channel, (·) represents the dot product; Step 3.3: The tensor obtained in step 2 is fed into the improved backbone module for feature extraction to obtain the output feature tensor. The tensors are fed in one by one for real-time monitoring. In step 3.4, the output feature tensor of the improved backbone module is fed into the improved neck module. In addition, the feature tensors of the second and third ELEN layers in the improved backbone module are fed into the improved neck module to perform feature map fusion to obtain the feature tensor. Step 4 is implemented as follows: Step 4.1: Based on the improvement of the original YOLOv7 network in step 3, a normalized NAM attention mechanism is added before the REPConv layer in the original head module; In step 4.1, the NAM attention mechanism includes a channel attention mechanism module and a spatial attention mechanism module. Both the channel attention mechanism module and the spatial attention mechanism module use the scaling factor in batch normalization, which is shown in the following formula (3): Among them, μ B and σ B is the mean and standard deviation of the mini-batch B, γ and β are trainable affine transformation parameters, B in is the input of batch B, B out is the output of batch B; Step 4.

2. The feature tensor obtained in step 3 will first enter the channel attention mechanism module to obtain the output feature Mc of the channel attention mechanism module; In step 4.2, the output features of the channel attention mechanism module are shown in formula (4): Mc=sigmoid(Wγ(BN(F1)))(4) Among them, Mc represents the output feature of the channel attention mechanism module, W γ is the channel weight, γ is the scale parameter of each channel, k is the number of channels, BN is the scale factor, and F1 is the input feature entering the channel attention mechanism module; Step 4.3: The output feature Mc of the channel attention mechanism module is input into the spatial attention mechanism module to obtain the output feature Ms of the spatial attention mechanism module. In step 4.3, the output feature Ms of the spatial attention mechanism module is shown in formula (5): Ms=sigmoid(W λ (BNs(F2))) (5) Among them, Ms represents the output feature of the spatial attention mechanism module, W λ is the spatial pixel weight, λ is the scale parameter of each pixel, n is the number of pixels, BNs is the spatial scale factor, and F2 is the output feature of the channel attention mechanism module.

2. The traffic sign detection method based on the normalized attention mechanism YOLOv7 according to claim 1 is characterized in that Step 1 is implemented as follows: Step 1.1, obtain the video source of the driver's driving process through the OpenCV video acquisition operation function; Step 1.2: After obtaining the video source of the driver's driving process in step 1.1, set the timer period and connect the slot function of the timer period overflow to display a frame of video. After loading it into an image frame, read each frame of the video to obtain a series of images of the traffic sign.

3. The traffic sign detection method based on the normalized attention mechanism YOLOv7 according to claim 1 is characterized in that Step 2 is implemented as follows: Step 2.1, cropping or padding the series of traffic sign images obtained in step 1 to keep the image sizes consistent; Step 2.2, convert the arrays stored discontinuously in memory in the series of images obtained in step 2.1 into numpy arrays stored contiguously in memory; Step 2.3, convert the numpy array processed in step 2.2 into a tensor in PyTorch.

4. The traffic sign detection method based on the normalized attention mechanism YOLOv7 according to claim 1 is characterized in that Step 5 is implemented as follows: The output feature Ms of the spatial attention mechanism module obtained in step 4 is fed into the tensor a obtained by the REPConv layer, and the obtained tensor a is fed into the detection head. The detection head accepts the tensor a output by the input REPConv layer and returns the final output tensor list z; during prediction, the forward method is used to apply the convolution layer to each element in a; then, it reshapes the output tensor and applies the sigmoid activation function to it; finally, it appends the output tensor to the list z and returns it; the tensor list z is a tuple containing a box and a score tensor, and the score and box in the tuple are used to determine which type of traffic sign it is; then continue to loop through step 1 to judge the representation of the traffic sign in real time.

Citation Information

Patent Citations

  • Chart identification method and device, equipment and storage medium

    CN114155547A

  • Target detection method based on NAM and YOLOv3

    CN115861651A