Lightweight classifier coupled traffic signal light fast recognition method and system
By improving the combination of the YOLOv5s model and the AlexNet network, a cross-domain normalization and pseudo-reflection separation mechanism was constructed, which solved the problems of low accuracy and real-time performance in traffic light recognition under changing lighting conditions and complex backgrounds, and achieved efficient traffic light recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHU SIMBA NETWORK TECH CO LTD
- Filing Date
- 2025-09-28
- Publication Date
- 2026-06-19
AI Technical Summary
Existing traffic light recognition methods have low accuracy under varying lighting conditions and complex backgrounds, making it difficult to simultaneously meet the requirements of high precision and real-time performance. In particular, when recognizing multiple light groups, the model complexity is high and the generalization ability is insufficient.
A method using a lightweight classifier coupled with a detection head is adopted. By improving the YOLOv5s model by adding an attention mechanism and an object detection layer, and combining it with the AlexNet network for feature extraction, a cross-domain normalization and pseudo-reflection separation mechanism is constructed. A multi-level parallel convolutional structure and feature fusion are used to achieve rapid recognition of traffic lights.
It significantly improves the accuracy and stability of traffic light recognition, reduces the false positive and false negative rates, enhances the model's generalization ability in different scenarios, and achieves fast and stable traffic light recognition.
Smart Images

