# NTS-YOLO: A Notcurnal Traffic Sign Detection Method Based on Improved YOLOv5
## 2 Methods
### Adding CBAM Attention Mechanism  
Nighttime traffic sign recognition faces many challenges in practice, especially due to problems such as low light and ambient noise, which result in blurred images and difficulty in recognizing the edges and details of traffic signs. To remedy this problem, this study introduced the Convolutional Block Attention Module (CBAM) attention mechanism to enhance the model's ability to recognize and represent key features, which in turn improves the recognition accuracy and stability under low-light conditions. The CBAM focuses on important feature channels and key spatial regions in the image through the dimensions of channel attention (\(CA\)) and spatial attention (\(SA\)), as illustrated in Figure 4. The channel attention (\(CA\)) and spatial attention (\(SA\)) of the CBAM are shown in Equations (1) and (2).  
\[CA(F)=\sigma(MLP(GAP(F))+MLP(GMP(F))) \tag{1}\]  
\[SA(F)=\sigma\Big{(}f^{\gamma\times 7}([GAP(F);GMP(F)])\Big{)} \tag{2}\]  
where \(F\) in \(CA(F)\) is the input feature map, \(\sigma\) is the sigmoid activation function, and \(MLP\) denotes the multilayer perceptron; \(GAP\) and \(GMP\) stand for global average pooling and global maximum pooling, respectively, which are used to compute the global statistical properties of each channel. The \(f^{\gamma\times 7}\) in \(SA(F)\) denotes the convolution operation with a \(7\times 7\) convolution kernel, and \([:]\) denotes the stacking of feature maps.  
Before the introduction of the CBAM, the output of the SPPF convolutional layer was the feature map F that was processed from the original input image after convolution, batch normalization, and the application of the ReLU activation function, as shown in Equation (3).  
\[F=ReLU(BN(Conv(Input))) \tag{3}\]  
After adding the CBAM, the output feature map F of the SPPF convolutional layer is further processed by the CBAM, and the network structure is shown in Figure 5. The CBAM first computes the attention weights of each channel through the CA part and then computes the spatial attention weights through the SA part. Finally, these two weights are multiplied with the original feature map F to obtain the final output feature map, as shown in Equation (4).  
\[F^{\prime}=F\times CA(F)\times SA(F) \tag{4}\]  
Figure 3: Unsupervised preprocessing comparison chart. The collected nighttime traffic sign images were processed with data augmentation to improve the image quality.  
Figure 4: CBAM attention mechanism structure diagram. The CBAM processes the input feature maps through two main modules: the channel attention module and the spatial attention module. The channel attention module adaptively adjusts the weights of different channels to highlight important features, while the spatial attention module focuses on key regions in the spatial domain, thereby enhancing the model’s ability to recognize critical areas.  
Figure 5: NTS-YOLO network structure. The NTS-YOLO network architecture integrates the CBAM attention mechanism, enabling the model to effectively focus on the region with the highest amount of information in the input image, significantly improving the real-time system’s object detection performance.  
The introduction of the CBAM allows the model to focus more effectively on key channel features and to identify and emphasize important spatial regions in the image. In complex environments at night, identifying traffic signs, small targets, and possible occlusion situations, traditional feature extraction methods are often affected by uneven lighting and background noise. With the CBAM attention mechanism, the model is able to focus not only on important channel features but also on key spatial regions in the image when processing the feature map. This integration strategy improves the model's sensitivity to details and enhances its robustness under low-light conditions, which brings a significant performance improvement to the nighttime traffic sign recognition task and provides an effective solution to address the challenges of uneven lighting and background noise.