Figure CN121259784B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, specifically to a method and system for rapid recognition of traffic lights using a lightweight classifier coupled to a detection head. Background Technology
[0002] In real-world road scenarios, traffic light recognition faces numerous challenges. Lighting conditions vary significantly at different times of day, from the soft light of early morning to the intense sunlight of midday, and then to artificial lighting at night, all of which affect the image quality of traffic lights. Existing traffic light recognition methods mainly include those based on traditional image processing and those based on deep learning. Traditional image processing methods rely on techniques such as color thresholding and shape detection, resulting in low accuracy under varying lighting conditions and complex backgrounds. While deep learning-based methods have improved recognition accuracy, most employ end-to-end deep network models, such as detection models using ResNet or VGG as the backbone network. These models have a large number of parameters and high computational complexity, making them difficult to meet real-time requirements.
[0003] Especially when processing images of traffic light clusters containing multiple traffic lights, existing methods often identify the entire cluster as a whole, requiring the construction of complex multi-label classification models to simultaneously identify multiple light state combinations. This approach not only increases model complexity but also reduces recognition accuracy. Furthermore, because traffic light images collected in different scenarios vary significantly in color, brightness, and other aspects, existing methods lack effective image standardization mechanisms, resulting in insufficient generalization ability of the models.
[0004] Therefore, existing traffic light recognition technologies suffer from the problem of balancing recognition accuracy and real-time performance, failing to simultaneously meet the dual requirements of intelligent transportation systems for high precision and rapid response.
[0005] In view of this, this application proposes a method and system for rapid identification of traffic lights using a lightweight classifier coupled with a detection head. Summary of the Invention
[0006] To achieve the above objectives, this application provides a method and system for rapid traffic light recognition using a lightweight classifier coupled to a detection head. The specific technical solution is as follows:
[0007] A fast traffic light recognition method using a lightweight classifier coupled with a detection head includes:
[0008] The first YOLOv5s model is improved by adding an attention mechanism and changing the object detection layer. The traffic light area in the road scene image is identified by the first YOLOv5s model.
[0009] The arrangement of the traffic light panels is determined based on the aspect ratio of the traffic light area image. The corresponding segmentation strategy is then used to crop the traffic light image into individual traffic light images according to the arrangement.
[0010] A data consistency processing mechanism is constructed to perform cross-domain standardization and pseudo-reflection separation on a single traffic light image, thereby unifying the image color and brightness distribution and suppressing highlights and shadows.
[0011] The backbone network in the second YOLOv5s model is replaced with an improved AlexNet network to construct the AlexNet-YOLOv5s model. A single traffic light image is input into the improved AlexNet network, and multi-scale features of the traffic light image are extracted through a multi-level parallel convolutional structure as input to the YOLOv5s structure in the AlexNet-YOLOv5s model.
[0012] By using the YOLOv5s structure in the AlexNet-YOLOv5s model, classification and recognition of multi-scale features are performed and the classification and recognition results are fused to generate traffic light recognition results.
[0013] Preferably, road scene images containing traffic lights are acquired by vehicle-mounted cameras, and the first YOLOv5s model is trained using a traffic scene dataset with labeled traffic light bounding boxes;
[0014] After receiving the acquired road scene image, the first YOLOv5s model identifies and labels the bounding boxes of the traffic light structure area, and crops the image with the bounding boxes of the traffic light area according to a fixed format as the traffic light area image.
[0015] Preferably, a two-dimensional coordinate system containing x and y axes is constructed using the top left corner of the identified traffic light area image as the origin, with the x-axis positive to the right and the y-axis positive downwards;
[0016] Two coordinate points, the upper left and lower right points, of the traffic light image bounding box are selected. The arrangement of the traffic lights is determined by calculating the difference between the width and height of the two coordinate points. When the difference is greater than 0, the width of the traffic light area is greater than its height, and the traffic light panel is arranged horizontally. When the difference is less than 0, the width of the traffic light area is less than its height, and the traffic light panel is arranged vertically.
[0017] Preferably, based on the layout of the traffic lights, the traffic light image is divided into three equal parts using two straight lines;
[0018] When the traffic light panel is arranged horizontally, two vertical dividing lines are used to divide the traffic light image into three equal parts;
[0019] When the traffic light panel is arranged vertically, two horizontal dividing lines are used to divide the traffic light image into three equal parts.
[0020] Preferably, cross-domain normalization processing is performed on the segmented individual traffic light images to convert the individual traffic light images from the RGB color space to the LAB color space;
[0021] In the LAB color space, the L channel represents luminance information, the A channel represents color components from green to red, and the B channel represents color components from blue to yellow. Adaptive histogram equalization is performed on the L channel, the cumulative distribution function of the L channel is calculated, and the luminance value is standardized to a preset range through a mapping function.
[0022] The mean and standard deviation of channels A and B are calculated separately, and color normalization is performed to eliminate color shifts caused by different shooting conditions by using preset reference mean and standard deviation.
[0023] Preferably, pseudo-reflection separation is performed on a single traffic light image by using a reflection component separation method based on Retinex theory to decompose the image into the product of illuminance component and reflection component;
[0024] Illuminance components are estimated by multi-scale Gaussian filtering. Multiple Gaussian kernels with different standard deviations are used to convolve the image, and the estimated illuminance components are obtained by weighted summation.
[0025] Calculate the reflectance component, perform dynamic range compression on the contrast component, and adaptively adjust the compression coefficient according to the dynamic range of the image;
[0026] The processed illuminance and reflectance components are recombined to obtain the processed traffic light image.
[0027] Preferably, the local response normalization layer in the original AlexNet network is replaced with a batch normalization algorithm; the batch normalization algorithm calculates the mean and variance on each batch of data, standardizes the features, and performs global normalization on the feature dimension;
[0028] The improved AlexNet network retains the original five-layer convolutional structure, and adds a batch normalization layer after each convolutional layer to normalize the features;
[0029] An improved AlexNet network was used as the feature extraction backbone network. The fully connected layers of the AlexNet network were removed, and only five convolutional layers and pooling layers were retained as feature extractors. The original CSPDarknet backbone network in the second YOLOv5s model was replaced to construct the AlexNet-YOLOv5s model.
[0030] Preferably, a multi-level parallel convolutional structure is constructed, and feature branches are drawn out at the output positions of the third, fourth and fifth convolutional layers of the improved AlexNet network, forming feature outputs at three different scales.
[0031] Features from the three scales are integrated through feature fusion, using a weighted fusion strategy. The fusion weights are automatically adjusted during training via backpropagation.
[0032] A feature enhancement unit is added after the multi-scale features to output three feature maps with different resolutions.
[0033] Preferably, the YOLOv5s detection head of the AlexNet-YOLOv5s model uses three detection branches at different scales to receive feature maps at different resolutions.
[0034] Non-maximum suppression is applied to the outputs of the three detection branches to remove duplicate detection boxes. A weighted voting mechanism is used to fuse the multi-scale detection results, calculate the weighted sum of the classification scores of each detection branch, and select the category with the highest score as the final traffic light classification and recognition result.
[0035] A traffic light rapid recognition system with a lightweight classifier coupled detection head, which is implemented according to the traffic light rapid recognition method of the lightweight classifier coupled detection head, includes: a region recognition module, a layout and cropping module, an image processing module, a composite network module, and a result recognition module;
[0036] The region recognition module acquires a road scene image containing traffic lights, improves the first YOLOv5s model by adding an attention mechanism and changing the target detection layer, and identifies the traffic light region image in the road scene image using the first YOLOv5s model.
[0037] The layout and cropping module determines the layout of the light panels based on the aspect ratio of the traffic light area image, and uses the corresponding segmentation strategy to crop the traffic light image into independent individual traffic light images according to the layout.
[0038] The image processing module constructs a data consistency processing mechanism to perform cross-domain standardization and pseudo-reflection separation on a single traffic light image, unifying the image color and brightness distribution and suppressing highlights and shadows.
[0039] The composite network module replaces the backbone network in the second YOLOv5s model with an improved AlexNet network to construct an AlexNet-YOLOv5s model. A single traffic light image is input into the improved AlexNet network, and multi-scale features of the traffic light image are extracted through a multi-level parallel convolutional structure as input to the YOLOv5s structure in the AlexNet-YOLOv5s model.
[0040] The result recognition module uses the YOLOv5s structure in the AlexNet-YOLOv5s model to classify and recognize multi-scale features and fuse the classification and recognition results to generate the traffic light recognition result.
[0041] The beneficial effects of this application are as follows: By recognizing traffic light areas in road scenes using YOLOv5s, this application also introduces an attention mechanism and resets the detection layer, which significantly improves the receptive field and feature contrast of small-sized traffic lights and reduces the false detection and missed detection rates; at the same time, it maintains lightweight inference overhead and achieves fast and stable candidate region extraction in complex road scenes.
[0042] This application determines the arrangement of light panels based on aspect ratio and adopts a targeted cropping strategy to split multi-light targets into standardized single-light samples, reducing target aliasing and background interference; providing consistent input size and composition for subsequent classification, and improving the classifier's discrimination accuracy.
[0043] This application unifies the color and brightness distribution under different devices and weather conditions through cross-domain standardization and pseudo-reflection separation, effectively suppressing specular noise, shadow noise, and reflection noise; reducing domain offset and enhancing the model's generalization ability across different scenarios such as day and night, sunny and cloudy, rain and fog.
[0044] This application replaces the backbone with an improved AlexNet and constructs AlexNet-YOLOv5s. It obtains multi-scale features with complementary high and low frequencies through multi-level parallel convolution, balancing lightweight and expressive power. This makes the edges and local textures of small objects more prominent, providing more discriminative feature inputs for the detection head.
[0045] This application performs classification and fusion of multi-scale features within the YOLOv5s architecture, integrating semantic and detailed information at different levels to improve the stability of the determination of red, yellow, green and off states; it outputs a unified confidence result to achieve high accuracy and low latency in the final recognition. Attached Figure Description
[0046] Figure 1 Flowchart of the traffic light fast recognition method with lightweight classifier coupled detection head provided in this application;
[0047] Figure 2 The flowchart of the traffic light detection and recognition algorithm provided in this application;
[0048] Figure 3 A schematic diagram illustrating the segmentation of a single traffic light image provided in this application;
[0049] Figure 4 The diagram shows the structure of the traffic light rapid recognition system with a lightweight classifier coupled detection head provided in this application. Detailed Implementation
[0050] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the specific embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0051] Many specific details are set forth in the following description in order to provide a full understanding of this application. However, this application may also be implemented in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.
[0052] Secondly, the term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of this application. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single embodiment or an embodiment selectively excluded from other embodiments.
[0053] Example 1
[0054] Reference Figures 1 to 3 This is the first embodiment of this application. Figure 1 As shown, a fast traffic light recognition method using a lightweight classifier coupled with a detection head is provided; for example... Figure 2 As shown, the algorithm flow for traffic light detection and recognition is provided.
[0055] Step 1: Obtain a road scene image containing traffic lights, improve the first YOLOv5s model by adding an attention mechanism and changing the object detection layer, and identify the traffic light area image in the road scene image using the first YOLOv5s model.
[0056] The system uses an onboard camera to capture road scene images containing traffic lights. A pre-trained YOLOv5s network is then used to identify the traffic light structure region in the captured traffic light images, which is then used as the traffic light region image. Irrelevant content is removed from the road scene images.
[0057] The first YOLOv5s model was used as the traffic light region detector. This model was trained on a traffic scene dataset with labeled traffic light bounding boxes. The trained model was then used to identify and crop out the structural images of the traffic lights. Upon receiving the acquired traffic light images, the first YOLOv5s model identified and labeled the bounding boxes of the traffic light structural regions, and cropped the images with the bounding boxes according to a fixed format as the traffic light region images, which were then used for subsequent arrangement determination and segmentation processing.
[0058] The accuracy of the first YOLOv5s model in recognizing traffic light structures in road scene images was improved by replacing the small object detection layer and adding an attention mechanism.
[0059] Step 2: Determine the layout of the traffic light panels based on the aspect ratio of the traffic light area image, and use the corresponding segmentation strategy to crop the traffic light image into independent individual traffic light images according to the layout.
[0060] Before segmenting the traffic light area image, the arrangement of the traffic lights must first be identified, and the arrangement of the traffic lights is calculated and determined based on the parameters of the traffic light area bounding box.
[0061] Using the top left corner of the identified traffic light area image as the origin, a two-dimensional coordinate system containing x and y axes is constructed. In the constructed two-dimensional coordinate system, the x-axis is positive to the right and the y-axis is positive downward. Two coordinate points are selected: the top left point (X1, Y1) and the bottom right point (X2, Y2) of the traffic light image bounding box.
[0062] The layout of the traffic light panels is distinguished by calculating the coordinates of the top left point (X1, Y1) and the bottom right point (X2, Y2). The calculation formula is: F = (X2 - X1) - (Y2 - Y1). If F > 0, the width of the traffic light area is greater than its height, indicating that the traffic light panel layout is horizontal. If F < 0, the width of the traffic light area is less than its height, indicating that the traffic light panel layout is vertical.
[0063] According to the arrangement of traffic lights (horizontal or vertical layout), the corresponding segmentation strategy is used to crop the traffic light image into independent individual traffic light images; the segmentation strategy includes: according to the layout of traffic lights, using two straight lines to divide the traffic light image into three equal parts.
[0064] Specifically, when the traffic light panels are arranged horizontally, lines L1 and L2 divide the traffic light image. The expressions for lines L1 and L2 are as follows:
[0065]
[0066] When the traffic light panels are arranged vertically, the traffic light image is segmented using lines L3 and L4. The expressions for lines L3 and L4 are as follows:
[0067]
[0068] Based on the arrangement of the traffic lights, and according to the selected segmentation method, the corresponding segmentation lines are calculated to crop the traffic light image into independent individual traffic light images.
[0069] like Figure 3 As shown, Figure 3 This is a schematic diagram illustrating how to segment the identified traffic light image into individual traffic light images.
[0070] This step employs the first YOLOv5s model, which can quickly and accurately locate and separate the complete structure of traffic lights from complex traffic backgrounds. It uses geometric calculations based on the aspect ratio of the detection boxes to determine the arrangement of the light panels, and combines this with a trisection segmentation strategy to obtain independent individual traffic light images. Compared to complex pixel-level segmentation networks, this method has extremely low computational cost and high execution efficiency. This step cleverly simplifies the traffic light group recognition problem into multiple independent, single-state basic traffic light recognition problems. This not only significantly reduces the learning difficulty and computational complexity of subsequent classification models, but also provides standardized input for subsequent traffic light color and state recognition, greatly improving the accuracy and robustness of traffic light image content recognition.
[0071] Step 3: Construct a data consistency processing mechanism to perform cross-domain standardization and pseudo-reflection separation on individual traffic light images, unify image color and brightness distribution, and suppress highlights and shadows.
[0072] Data consistency processing is performed on the individual traffic light images obtained in step 1, and a cross-domain standardization and pseudo-reflection separation mechanism is constructed to solve the problems of color deviation and brightness unevenness of traffic light images under different lighting conditions, weather conditions and shooting angles.
[0073] Cross-domain normalization is performed on the segmented individual traffic light images, first converting them from the RGB color space to the LAB color space. In the LAB color space, the L channel represents luminance information, the A channel represents the color components from green to red, and the B channel represents the color components from blue to yellow. The conversion formula is as follows:
[0074] L=116×f(Y / Y n )-16
[0075] A = 500 × [f(X / X)] n )-f(Y / Y n )]
[0076] B = 200 × [f(Y / Y)] n )-f(Z / Z n )]
[0077] X, Y, and Z are tristimulus values obtained by first linearizing (de-gamma) the RGB values of a single traffic light image according to a known standard (such as sRGB, white point D65), and then transforming them from linear RGB to the CIE1931 XYZ color space using a fixed 3×3 matrix. The XYZ color space is a device-independent color representation. n Y n Z n For the tristimulus value of the reference white point, f(·) is a nonlinear transformation function, when X / X nWhen >0.008856, f(X / X) n )=(X / X n ) 1 / 3 Otherwise f(X / X) n ) = 7.787(X / X n )+16 / 116, similarly we can obtain f(Y / Y) n ) and f(Z / Z n ).
[0078] Adaptive histogram equalization is performed on the L channel to map the brightness values to a standard distribution range. The cumulative distribution function C(l) of the L channel is calculated, where l represents the brightness level. Then, the value is mapped using the L channel function. new =C(L) old The brightness value is standardized to the range [0, 100] by 100. Adaptive histogram equalization can effectively balance the overall brightness of the image, so that traffic light images taken under strong light and low light conditions have similar brightness distribution characteristics.
[0079] Calculate the mean φ for channels A and B respectively. A φ B and standard deviation s A σ B Perform color normalization:
[0080] A norm =(A-φ A ) / σ A ×σ ref +φ ref
[0081] B norm =(B-φ B ) / σ B ×σ ref +φ ref
[0082] Where φ ref and σ ref The preset reference mean and standard deviation are obtained through statistical analysis of a large number of traffic light images under standard lighting conditions. For example, μ... ref Set to 0, σ ref Set to 25. Color normalization eliminates color shifts caused by different shooting conditions, ensuring that the color characteristics of red, yellow, and green signal lights remain consistent.
[0083] Next, pseudo-reflection separation is performed on individual traffic light images to eliminate highlight areas and shadow interference caused by strong light illumination. A reflection component separation method based on Retinex theory is used to decompose the image into the product I of illuminance component S and reflection component R: I = S × R.
[0084] Illuminance components are estimated using multi-scale Gaussian filtering: Where K is the scale number, set to 3, w k The weights for the k-th scale satisfy... The standard deviation is σ k The Gaussian kernel is used, and * indicates the convolution operation.
[0085] The reflection component R = I / (S + ∈) of a single traffic light image is calculated, where ∈ is a small constant to prevent division by zero, with a value of 0.001. The reflection component R contains the essential color information of the object and is not affected by changes in illumination.
[0086] Dynamic range compression is applied to the contrast component S to suppress excessively strong and weak illumination in the image.
[0087] S compressed = log(1+α×S) / log(1+α)
[0088] Among them, S compressed This is the adjusted illumination, where α is the compression coefficient, adaptively adjusted according to the image's dynamic range. The calculation formula is α = 10 / max(S), where max(S) is the maximum illuminance component. The compressed illuminance component effectively reduces the impact of highlights and shadows.
[0089] The processed illuminance and reflectance components are recombined: I processed =S compressed ×R, and you get a traffic light image with uniform illumination and consistent color.
[0090] The processed LAB image is converted back to the RGB color space and the pixel values are cropped to ensure that all pixel values are within the range of [0, 255].
[0091] This step, through the aforementioned data consistency processing mechanism, standardizes traffic light images collected under different environmental conditions to a uniform color and brightness distribution, eliminating image quality differences caused by changes in lighting, weather factors, and shooting angles. This provides high-quality, standardized input data for subsequent feature extraction and recognition classification, significantly improving the model's robustness and recognition accuracy in complex scenarios.
[0092] Step 4: Replace the backbone network in the second YOLOv5s model with the improved AlexNet network to construct the AlexNet-YOLOv5s model. Input a single traffic light image into the improved AlexNet network and extract multi-scale features of the traffic light image through a multi-level parallel convolutional structure, which are then used as inputs to the YOLOv5s structure in the AlexNet-YOLOv5s model.
[0093] The original AlexNet network uses Local Response Normalization (LRN) to normalize the activation values of neurons. LRN simulates the lateral inhibition mechanism of biological neurons by normalizing the activity of neurons in adjacent feature maps at the same spatial location. LRN requires complex normalization calculations for multiple channels at each spatial location, resulting in high computational complexity and slow training and inference speeds.
[0094] To improve network training efficiency and stability, the Batch Normalization (BN) algorithm replaces the LRN layer in the original AlexNet. The BN algorithm calculates the mean and variance on each batch of data, standardizing the features. Compared to LRN's local spatial normalization, BN performs global normalization along the feature dimension, making the computation process simpler and more efficient. By standardizing the input of each layer to a distribution with a mean of 0 and a variance of 1, BN can solve the internal covariate shift problem during AlexNet network training, ensuring a stable input distribution for each layer.
[0095] The improved AlexNet network was used as the feature extraction backbone network to replace the original CSPDarknet backbone network in the YOLOv5s network, thus constructing the AlexNet-YOLOv5s model.
[0096] It should be noted that the YOLOv5s network structure includes a head network, a neck network, and a feature extraction backbone network. The AlexNet network is a classic 8-layer convolutional neural network (5 convolutional layers + 3 fully connected layers), whose convolutional layers excel at extracting low-level features such as edges and textures, as well as some mid-level semantic features. When the improved AlexNet network replaces the original CSPDarknet backbone network in the YOLOv5s network as the feature extraction backbone network, the fully connected layers (classification head) of the AlexNet network need to be removed, retaining only its 5 convolutional layers and pooling layers as feature extractors, replacing the original CSPDarknet backbone network (a deep network composed of CSP modules and residual connections) in the YOLOv5s network.
[0097] The improved AlexNet network retains the original five-layer convolutional structure, but adds a Batch Normalization (BN) layer after each convolutional layer for feature normalization. The single traffic light image processed in step 2 is resized to a standard input size of H×W×C, where H and W are the height and width of the input image, and C is the number of channels, and then input into the improved AlexNet network. For example, the input size is set to 224×224×3.
[0098] The first convolutional layer uses N1 convolutional kernels of size K1×K1 with a stride of S1 to extract features from the input image. After normalization by a BN layer and activation by a ReLU function, downsampling is performed through a max pooling layer. The large convolutional kernels in the first layer can capture the overall shape features and color distribution information of the traffic lights. For example, N1 is set to 96, K1 is set to 11, and S1 is set to 4.
[0099] The second convolutional layer uses N² kernels of size K²×K², with a stride of S² and padding of P². After BN and ReLU activation, it is downsampled again by a max-pooling layer. This layer extracts the mid-level texture features and local structural information of the traffic lights. For example, N² is set to 256 and K² is set to 5.
[0100] The third, fourth, and fifth convolutional layers use N3, N4, and N5 convolutional kernels of size K3×K3, respectively, with a stride of S3 and padding of P3. These three consecutive small-sized convolutional kernels can extract fine features of traffic lights, including key recognition information such as arrow direction and circular outline. A max-pooling layer is then applied after the fifth convolutional layer for feature dimensionality reduction. For example, N3 and N4 are set to 384, N5 to 256, and K3 to 3.
[0101] To extract multi-scale features, a multi-level parallel convolutional structure is constructed. Feature branches are drawn from the output positions of the third, fourth, and fifth convolutional layers, forming feature outputs at three different scales. The first-scale feature, F1, is extracted from the third convolutional layer and contains high-level semantic information and overall structural features of traffic lights. The number of channels is adjusted to C using a 1×1 convolution. out Thus, F1' = Conv 1×1 (F1). The second-scale feature F2 is extracted from the fourth convolutional layer, fusing feature information from the middle and high layers. It is also adjusted for the number of channels using a 1×1 convolution, resulting in F2' = Conv. 1×1 (F2). The third-scale feature F3 is extracted from the fifth convolutional layer and contains the finest local features. To align with other scale features, the feature map is expanded to a uniform size through an upsampling operation using bilinear interpolation: F3' = Upsample(F3).
[0102] Features from the three scales are integrated through feature fusion, using a weighted fusion strategy:
[0103] F multi =w1·F1'+w2·F2'+w3·F3'
[0104] Where w1, w2, and w3 are learnable weight parameters, satisfying w1 + w2 + w3 = 1, which are automatically adjusted during training through backpropagation. The fused multi-scale features Fmulti It retains both global structural information and local detailed features.
[0105] To further enhance the expressive power of the features, a feature enhancement unit is added after the multi-scale features. The feature enhancement unit consists of two convolutional layers, each followed by a BN layer and a ReLU activation function: F enhanced =Conv2(ReLU(BN(Conv1(F multi )))); where Conv1 and Conv2 represent the two convolution operations in the feature enhancement unit. The feature enhancement unit outputs three feature maps of different resolutions, denoted as and These multi-scale feature maps are generated through various convolution and sampling operations. They contain traffic light feature information ranging from coarse-grained to fine-grained.
[0106] The YOLOv5s network consists of a head network, a neck network, and a feature extraction backbone network. The neck network of the YOLOv5s network adopts the PANet structure, which combines upsampling and downsampling to fuse multi-scale features and solve the problem of small target detection accuracy. The head network outputs prediction results through convolutional layers, including bounding boxes, confidence scores, and class probabilities.
[0107] Improved AlexNet network output with three multi-scale feature maps and The neck network, directly connected to the YOLOv5s network, serves as the input to the subsequent detection head. The coupled architecture of the AlexNet and YOLOv5s networks fully leverages the lightweight advantages of AlexNet in feature extraction and the high efficiency of YOLOv5s in object detection.
[0108] This step significantly reduces the computational complexity of the AlexNet network by introducing a Batch Normalization (BN) layer, thereby improving its training speed and inference efficiency. The multi-layered parallel convolutional structure of the AlexNet network enables it to simultaneously capture both global semantic information and local detail features of a single traffic light. The constructed AlexNet-YOLOv5s model achieves an organic combination of a lightweight feature extractor and an efficient detection head, providing a solid feature foundation and an efficient detection framework for accurately recognizing traffic light signals in various complex scenarios.
[0109] Step 5: Using the YOLOv5s structure in the AlexNet-YOLOv5s model, classify and recognize multi-scale features, and fuse the classification results to generate traffic light recognition results.
[0110] The multi-scale feature map F extracted in step 4 s1 Fs2 and F s3 The data is input into the YOLOv5s detection head structure of the AlexNet-YOLOv5s model for accurate classification and recognition of traffic light status. The YOLOv5s detection head employs three detection branches at different scales, each corresponding to a feature map of different resolutions, enabling effective detection of targets of different sizes on traffic lights.
[0111] The first detection branch receives high-resolution feature map F. s1 This feature map retains rich spatial detail information, making it suitable for detecting small traffic light targets. The number of channels is adjusted to N1×(C+5) through 1×1 convolution, where N1 is the number of anchor boxes at this scale, C is the number of traffic light categories, including red, yellow, green, red left turn, green left turn, red right turn, green right turn, etc., and 5 represents the four coordinate parameters and one confidence score of the bounding box.
[0112] The second detection branch processes the medium-resolution feature map F. s2 By using the Feature Pyramid Network (FPN) structure, F s2 Compared with the upsampled F s3 Perform feature fusion: F' s2 =Conv(F s2 +Upsample(F s3 The fusion of features, where Upsample(·) represents a 2x upsampling operation and Conv represents a 3×3 convolution operation, incorporates semantic information from deeper layers and positional information from shallower layers, enhancing the detection capability for medium-sized traffic light targets.
[0113] The third detection branch processes the low-resolution feature map F. s3 This feature map has the largest receptive field and contains rich semantic information, making it suitable for detecting large traffic light targets. Through a path aggregation network (PAN) structure, F... s3 With the downsampled F' s2 Perform secondary fusion: F' s3 =Conv(F s3 +Downsample(F' s2 The function `Downsample(·)` represents a 2x downsampling operation. This bottom-up approach enhances the efficiency of feature propagation and improves the localization accuracy of large targets.
[0114] For each detection branch, calculate the classification confidence and location regression parameters of the predicted bounding box; the classification confidence is activated by the sigmoid function: in σ represents the raw score output by the network, and σ denotes the sigmoid function.
[0115] Position regression is represented by an offset relative to the anchor frame: b x =σ(t) x )+c x b y =σ(t) y )+c y , Where t x ,t y ,t w ,t h c is the offset predicted by the network. x ,c y p represents the coordinates of the top-left corner of the grid cell. w ,p h The width and height of the preset anchor frame.
[0116] To improve recognition accuracy, a focus loss function is introduced to replace the traditional cross-entropy loss, addressing the class imbalance problem in the traffic light dataset: L focal =-α t (1-p t ) γ log(p t ), where p t α represents the model's predicted probability for the correct class. t α is the category weighting factor, and γ is the focusing parameter. For example, α... t γ is set to 2 based on the reciprocal of the number of samples in each category.
[0117] Non-maximum suppression (NMS) is applied to the outputs of the three detection branches to remove duplicate detection boxes. An IoU threshold θ is set. iou and confidence threshold θ conf When the IoU of the two detection boxes is greater than θ iou At that time, retain the detection boxes with higher confidence.
[0118] When fusing multi-scale detection results, a weighted voting mechanism is used to determine the final traffic light status. For traffic lights at the same location, the weighted sum of the classification scores of each detection branch is calculated: Where w υ S is the weight of the υth detection branch, which is dynamically adjusted based on the branch's accuracy on the validation set. υ This is the classification score vector for this branch.
[0119] Select the category with the highest score as the final traffic light classification result: class = argmax(S final ).
[0120] This step, through the aforementioned multi-scale detection and fusion mechanism, enables the AlexNet-YOLOv5s model to fully utilize feature information at different levels, achieving accurate recognition of traffic lights of various sizes and states. The introduction of the focus loss function effectively addresses the class imbalance problem, improving the recognition accuracy for a few classes such as yellow lights and turn signals. The multi-scale fusion strategy integrates the advantages of different detection branches, significantly improving the accuracy and robustness of traffic light recognition while maintaining detection speed. This method demonstrates excellent recognition performance, providing reliable traffic light recognition technology support for intelligent transportation systems and autonomous driving applications.
[0121] Example 2
[0122] The second embodiment of this application improves the method for rapid recognition of traffic lights using a lightweight classifier coupled with a detection head, specifically by refining the YOLOv5s model for recognizing traffic light areas in road scene images.
[0123] When recognizing traffic light structures in road scene images, the YOLOv5s model outputs feature layers of three different scales: 20*20, 40*40, and 80*80, enabling effective detection of targets of different sizes. The 20*20 feature layer is primarily used to predict large targets because it contains higher-level semantic information and has a wider receptive field. Conversely, the 80*80 feature layer is mainly used to predict small targets because it contains shallower, finer-grained features. Targets of other sizes are predicted by the 40*40 feature layer.
[0124] Traffic lights typically occupy very few pixels in a road scene image, making them a typical small target for detection. In currently widely used models, they often face challenges in achieving poor detection results. This is mainly because the Yolov5s model's network architecture includes multiple convolutions and downsampling processes, further reducing the relative size of small targets in the image and thus lowering detection accuracy.
[0125] To address the issue of low accuracy in traffic light detection, this embodiment removes the 20*20 feature layer from the first YOLOv5s model network and adds a 160*160 small target detection layer for traffic lights, thereby enhancing the network's ability to detect small targets and improving the accuracy of traffic light detection.
[0126] To verify the impact of different attention mechanisms on the network performance of the first YOLOv5s model, this embodiment inserts four commonly used attention mechanisms—SE, CBMA, EMA, and CA—into the first YOLOv5s model network, and trains the improved YOLOv5s model accordingly. The experimental results are shown in Table 1.
[0127] Table 1. Comparison of experimental results for inserting four attention mechanisms into the first Yolov5s model.
[0128]
[0129]
[0130] As shown in Table 1, compared with the original YOLOv5s, the first YOLOv5s model with the addition of four attention mechanisms has improved recall and detection accuracy. Although the detection speed of the model has decreased, the decrease is very small and will not affect the real-time performance of the model.
[0131] Comparison of experimental data reveals that among the four added attention mechanisms, YOLOv5s-CA exhibits the best training results. Compared to the original YOLOv5s, YOLOv5s-CA improves the mean precision by 2.62% and recall by 1.6%; compared to YOLOv5s-SE, it improves the mean precision by 1.21% and recall by 0.94%; compared to YOLOv5s-EMA, it improves the mean precision by 1.5% and recall by 0.21%; and compared to YOLOv5s-CBAM, it improves the mean precision by 0.34% and recall by 0.15%. In conclusion, YOLOv5s-CA demonstrates the highest detection accuracy for traffic light detection. Therefore, adding the CA attention mechanism to the first YOLOv5s model can enhance model performance.
[0132] Example 3
[0133] Reference Figure 4 This is the third embodiment of the present application, which provides a traffic light rapid recognition system with a lightweight classifier coupled detection head.
[0134] The system includes: a region recognition module, a layout and cropping module, an image processing module, a composite network module, and a result recognition module.
[0135] The region recognition module acquires a road scene image containing traffic lights, improves the first YOLOv5s model by adding an attention mechanism and changing the target detection layer, and identifies the traffic light region image in the road scene image using the first YOLOv5s model.
[0136] The layout and cropping module determines the layout of the traffic light panels based on the aspect ratio of the traffic light area image, and uses the corresponding segmentation strategy to crop the traffic light image into independent individual traffic light images according to the layout.
[0137] The image processing module constructs a data consistency processing mechanism to perform cross-domain standardization and pseudo-reflection separation on a single traffic light image, unifying the color and brightness distribution of the image and suppressing highlights and shadows.
[0138] The composite network module replaces the backbone network in the second YOLOv5s model with an improved AlexNet network to construct an AlexNet-YOLOv5s model. A single traffic light image is input into the improved AlexNet network, and multi-scale features of the traffic light image are extracted through a multi-level parallel convolutional structure, which are then used as inputs to the YOLOv5s structure in the AlexNet-YOLOv5s model.
[0139] The result recognition module uses the YOLOv5s structure in the AlexNet-YOLOv5s model to classify and recognize multi-scale features and fuse the classification and recognition results to generate the traffic light recognition result.
[0140] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings or direct couplings or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0141] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments under the guidance of this application without departing from the spirit and scope of protection of the claims. All of these variations are within the protection scope of this application.
Claims
1. A traffic signal light fast recognition method of a light weight classifier coupled detection head, characterized in that, include: The first YOLOv5s model is improved by adding an attention mechanism and changing the object detection layer. The traffic light area in the road scene image is identified by the first YOLOv5s model. The arrangement of the traffic light panels is determined based on the aspect ratio of the traffic light area image. The corresponding segmentation strategy is then used to crop the traffic light image into individual traffic light images according to the arrangement. A data consistency processing mechanism is constructed to perform cross-domain standardization and pseudo-reflection separation on a single traffic light image, thereby unifying the image color and brightness distribution and suppressing highlights and shadows. The local response normalization layer in the original AlexNet network is replaced with a batch normalization algorithm. The batch normalization algorithm calculates the mean and variance on each batch of data, standardizes the features, and performs global normalization on the feature dimension. The improved AlexNet network retains the original five-layer convolutional structure, and adds a batch normalization layer after each convolutional layer to normalize the features; The improved AlexNet network was used as the feature extraction backbone network. The fully connected layers of the AlexNet network were removed, and only five convolutional layers and pooling layers were retained as feature extractors. The original CSPDarknet backbone network in the second YOLOv5s model was replaced to construct the AlexNet-YOLOv5s model. A multi-level parallel convolutional structure is constructed, and feature branches are drawn out from the output positions of the third, fourth and fifth convolutional layers of the improved AlexNet network to form feature outputs at three different scales. The features at the three scales are integrated through feature fusion, using a weighted fusion strategy, and the fusion weights are automatically adjusted through backpropagation during training. A feature enhancement unit is added after the multi-scale features to output three feature maps at different resolutions. A single traffic light image is input into an improved AlexNet network. Through a multi-level parallel convolutional structure, multi-scale features of the traffic light image are extracted and used as input to the YOLOv5s structure in the AlexNet-YOLOv5s model. By using the YOLOv5s structure in the AlexNet-YOLOv5s model, classification and recognition of multi-scale features are performed and the classification and recognition results are fused to generate traffic light recognition results.
2. The traffic signal light fast recognition method of claim 1, wherein The first YOLOv5s model was trained using a traffic scene dataset with labeled traffic light bounding boxes, which was then used to collect road scene images containing traffic lights by vehicle-mounted cameras. After receiving the acquired road scene image, the first YOLOv5s model identifies and labels the bounding boxes of the traffic light structure area, and crops the image with the bounding boxes of the traffic light area according to a fixed format as the traffic light area image.
3. The traffic signal light fast recognition method of claim 2, wherein Using the top left corner of the identified traffic light area image as the origin, a two-dimensional coordinate system containing x and y axes is constructed, with the x-axis positive to the right and the y-axis positive downwards. Two coordinate points, the upper left and lower right points, of the traffic light image bounding box are selected. The arrangement of the traffic lights is determined by calculating the difference between the width and height of the two coordinate points. When the difference is greater than 0, the width of the traffic light area is greater than its height, and the traffic light panel is arranged horizontally. When the difference is less than 0, the width of the traffic light area is less than its height, and the traffic light panel is arranged vertically.
4. The method for rapid traffic light recognition using a lightweight classifier coupled detection head according to claim 3, characterized in that, Based on the layout of the traffic lights, the traffic light image is divided into three equal parts using two straight lines; When the traffic light panel is arranged horizontally, two vertical dividing lines are used to divide the traffic light image into three equal parts; When the traffic light panel is arranged vertically, two horizontal dividing lines are used to divide the traffic light image into three equal parts.
5. The traffic signal light fast recognition method of claim 4, wherein, Cross-domain normalization is performed on the segmented individual traffic light images to convert them from the RGB color space to the LAB color space; In the LAB color space, the L channel represents luminance information, the A channel represents color components from green to red, and the B channel represents color components from blue to yellow. Adaptive histogram equalization is performed on the L channel, the cumulative distribution function of the L channel is calculated, and the luminance value is standardized to a preset range through a mapping function. The mean and standard deviation of channels A and B are calculated separately, and color normalization is performed to eliminate color shifts caused by different shooting conditions by using preset reference mean and standard deviation.
6. The traffic signal light fast recognition method of claim 5, wherein, For a single traffic light image, pseudo-reflection separation is performed using a reflection component separation method based on Retinex theory, which decomposes the image into the product of illuminance and reflection components. Illuminance components are estimated by multi-scale Gaussian filtering. Multiple Gaussian kernels with different standard deviations are used to convolve the image, and the estimated illuminance components are obtained by weighted summation. Calculate the reflectance component, perform dynamic range compression on the contrast component, and adaptively adjust the compression coefficient according to the dynamic range of the image; The processed illuminance and reflectance components are recombined to obtain the processed traffic light image.
7. The traffic signal light fast recognition method of claim 6, wherein, The YOLOv5s detection head of the AlexNet-YOLOv5s model uses three detection branches at different scales to receive feature maps at different resolutions. Non-maximum suppression is applied to the outputs of the three detection branches to remove duplicate detection boxes. A weighted voting mechanism is used to fuse the multi-scale detection results, calculate the weighted sum of the classification scores of each detection branch, and select the category with the highest score as the final traffic light classification and recognition result.
8. A traffic light rapid recognition system with a lightweight classifier coupled detection head, implemented according to any one of claims 1 to 7, characterized in that, include: The module includes a region recognition module, a layout and cropping module, an image processing module, a composite network module, and a result recognition module. The region recognition module acquires a road scene image containing traffic lights, improves the first YOLOv5s model by adding an attention mechanism and changing the target detection layer, and identifies the traffic light region image in the road scene image using the first YOLOv5s model. The layout and cropping module determines the layout of the light panels based on the aspect ratio of the traffic light area image, and uses the corresponding segmentation strategy to crop the traffic light image into independent individual traffic light images according to the layout. The image processing module constructs a data consistency processing mechanism to perform cross-domain standardization and pseudo-reflection separation on a single traffic light image, unifying the image color and brightness distribution and suppressing highlights and shadows. The composite network module replaces the backbone network in the second YOLOv5s model with an improved AlexNet network to construct an AlexNet-YOLOv5s model. A single traffic light image is input into the improved AlexNet network, and multi-scale features of the traffic light image are extracted through a multi-level parallel convolutional structure as input to the YOLOv5s structure in the AlexNet-YOLOv5s model. The result recognition module uses the YOLOv5s structure in the AlexNet-YOLOv5s model to classify and recognize multi-scale features and fuse the classification and recognition results to generate the traffic light recognition result.