Scene recognition model, scene recognition model training method and electronic equipment
By combining the core convolutional module and the fusion convolutional module, the features of dangerous areas in traffic scene images are enhanced, solving the problem of insufficient salient feature extraction in the recognition of dangerous traffic scenes by traditional convolutional networks, and realizing high-precision dangerous scene recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-06
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies suffer from insufficient extraction of salient features in the identification of dangerous traffic scenes. Traditional convolutional networks struggle to effectively distinguish between background noise and core dangerous targets, resulting in limited classification accuracy in dangerous scene identification.
Multi-scale feature extraction is performed using a core convolutional module, while the fusion convolutional module enhances key features of dangerous areas and suppresses background noise through a channel attention mechanism. Finally, accurate classification is achieved through a scene classification module.
It enables accurate identification of dangerous traffic scenarios, meets the high-precision requirements of autonomous driving and intelligent traffic monitoring, and improves the classification accuracy of dangerous scenario identification.
Smart Images

Figure CN121789157A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of traffic scene recognition, and in particular to a scene recognition model, a training method for the scene recognition model, and an electronic device. Background Technology
[0002] With the rapid development of autonomous driving and intelligent transportation systems, real-time analysis of traffic scenarios has become a core technological support for ensuring travel safety and improving traffic efficiency. Hazardous traffic scenario identification aims to accurately and quickly capture scenarios with safety risks, such as vehicle collisions, pedestrian intrusions, and sudden obstacles, from complex and ever-changing traffic environments. This provides reliable data for autonomous driving decision-making systems and intelligent traffic monitoring and early warning platforms, thereby triggering avoidance measures (such as automatic braking and path avoidance) and issuing safety warnings in advance, minimizing the incidence of traffic accidents.
[0003] In the field of dangerous traffic scene recognition (such as vehicle collisions, pedestrian intrusion, etc.), existing technologies mostly rely on traditional image processing or conventional deep learning models, but they generally suffer from insufficient extraction of salient features. Traditional convolutional networks often use feature extraction modules with fixed structures, which are difficult to effectively distinguish between background noise and core dangerous targets, ultimately resulting in limited classification accuracy for dangerous scene discrimination. Summary of the Invention
[0004] To solve the above-mentioned technical problems, or at least partially solve them, this application provides a scene recognition model, a training method for the scene recognition model, and an electronic device.
[0005] In the first aspect, this application provides a scene recognition model, including: a core convolutional module, a fusion convolutional module, and a scene classification module; The core convolutional module is used to extract multi-scale features from the input image to obtain a compact feature map. The input image is obtained after preprocessing the acquired traffic scene image. The fusion convolution module is used to extract spatial features from the compact feature map, enhance key features of dangerous areas in the traffic scene image through a channel attention mechanism, suppress background noise, and obtain a scene enhancement feature map. The fusion convolution module includes: a spatial convolution unit, an attention enhancement unit, and a channel adjustment unit; The spatial convolutional unit is used to extract spatial features from the compact feature map to obtain a spatial feature map; The attention enhancement unit is used to obtain the first channel weight corresponding to each channel, multiply each channel of the spatial feature map by the corresponding first channel weight to obtain a low-level saliency feature map, wherein the first channel weight of the dangerous area in the traffic scene image is greater than the first channel weight of the non-dangerous area in the traffic scene image. The channel adjustment unit is used to adjust the number of channels in the low-level saliency feature map to obtain the scene enhancement feature map; The scene classification module is used to classify the scene enhanced feature map to obtain the probability that the scene enhanced feature map belongs to the dangerous traffic scene category; The scene recognition model is further configured to: obtain a scaling factor, adjust the number of layers of the core convolutional module and the fusion convolutional module based on the scaling factor, adjust the number of channels of the core convolutional module and the fusion convolutional module based on the scaling factor, and adjust the resolution of the traffic scene image based on the scaling factor.
[0006] Optionally, the spatial convolution unit is used to extract spatial features from the compact feature map using a regular 3x3 convolution to obtain a spatial feature map; The channel adjustment unit is used to adjust the number of channels in the low-level saliency feature map using 1x1 convolution to obtain the scene enhancement feature map.
[0007] Optionally, the attention enhancement unit includes: a first channel weight generation unit, a first feature weighting unit, and a first residual optimization unit; The first channel weight generation unit is used to perform global average pooling on the spatial feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the first channel weight for each channel. The first feature weighting unit is used to multiply each channel of the spatial feature map by its corresponding first channel weight to obtain a first weighted feature map; The first residual optimization unit is used to perform residual processing on the first weighted feature map to obtain the low-level saliency feature map.
[0008] Optionally, the core convolutional module includes: an expansion unit, a depthwise convolutional unit, a channel attention unit, and a compression unit; The expansion unit is used to expand the number of input channels of the input image from the original dimension to the first dimension using 1x1 convolution, extract high-dimensional features from the input image, and output a high-dimensional feature map. The depthwise convolutional unit is used to perform spatial convolution independently on each channel of the high-dimensional feature map using 3x3 depthwise separable convolution, keeping the number of channels unchanged, and outputting a depthwise feature map. The channel attention unit is used to obtain the second channel weights corresponding to each channel, and multiply each channel of the depth feature map by the corresponding second channel weights to obtain a high-level saliency feature map. The second channel weights of dangerous areas in the traffic scene image are greater than the second channel weights of non-dangerous areas in the traffic scene image. The compression unit is used to compress the number of channels of the high-level saliency feature map from the first dimension back to the original dimension using a 1x1 convolution to obtain the compact feature map.
[0009] Optionally, the channel attention unit includes: a second channel weight generation unit, a second feature weighting unit, and a second residual optimization unit; The second channel weight generation unit is used to perform global average pooling on the depth feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the second channel weight for each channel. The second feature weighting unit is used to multiply each channel of the depth feature map by the corresponding second channel weight to obtain the second weighted feature map; The second residual optimization unit is used to perform residual processing on the second weighted feature map to obtain the high-level saliency feature map.
[0010] Secondly, this application provides a method for training a scene recognition model, including: Obtain a training dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; The traffic scene images in the training dataset are preprocessed to obtain multiple input images; The input image is input into the scene recognition model as described in any of the first aspects, so that the scene recognition model outputs a predicted probability that the input image is a dangerous traffic scene category; Obtain the category weights corresponding to the dangerous traffic scene categories and the focusing parameters corresponding to the degree of focus on the dangerous traffic scene categories; The predicted probability, the category weight, and the focusing parameter are input into the focus loss function to obtain the focus loss value; If the focus loss value is less than a preset loss value threshold, the scene recognition model is considered to have completed training.
[0011] Optionally, obtaining the category weights corresponding to the dangerous traffic scene categories and the focusing parameters corresponding to the degree of focus on the dangerous traffic scene categories includes: Obtain the initial weights corresponding to the dangerous traffic scene categories and the initial parameters corresponding to the degree of focus on the dangerous traffic scene categories; Obtain a verification dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; Each traffic scene image in the validation dataset is input into the scene recognition model so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene; The recall rate of the scene recognition model is determined based on the probability label and predicted probability of each traffic scene image; If the recall rate is less than a preset recall rate threshold, the initial weight is adjusted to obtain the category weight, and the initial parameters are adjusted to obtain the focus parameters.
[0012] Thirdly, this application provides a scene recognition method, including: Acquire traffic scene images captured by vehicles; The traffic scene image is preprocessed to obtain the input image; The input image is input into a scene recognition model as described in any of the first aspects, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene.
[0013] Fourthly, this application provides a training apparatus for a scene recognition model, comprising: The first acquisition module is used to acquire a training dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; The first preprocessing module is used to preprocess the traffic scene images in the training dataset to obtain multiple input images; The first input module is used to input the input image into the scene recognition model as described in any of the first aspects, so that the scene recognition model outputs a predicted probability that the input image is a dangerous traffic scene category; The second acquisition module is used to acquire the category weights corresponding to the dangerous traffic scene categories and the focus parameters corresponding to the degree of focus on the dangerous traffic scene categories; The second input module is used to input the predicted probability, the category weight, and the focusing parameter into the focus loss function to obtain the focus loss value; The first determining module is used to determine that the scene recognition model has been trained if the focus loss value is less than a preset loss value threshold.
[0014] Fifthly, this application provides a scene recognition device, comprising: The third acquisition module is used to acquire traffic scene images collected by the vehicle; The second preprocessing module is used to preprocess the traffic scene image to obtain the input image; The third input module is used to input the input image into the scene recognition model as described in any of the first aspects, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene.
[0015] Sixthly, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the training method of the scene recognition model as described in the second aspect of claim, or the scene recognition method as described in the third aspect.
[0016] The beneficial effects of this invention are: This application embodiment efficiently extracts multi-scale features through a core convolution module, enhances key features of dangerous areas in the traffic scene image by fusing convolution modules, suppresses background noise, and effectively distinguishes between background noise and dangerous targets. The scene classification module then performs classification based on the scene enhancement feature map, which can accurately output the classification probability, realize the accurate identification of dangerous traffic scenes, and meet the high-precision requirements of autonomous driving and intelligent traffic monitoring. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A structural diagram of a scene recognition model provided in an embodiment of this application; Figure 2 A flowchart illustrating a training method for a scene recognition model provided in an embodiment of this application; Figure 3 for Figure 2 Flowchart of step S104; Figure 4 A flowchart illustrating a scene recognition method provided in an embodiment of this application; Figure 5 A structural diagram of a training device for a scene recognition model provided in an embodiment of this application; Figure 6 This is a structural diagram of a scene recognition device provided in an embodiment of this application; Figure 7 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] In the field of dangerous traffic scene recognition (such as vehicle collisions, pedestrian intrusion, etc.), existing technologies mostly rely on traditional image processing or conventional deep learning models, but they generally suffer from insufficient extraction of salient features. Traditional convolutional networks often use feature extraction modules with fixed structures, which are difficult to effectively distinguish between background noise and core dangerous targets, ultimately limiting the classification accuracy of dangerous scene identification. To address this, embodiments of this application provide a scene recognition model, a training method for the scene recognition model, and an electronic device, aiming to efficiently extract features, enhance saliency, and optimize the allocation of computing resources.
[0022] This application provides a scene recognition model, such as Figure 1 As shown, the network structure of the scene recognition model includes: a core convolutional module (CoreConv), a fusion convolutional module (FusedConv), and a scene classification module; The core convolutional module is used to extract multi-scale features from the input image to obtain a compact feature map. The input image is obtained after preprocessing the acquired traffic scene image. In this embodiment, multi-scale feature extraction refers to capturing image features of different sizes and levels, covering low-level features such as edges and textures as well as high-level features such as target categories; compact feature map refers to a feature map with compact dimensions and less redundant information after channel compression; preprocessing refers to the standardization processing performed on the original traffic scene image; traffic scene image refers to the road and surrounding environment image collected by vehicles or monitoring equipment.
[0023] The core convolutional module is a lightweight unit designed for efficient feature extraction from dangerous scenes. It adopts an inverted bottleneck structure to capture multi-scale features with low computational cost. It expands the number of input image channels through 1x1 convolution, extracts features through 3x3 depthwise separable convolution, enhances dangerous area features through channel attention mechanism, and finally compresses the number of channels with 1x1 convolution to output a compact feature map.
[0024] The fusion convolution module is used to extract spatial features from the compact feature map, enhance key features of dangerous areas in the traffic scene image through a channel attention mechanism, suppress background noise, and obtain a scene enhancement feature map. In this embodiment, spatial features refer to spatially related features such as the location and shape of dangerous targets in the image, such as fast-moving pedestrians, vehicle lights, etc.; channel attention mechanism refers to the mechanism of dynamically adjusting the weight of each feature channel; dangerous area refers to areas with safety risks such as vehicle collisions and pedestrian intrusions; key features refer to core features that can distinguish dangerous areas from non-dangerous areas; background noise refers to irrelevant interference information such as roads and sky; scene enhancement feature map refers to a feature map where key features are prominent and noise is suppressed.
[0025] The fusion convolution module is a feature extraction unit designed for complex traffic scenarios. It uses a 3x3 ordinary convolution to extract the spatial features of the core convolution module, i.e., the compact feature map. Compared with depthwise separable convolution, the ordinary 3x3 convolution retains more spatial information. The extracted features are input into the channel attention module to calculate the channel weights. By multiplying the weights with the feature map channel by channel, the features of dangerous areas are enhanced, background noise is suppressed, and a scene enhancement feature map is obtained, which directly captures spatial details and enhances the adaptability of dynamic scenes.
[0026] The scene classification module is used to classify the scene enhancement feature map and obtain the probability that the scene enhancement feature map belongs to the dangerous traffic scene category.
[0027] In this embodiment of the application, scene classification refers to determining whether the scene corresponding to the feature map is a dangerous traffic scene; dangerous traffic scene refers to a scene that may cause a traffic accident; probability refers to the possibility value of the feature map belonging to the dangerous traffic scene category, and the value range is [0, 1].
[0028] The scene classification module processes the scene enhancement feature map through convolutional layers and global average pooling layers, and then outputs the probability of dangerous traffic scene category through a fully connected layer.
[0029] This application embodiment efficiently extracts multi-scale features through a core convolution module, enhances key features of dangerous areas in the traffic scene image by fusing convolution modules, suppresses background noise, and effectively distinguishes between background noise and dangerous targets. The scene classification module then performs classification based on the scene enhancement feature map, which can accurately output the classification probability, realize the accurate identification of dangerous traffic scenes, and meet the high-precision requirements of autonomous driving and intelligent traffic monitoring.
[0030] Because traditional convolutional networks often employ feature extraction modules with fixed structures, they struggle to distinguish between background noise and critical hazardous targets (such as obstacles and collision points) in complex and ever-changing traffic environments. This results in insufficient extraction of salient features from key local areas, thus limiting the classification accuracy of hazardous scene identification. Therefore, in another embodiment of this application, the fusion convolutional module includes: a spatial convolutional unit, an attention enhancement unit, and a channel adjustment unit. The spatial convolutional unit is used to extract spatial features (such as fast-moving pedestrians and vehicles) from the compact feature map using ordinary 3x3 convolution to obtain the spatial feature map. In this embodiment of the application, ordinary 3x3 convolution refers to the standard convolution operation with a kernel size of 3x3, a stride of 1, and padding of 1; spatial feature map refers to a feature map mainly composed of spatial features.
[0031] The spatial convolution unit uses ordinary 3x3 convolution to perform convolution operations on the compact feature map, directly capturing the spatial features within it while keeping the feature map size unchanged, and outputting the spatial feature map.
[0032] For example, the spatial convolutional unit uses a standard 3x3 convolution as the primary operator to directly extract spatial features (such as fast-moving pedestrians and vehicles). The kernel size is 3x3, the stride is 1, and the padding is 1, ensuring that the feature map size remains unchanged. Mathematically, this can be expressed as:
[0033] in, The output of the core convolutional module (CoreConv) has a dimension of . H×W× , The output of spatial convolution. : 3×3 convolution kernel for the spatial convolution part.
[0034] In this embodiment, the Swish activation function can be used after the spatial convolution unit and before the attention enhancement unit. Compared with ReLU, it provides a smoother gradient and improves the ability to represent deep features.
[0035] The attention enhancement unit is used to obtain the first channel weight corresponding to each channel, multiply each channel of the spatial feature map by the corresponding first channel weight to obtain a low-level saliency feature map, wherein the first channel weight of the dangerous area in the traffic scene image is greater than the first channel weight of the non-dangerous area in the traffic scene image. In this embodiment of the application, the first channel weight refers to the numerical value assigned to each channel of the spatial feature map to adjust the importance of the channel; the low-level saliency feature map refers to the feature map that highlights low-level saliency features such as edges and textures; and the non-dangerous area refers to a normal traffic area without safety risks.
[0036] The attention enhancement unit performs global average pooling on the spatial feature map to generate a global feature vector. It calculates the first channel weight of each channel through two 1x1 convolutions and multiplies each channel of the spatial feature map with its corresponding weight channel by channel to obtain a low-level saliency feature map.
[0037] For example, the input to the attention enhancement unit (CAM) is the feature map output by the spatial convolution. Channel weights are calculated based on the saliency of the features. and with Channel-by-channel multiplication is performed, and key features (such as vehicle edges) are enhanced through dynamic weighting while suppressing background noise, resulting in a low-level saliency feature map. Keeping the dimensions constant, the mathematical expression is: = ,
[0038] The Attention Enhancement Unit (CAM) is a lightweight channel attention mechanism designed to enhance the salience of critical areas in hazardous scenes. By dynamically weighting feature channels, it highlights the attention to hazardous targets. In other words, in the shallow stage, CAM enhances the geometric edges and texture details of hazardous targets (such as the outline of pedestrians, the edges of vehicles, etc.).
[0039] In one embodiment of this application, the attention enhancement unit includes: a first channel weight generation unit, a first feature weighting unit, and a first residual optimization unit; The first channel weight generation unit is used to perform global average pooling on the spatial feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the first channel weight for each channel. In this embodiment, global average pooling refers to averaging all elements of each channel in the feature map to compress spatial information; global feature vector refers to the vector representing the global information of the corresponding channel obtained through global average pooling; dependency refers to the degree of correlation between the global feature vectors of each channel; feature saliency calculation refers to the process of evaluating and quantifying the importance of each channel feature to the identification of dangerous scenarios.
[0040] The first channel weight generation unit first performs global average pooling on the spatial feature map to obtain the global feature vector of each channel. Then, it learns the inter-channel dependencies through a bottleneck structure constructed by two layers of 1x1 convolutions, and calculates the first channel weight of each channel by combining the sigmoid activation function.
[0041] The first channel weight generation unit performs global average pooling (GAP) on the spatial feature map to generate channel-dimensional feature vectors:
[0042] in, For the input feature map, This represents the global feature of the c-th channel.
[0043] Channel weights are calculated using two 1×1 convolutional layers:
[0044] in, , The dimensionality reduction ratio r is set to 16 (which can be dynamically adjusted). Channel dimensionality reduction (e.g., ratio = 16) is used to balance computational load and performance. After dimensionality reduction, the number of parameters in the fully connected layer is only [amount missing]. , It is the sigmoid activation function. Global feature vector The set of terms, b1 and b2 are bias terms.
[0045] Between two 1×1 convolutional layers (i.e. after the activation function of the dimensionality reduction layer), the fully connected layer is regularized by dropout to prevent overfitting.
[0046] It supports dynamically adjusting the complexity of the weight generation network. For example, a higher dimensionality reduction ratio (e.g., r=32) can be used on mobile / embedded devices to reduce computation and latency; while a lower dimensionality reduction ratio (e.g., r=8) can be used on high-performance servers to pursue higher feature capture accuracy.
[0047] The first feature weighting unit is used to multiply each channel of the spatial feature map by its corresponding first channel weight to obtain a first weighted feature map; In this embodiment of the application, the first weighted feature map refers to the feature map obtained by multiplying each channel of the spatial feature map by the weight of the corresponding first channel.
[0048] The first feature weighting unit performs element-wise multiplication of each channel element of the spatial feature map with the corresponding first channel weight according to the channel dimension, thereby strengthening the features of high-weight channels and weakening the features of low-weight channels, and thus obtaining the first weighted feature map.
[0049] The first feature weighting unit assigns channel weights. Multiply by the spatial feature map to enhance the response in hazardous areas (such as pedestrians and obstacles) and suppress background interference (such as roads and sky):
[0050] The first residual optimization unit is used to perform residual processing on the first weighted feature map to obtain the low-level saliency feature map.
[0051] In this embodiment of the application, residual processing refers to the operation of adding the original input features to the processed features while retaining the original feature information; low-level saliency feature map refers to the feature map with more prominent saliency features and more complete information after residual processing.
[0052] The first residual optimization unit adds the first weighted feature map and the spatial feature map element by element to achieve residual connection, retain the original feature information, and outputs a low-level saliency feature map.
[0053] Introducing residual connections preserves original features and avoids information loss:
[0054] Where X' is the output of CAM processing, and X is the input of CAM.
[0055] This implementation uses a first channel weight generation unit to accurately calculate channel weights, a first feature weighting unit to enhance dangerous area features, and a first residual optimization unit to retain original feature information. This makes the low-level saliency feature map output by the attention enhancement unit both highly saliency and complete, providing high-quality feature support for subsequent scene classification and improving the accuracy of dangerous traffic scene recognition.
[0056] The channel adjustment unit is used to adjust the number of channels in the low-level saliency feature map using 1x1 convolution to obtain the scene enhancement feature map.
[0057] In this embodiment, channel adjustment refers to changing the number of channels in the feature map through convolution operations to optimize the feature distribution.
[0058] The channel adjustment unit uses 1x1 convolution to reduce the dimensionality of low-level salient feature maps, reduce redundant channels, optimize feature distribution, reduce redundant information, and output scene-enhanced feature maps.
[0059]
[0060] in, The output of the fused convolutional module (FusedConv) has a dimension of . H×W× .
[0061] Subsequently, this application preserves the original features through residual connections (skip connections) to alleviate the gradient vanishing problem in deep networks, mathematically expressed as (ensuring dimensional consistency):
[0062] This application embodiment accurately extracts spatial features through spatial convolution units, enhances low-level salient features in dangerous areas through attention enhancement units, and optimizes the distribution of feature channels through channel adjustment units. This makes the scene enhancement feature map output by the fusion convolution module prominent and less redundant, improving the accuracy of subsequent scene classification, assisting in the efficient identification of dangerous traffic scenes, and improving the detection capability of low-light or blurred targets.
[0063] To improve detection accuracy, some deep learning models (such as the Transformer based on global attention) introduce a huge number of parameters and computational redundancy when processing high-resolution traffic scene images, resulting in increased computational complexity and failing to meet the stringent requirements of intelligent transportation systems for millisecond-level real-time response (typically less than 10ms). Therefore, in another embodiment of this application, the core convolutional module includes: an expansion unit, a depthwise convolutional unit, a channel attention unit, and a compression unit. The expansion unit is used to expand the number of input channels of the input image from the original dimension to the first dimension using 1x1 convolution, extract high-dimensional features from the input image, and output a high-dimensional feature map. In this embodiment, 1x1 convolution refers to a convolution operation with a kernel size of 1x1, used to adjust the number of channels; the original dimension refers to the initial number of channels in the input image; the first dimension refers to the number of channels in the expanded input image, which can be, for example, four times the original dimension; high-dimensional features refer to features containing richer semantic information; and high-dimensional feature maps refer to feature maps rich in high-dimensional features after the number of channels is expanded.
[0064] The extended unit uses a 1x1 convolutional layer to perform convolution operations on the input image, expanding the number of input channels to a preset first dimension to achieve high-dimensional feature extraction and output a high-dimensional feature map.
[0065] For example, for the input feature map as Its dimensions H×W× This method expands the number of input channels to a higher dimension (e.g., from 64 to 256) through 1x1 convolutions, extracting rich high-dimensional features. The expansion factor is typically set to 4, and the output feature map... The dimension becomes H×W× The mathematical expression is:
[0066] in, : Represents the weight matrix of the 1x1 convolutional layer in the expansion stage. : Indicates the number of channels in the input feature map. : Represents the high-dimensional feature map after dimensionality enhancement.
[0067] The depthwise convolutional unit is used to perform spatial convolution independently on each channel of the high-dimensional feature map using 3x3 depthwise separable convolution, keeping the number of channels unchanged, and outputting a depthwise feature map. In this embodiment of the application, 3x3 depthwise separable convolution refers to the operation of splitting standard convolution into depthwise convolution and pointwise convolution, where depthwise convolution only performs spatial convolution on a single channel; depth feature map refers to the feature map obtained after processing by depthwise separable convolution.
[0068] The depthwise convolutional unit uses 3x3 depthwise separable convolutions to process high-dimensional feature maps. Each convolutional kernel operates on only one channel, independently extracting spatial features (such as fast-moving pedestrians and vehicles), thus maintaining the number of channels and high-dimensional features. Figure 1 Output a depth feature map.
[0069] For example, the input high-dimensional feature map is Using 3x3 depthwise separable convolutions reduces computation by performing spatial convolutions independently on each channel, thus reducing the number of parameters compared to standard convolutions. Reduce to (in, k (3), keeping the number of channels constant, the output depth feature map at this time The dimension is still H×W×
[0070] Compared to standard convolution, depthwise separable convolution decouples spatial and channel correlations, consisting of two sub-operations: depthwise convolution and pointwise convolution. Depthwise convolution performs filtering only in the spatial dimension, with each kernel operating on only one input channel, focusing on capturing spatial location features without involving inter-channel interactions. In contrast, pointwise convolution (i.e., 1×1 convolution) performs linear combination only in the channel dimension, fusing the features extracted by depthwise convolution across channels using 1×1 kernels to construct a new feature space, significantly reducing computational cost.
[0071] The channel attention unit is used to obtain the second channel weights corresponding to each channel, and multiply each channel of the depth feature map by the corresponding second channel weights to obtain a high-level saliency feature map. The second channel weights of dangerous areas in the traffic scene image are greater than the second channel weights of non-dangerous areas in the traffic scene image. In this embodiment of the application, the second channel weight refers to the weight value assigned to each channel of the depth feature map; the high-salience feature map refers to the feature map that highlights high-salience features such as target category.
[0072] The channel attention unit performs global average pooling on the deep feature map to generate a global feature vector. It learns the dependencies between channels through two layers of 1x1 convolution, calculates the second channel weight of each channel, and multiplies each channel of the deep feature map with its corresponding weight to obtain a high-level saliency feature map.
[0073] For example, the depth feature map after depth convolution The input channel attention module (CAM) extracts the global context by compressing spatial information through global average pooling and automatically learns the dependencies between channels to obtain feature saliency through a bottleneck structure built with two 1x1 convolutional layers, thereby calculating the channel weights. and with Channel-by-channel multiplication is performed to enhance the feature response to hazardous areas (such as vehicles and pedestrians) while suppressing background noise. The output is a high-level saliency feature map. The dimension remains as H×W×
[0074] = ,
[0075] Attention Enhancement Unit (CAM) is a lightweight channel attention mechanism designed to enhance the salience of critical areas in hazardous scenes. By dynamically weighting feature channels, it highlights the attention to hazardous targets. In other words, at a deeper level, CAM enhances the high-level semantic features of hazardous targets (such as the categories of hazardous targets like vehicles and pedestrians).
[0076] In one embodiment of this application, the channel attention unit includes: a second channel weight generation unit, a second feature weighting unit, and a second residual optimization unit; The second channel weight generation unit is used to perform global average pooling on the depth feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the second channel weight for each channel. In this embodiment of the application, the second channel weight refers to the numerical value assigned to each channel of the depth feature map to measure the importance of the channel.
[0077] The second channel weight generation unit first performs global average pooling on the deep feature map to obtain the global feature vector of each channel. Then, it learns the channel dependencies through two layers of 1x1 convolution with a dimensionality reduction ratio of 16, and outputs the second channel weights of each channel through the sigmoid activation function.
[0078] The second channel weight generation unit performs global average pooling (GAP) on the depth feature map to generate channel-dimensional feature vectors:
[0079] in, For the input feature map, This represents the global feature of the c-th channel.
[0080] Channel weights are calculated using two 1×1 convolutional layers:
[0081] in, , The dimensionality reduction ratio r is set to 16 (which can be dynamically adjusted). Channel dimensionality reduction (e.g., ratio = 16) is used to balance computational load and performance. After dimensionality reduction, the number of parameters in the fully connected layer is only [amount missing]. , It is the sigmoid activation function. Global feature vector The set of terms, b1 and b2 are bias terms.
[0082] In this embodiment, after pointwise convolution, batch normalization and ReLU activation functions can be used to ensure training stability and non-linear expressive power. Between two 1×1 convolutional layers (i.e. after the activation function of the dimensionality reduction layer), dropout regularization can also be used to regularize the fully connected layer to prevent overfitting.
[0083] It supports dynamically adjusting the complexity of the weight generation network. For example, a higher dimensionality reduction ratio (e.g., r=32) can be used on mobile / embedded devices to reduce computation and latency; while a lower dimensionality reduction ratio (e.g., r=8) can be used on high-performance servers to pursue higher feature capture accuracy.
[0084] The second feature weighting unit is used to multiply each channel of the depth feature map by the corresponding second channel weight to obtain the second weighted feature map; In this embodiment of the application, the second weighted feature map refers to the feature map obtained by multiplying each channel of the depth feature map with the corresponding weight of the second channel.
[0085] The second feature weighting unit multiplies each element of the depth feature map with the corresponding weight of the second channel one by one, thereby enhancing the feature response of the high-weight channels and obtaining the second weighted feature map.
[0086] The second feature weighting unit assigns channel weights. Multiply by the depth feature map to enhance the response in hazardous areas (such as pedestrians and obstacles) and suppress background interference (such as roads and sky):
[0087] The second residual optimization unit is used to perform residual processing on the second weighted feature map to obtain the high-level saliency feature map.
[0088] In this embodiment of the application, the high-level saliency feature map refers to the feature map that has more prominent high-level saliency features and more complete information after residual processing.
[0089] The second residual optimization unit adds the second weighted feature map to the depth feature map element by element to achieve residual connection, retain the original depth feature information, and outputs a high-level saliency feature map.
[0090] Introducing residual connections preserves original features and avoids information loss:
[0091] Where X' is the output of CAM processing, and X is the input of CAM.
[0092] This implementation uses a second channel weight generation unit to accurately quantify the importance of channels, a second feature weighting unit to enhance high-level features of dangerous areas, and a second residual optimization unit to ensure the integrity of feature information. This enables the high-level saliency feature map output by the channel attention unit to accurately highlight the core features of dangerous areas, improve the feature extraction quality of the core convolution module, and thus improve the accuracy of dangerous traffic scene recognition.
[0093] The compression unit is used to compress the number of channels of the high-level saliency feature map from the first dimension back to the original dimension using a 1x1 convolution to obtain the compact feature map.
[0094] In this embodiment of the application, the first dimension refers to the number of channels in the high-level saliency feature map, which can be consistent with the first dimension, for example; the original dimension refers to the initial number of channels in the input image.
[0095] The compression unit uses 1x1 convolution to perform convolution operations on the high-level salient feature map, compressing the number of channels from the first dimension to the original dimension of the input image, removing redundant information, and outputting a compact feature map.
[0096] The input is the feature map after depthwise convolution. By using 1x1 convolutions to compress the number of channels back to the original dimension (e.g., from 256 to 64), a compact feature map is generated, and the final output is... The dimensions are restored to H×W× :
[0097] in, : Represents the compact feature map output by the core convolutional module.
[0098] Subsequently, the original features can be preserved through residual connections (skip connections), alleviating the gradient vanishing problem in deep networks. Mathematically, this can be expressed as (ensuring dimensional consistency):
[0099] This implementation extracts high-dimensional features through an extension unit, captures spatial features with low computational cost through a deep convolution unit, enhances high-level features in dangerous areas through a channel attention unit, and optimizes feature dimensions through a compression unit, thus realizing a lightweight core convolution module. This allows the core convolution module to output high-quality, compact feature maps while maintaining high computational efficiency, reducing computational complexity and laying the foundation for subsequent feature fusion and classification, while balancing the accuracy and real-time performance of dangerous traffic scene recognition.
[0100] To improve detection accuracy, some deep learning models (such as the Transformer based on global attention) introduce a huge number of parameters and computational redundancy when processing high-resolution traffic scene images, leading to increased computational complexity and failing to meet the stringent requirements of intelligent transportation systems for millisecond-level real-time response (typically less than 10ms). Therefore, in another embodiment of this application, the scene recognition model is further configured to: obtain scaling factors; adjust the number of layers in the core convolutional module and the fusion convolutional module based on the scaling factors; adjust the number of channels in the core convolutional module and the fusion convolutional module based on the scaling factors; and adjust the resolution of the traffic scene image based on the scaling factors. This allows for dynamic adjustment of the network structure (number of layers, number of channels, resolution) to optimize parameter distribution and adapt to complex traffic scenes.
[0101] In this embodiment, the scaling factor refers to the proportional coefficient used to adjust the network structure parameters, including the layer scaling factor α, the channel scaling factor β, and the resolution scaling factor γ. Layer adjustment refers to changing the number of network layers in the core convolutional module and the fusion convolutional module to adapt to task requirements. Channel adjustment refers to changing the number of channels in each layer of the core convolutional module and the fusion convolutional module to balance feature expressiveness and computational load. Resolution adjustment refers to changing the resolution of the input traffic scene image to balance detection accuracy and computational efficiency.
[0102] The scene recognition model determines the appropriate layer scaling factor α, channel scaling factor β, and resolution scaling factor γ based on the computing performance of the target hardware platform, task complexity, and dataset conditions.
[0103] Layer adjustment: Dynamically configure the stacking number of core convolutional modules and fusion convolutional modules according to task complexity. For tasks with few samples in dangerous scenarios, the shallow fusion convolutional modules are preferentially increased in number (e.g., from 2 layers to 4 layers) to enhance the extraction of low-level features (such as edges and textures); the deep core convolutional modules are kept with fewer layers (e.g., 3 layers) to avoid overfitting.
[0104] In practical applications, task complexity is determined by the performance feedback of the search algorithm on the validation set. The specific logic is as follows: train the model on the training set, evaluate it on the validation set, and determine the highest-scoring combination of α, β, and γ as the final scaling factors. Here, the dataset refers to both the training set and the validation set. The training set is used to train candidate models with different configurations, and the validation set determines which set of parameters is best. The inference phase does not require a dataset; instead, it takes the image to be assessed for danger as input and outputs whether the image is dangerous.
[0105] The optimal number of layers is determined using a grid search algorithm. The search range for the number of layers in each stage is set to [4, 8] (i.e., trying five configurations: 4, 5, ..., 8 layers). Here, [4, 8] refers to the range of values for the number of convolutional layers in each stage of the network. Grid search means that the system automatically traverses all integer layer configurations within this range (4, 5, 6, 7, 8) and finds the optimal solution through validation set testing. The system iterates through all layers within this range and evaluates their performance (Score) using the validation set, ultimately selecting the set of layers with the highest overall score as the fixed configuration.
[0106] The scene recognition model uses the layer scaling factor α and the base layer number Lbase, through the formula:
[0107] in, Basic layer number, This is the scaling factor (adjustable based on the computational performance of the target hardware platform, depending on the task and dataset). For small-scale or simple scenario datasets (e.g., fewer than 5000 samples), set... ≈1.0, maintaining the basic number of layers to prevent overfitting; for large-scale complex scene datasets (e.g., more than 50,000 samples), set... ∈[1.2,1.4], increase network depth to improve feature extraction capacity.
[0108] Channel Count Adjustment: The scene recognition model dynamically adjusts the number of channels per layer using a scaling factor. For example, with a base channel count of 32, the scaling range is [0.8, 1.4]. Shallow FusedConv modules allocate more channels (e.g., 1.2 times, approximately 38 channels) to capture richer details; deeper CoreConv modules reduce the number of channels (e.g., 0.9 times, approximately 29 channels) to decrease computation. The scene recognition model adjusts the channel count based on the channel count scaling factor β and the base channel count Cbase using the formula:
[0109] in, Based on the number of channels, This is a scaling factor (adjustable based on the target hardware platform's computing performance, depending on the task and dataset).
[0110] Resolution Adjustment: The input image resolution is dynamically selected based on hardware performance and task requirements, for example, ranging from 224x224 to 320x320. Higher resolution (320x320) improves the detection capability of small targets (such as pedestrians at a distance); lower resolution (224x224) reduces computation by approximately 30%, suitable for real-time scenarios. The scene recognition model uses the resolution scaling factor γ and the base resolution Rbase, through the formula:
[0111] in, Based on resolution, This is a scaling factor (adjustable based on the target hardware platform's computing performance, depending on the task and dataset).
[0112] The number of layers, channels, and resolution are adjusted using a composite scaling formula:
[0113] in, , , These are scaling factors for the number of layers, channels, and resolution, respectively, with constraints ensuring that the total computational load increases in a manageable manner (e.g., approximately 2 times).
[0114] The optimization process uses a random search to explore the parameter space, trying several combinations. The evaluation criteria are as follows:
[0115] in, Indicates accuracy rate. Indicates recall rate, Indicates the time of reasoning. , and It's the ratio of factors considered, which can be set. and The larger the value, the more priority is given to accuracy and recall.
[0116] This application embodiment obtains an appropriate scaling factor, dynamically adjusts the number of layers and channels of the core convolutional module and the fusion convolutional module, as well as the resolution of the traffic scene image, optimizes the distribution of network parameters, and adapts to different hardware platforms and task scenarios while controlling the growth of computational load. This improves the model's robustness to imbalanced data and its real-time response capability, ensuring the efficiency and adaptability of dangerous traffic scene recognition.
[0117] In real-world traffic scenarios, the number of safe scenario samples far exceeds that of dangerous scenario samples (typically a ratio as high as 20:1). This causes the model to be dominated by a large number of safe samples during training, resulting in insufficient sensitivity to features of dangerous scenarios (such as vehicle collisions and pedestrian intrusions), ultimately leading to a low recall rate for dangerous scenarios (typically below 80%). Therefore, in another embodiment of this application, a training method for a scene recognition model is also provided, such as... Figure 2 As shown, it includes: Step S101: Obtain a training dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; In this embodiment of the application, the training dataset refers to the dataset used to train the scene recognition model; the probability label index indicates whether a traffic scene image is a dangerous traffic scene and the corresponding probability label.
[0118] In this step, a large number of traffic scene images are collected through vehicles, monitoring equipment, etc., including a large number of safe scene images and a small number of dangerous scene images (ratio of approximately 20:1). Each image is labeled with a probability label for the dangerous traffic scene category according to the ratio, and a training dataset is constructed.
[0119] Step S102: Preprocess the traffic scene images in the training dataset to obtain multiple input images; In this embodiment of the application, preprocessing refers to performing operations such as standardization and data augmentation on the original traffic scene images in the training dataset to improve the model's generalization ability.
[0120] In this step, the traffic scene images in the training dataset are normalized, their standard deviation adjusted, randomly cropped, and horizontally flipped. Enhancement strategies are applied to dangerous scene images, including additional enhancement operations such as random rotation, brightness adjustment, and color jitter, to obtain the input image.
[0121] The dataset was divided into a training set (70%), a validation set (10%), and a test set (20%) to ensure that dangerous samples were evenly distributed across the subsets.
[0122] Step S103: Input the input image into the scene recognition model as described in the foregoing embodiment, so that the scene recognition model outputs a predicted probability that the input image is a dangerous traffic scene category; In this embodiment of the application, the prediction probability refers to the numerical value of the scene recognition model's prediction that the input image belongs to the category of dangerous traffic scene.
[0123] In this step, the preprocessed input images are input into the scene recognition model in batches. Features are extracted through the core convolution module and the fusion convolution module of the model. The scene classification module outputs the predicted probability of each input image belonging to the dangerous traffic scene category.
[0124] Step S104: Obtain the category weights corresponding to the dangerous traffic scene categories and the focusing parameters corresponding to the degree of focusing on the dangerous traffic scene categories; In this embodiment of the application, the category weight refers to the weight assigned to the dangerous traffic scene category to balance the sparsity of dangerous scene samples; the focus parameter refers to the parameter used to enhance the model's attention to difficult-to-classify dangerous samples.
[0125] In this step, the initial category weights of dangerous traffic scene categories are pre-set based on the ratio of dangerous scene samples to safe scene samples in the training dataset. High weights can be assigned to dangerous categories, for example, an initial category weight alpha of 0.8 can compensate for their sparsity. The initial focusing parameters are set according to the expected attention level of difficult-to-classify samples, which can enhance the attention to difficult-to-classify dangerous samples. For example, an initial focusing parameter gamma of 3.0 can reduce the interference of easily classified safe samples.
[0126] Step S105: Input the predicted probability, the category weight, and the focusing parameter into the focus loss function to obtain the focus loss value; In this embodiment, the focus loss function refers to the FocalLoss loss function used to solve the data imbalance problem; the focus loss value refers to the numerical value calculated by the focus loss function to measure the difference between the model prediction result and the true label.
[0127] In this step, the predicted probability output by the model, the set class weights, and the focus parameters are substituted into the focus loss function to calculate the focus loss value.
[0128] Step S106: If the focus loss value is less than the preset loss value threshold, it is determined that the scene recognition model has been trained.
[0129] In this embodiment of the application, the preset loss threshold refers to a pre-set loss value standard for judging whether the model training has met the standard.
[0130] In this step, the focus loss value is continuously monitored. If the focus loss value is less than the preset loss value threshold, it indicates that the model prediction accuracy has met the standard and training is complete. If it is greater than or equal to the threshold, the learning rate and other parameters are adjusted to continue training.
[0131] This application embodiment constructs a training dataset with probability labels, improves data quality through preprocessing, inputs it into a scene recognition model to obtain predicted probabilities, and optimizes the model through a focus loss function by combining class weights and focus parameters. This enables the trained model to effectively cope with the data imbalance problem, improve the recognition accuracy and recall rate of dangerous traffic scenes, and meet the needs of practical applications.
[0132] In another embodiment of this application, step S104 obtains the category weight corresponding to the dangerous traffic scene category and the focus parameter corresponding to the degree of focus on the dangerous traffic scene category, such as... Figure 3 As shown, it includes: Step S201: Obtain the initial weights corresponding to the dangerous traffic scene categories and the initial parameters corresponding to the degree of focus on the dangerous traffic scene categories; In this embodiment of the application, the initial weight refers to the unadjusted initial weight value assigned to the category of dangerous traffic scenarios; the initial parameter refers to the unadjusted initial parameter value used to focus on difficult-to-classify dangerous samples.
[0133] In this step, the initial weights of dangerous traffic scene categories are set according to the sparsity of dangerous scene samples in the training dataset, and the initial parameters are set according to the expected attention the model should pay to difficult-to-classify samples.
[0134] Step S202: Obtain the verification dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; In this embodiment of the application, the validation dataset refers to the dataset used to validate model performance and adjust parameters, and is independent of the training dataset.
[0135] In this step, a certain number of traffic scene images are collected, covering different scene types. Each image is labeled with a probability label for a dangerous traffic scene category, and a validation dataset is constructed to ensure that dangerous samples are evenly distributed.
[0136] Step S203: Input the traffic scene images in the verification dataset one by one into the scene recognition model, so that the scene recognition model outputs the predicted probability that the input image is a dangerous traffic scene category; In this embodiment of the application, the prediction probability in this step refers to the numerical value of the model's prediction of the dangerous scene category of the images in the verification dataset.
[0137] In this step, traffic scene images from the validation dataset are sequentially input into the scene recognition model in the current training phase. The model then extracts features and classifies the images to output the predicted probabilities for each image.
[0138] Step S204: Determine the recall rate of the scene recognition model based on the probability label and predicted probability of each traffic scene image; In this embodiment, recall rate refers to the ratio of the number of dangerous traffic scene images correctly identified by the model to the total number of actual dangerous traffic scene images in the validation dataset, reflecting the model's ability to detect dangerous scenes.
[0139] In this step, the total number of images in the validation dataset that are actually dangerous traffic scenes and the number of dangerous scene images whose predicted probability by the model is greater than a preset threshold (such as 0.5) are counted, and the ratio of the two is calculated to obtain the recall rate.
[0140] Step S205: If the recall rate is less than a preset recall rate threshold, adjust the initial weight to obtain the category weight, and adjust the initial parameter to obtain the focus parameter.
[0141] In this embodiment of the application, the preset recall threshold refers to the minimum recall standard set in advance to measure the model's ability to detect dangerous scenarios; the category weight refers to the adjusted category weight of dangerous traffic scenarios; and the focusing parameter refers to the adjusted parameter used to focus on difficult-to-classify dangerous samples.
[0142] In this step, if the calculated recall rate is less than the preset recall rate threshold, the initial weights are increased to enhance the model's attention to dangerous categories, and the initial parameters are increased to strengthen the focus on difficult-to-classify samples; if the recall rate meets the target, the initial weights and initial parameters are kept as category weights and focus parameters.
[0143] If the recall rate is too low (severe false negatives), alpha should be increased first to enhance the model's overall weighting of dangerous categories and directly reduce false negatives. If false negatives are mainly concentrated on difficult-to-distinguish samples such as blurry or occluded samples, gamma should be increased to force the model to focus on mining difficult samples. Conversely, if too many false positives lead to a decrease in precision, alpha should be appropriately decreased. In practical applications, the recall rate on the validation set can be monitored periodically, and alpha and gamma can be dynamically adjusted accordingly.
[0144] This application embodiment obtains initial weights and initial parameters, evaluates the model recall using a validation dataset, and dynamically adjusts the parameters based on whether the recall meets the standard to obtain suitable category weights and focus parameters. This ensures that the focus loss function can effectively solve the data imbalance problem, improve the model's recall for dangerous traffic scenarios, and reduce missed detections.
[0145] In another embodiment of this application, a scene recognition method is also provided, such as... Figure 4 As shown, it includes: Step S301: Acquire traffic scene images captured by the vehicle; In this embodiment of the application, vehicle data collection refers to collecting images of the road and the surrounding environment through sensors such as cameras installed on the vehicle.
[0146] In this step, the vehicle's camera captures real-time images of traffic scenes during the journey, covering environmental information such as roads, vehicles, pedestrians, and obstacles.
[0147] Step S302: Preprocess the traffic scene image to obtain the input image; In this embodiment of the application, preprocessing refers to standardizing the original traffic scene images collected by the vehicle to adapt to the input requirements of the scene recognition model.
[0148] In this step, the acquired traffic scene images are normalized and their resolution adjusted to the target resolution (e.g., 256x256), then normalized and enhanced to obtain the input image.
[0149] Step S303: Input the input image into the scene recognition model as described in the foregoing embodiment, so that the scene recognition model outputs a predicted probability that the input image belongs to the dangerous traffic scene category.
[0150] In this embodiment of the application, the predicted probability refers to the judgment result of the scene recognition model that the input image belongs to the category of dangerous traffic scene, and the value range is [0, 1].
[0151] In this step, the preprocessed input image is input into the scene recognition model. The core convolutional module of the model extracts multi-scale features to capture low-level details (such as edges and textures), and the fusion convolutional module fuses spatial information to enhance dynamic target detection. Based on the features extracted by the core convolutional module and the fusion convolutional module, after convolution + global average pooling and fully connected layer operations by the scene classification module, the output image is the predicted probability of the dangerous traffic scene category. A threshold is set, for example, 0.5. If the probability is >0.5, it is judged as a dangerous scene.
[0152] This application embodiment acquires traffic scene images collected by vehicles, preprocesses them to adapt to the model input, and uses a scene recognition model to accurately output the predicted probability of dangerous traffic scene categories, thereby achieving real-time identification of dangerous scenes, providing a reliable basis for autonomous driving decisions, helping to trigger risk avoidance measures in advance, reducing the incidence of traffic accidents, and ensuring the safety of traffic participants.
[0153] In another embodiment of this application, a training device for a scene recognition model is also provided, such as... Figure 5 As shown, it includes: The first acquisition module 11 is used to acquire a training dataset, which includes: multiple traffic scene images and probability labels of each traffic scene image as a dangerous traffic scene category; The first preprocessing module 12 is used to preprocess the traffic scene images in the training dataset to obtain multiple input images; The first input module 13 is used to input the input image into the scene recognition model as described in any of the foregoing embodiments, so that the scene recognition model outputs a predicted probability that the input image is a dangerous traffic scene category; The second acquisition module 14 is used to acquire the category weights corresponding to the dangerous traffic scene categories and the focusing parameters corresponding to the degree of focusing on the dangerous traffic scene categories; The second input module 15 is used to input the predicted probability, the category weight and the focusing parameter into the focus loss function to obtain the focus loss value; The first determining module 16 is used to determine that the scene recognition model has been trained if the focus loss value is less than a preset loss value threshold.
[0154] In another embodiment of this application, a scene recognition device is also provided, such as... Figure 6 As shown, it includes: The third acquisition module 21 is used to acquire traffic scene images collected by the vehicle; The second preprocessing module 22 is used to preprocess the traffic scene image to obtain the input image; The third input module 23 is used to input the input image into the scene recognition model as described in any of the foregoing embodiments, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene.
[0155] In another embodiment of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. Memory, used to store computer programs; When the processor executes the program stored in the memory, it implements the training method of the scene recognition model described in any of the foregoing embodiments, or the scene recognition method described in the foregoing embodiments.
[0156] The electronic device provided in this invention, through its processor executing a program stored in its memory, implements the following: This embodiment constructs a training dataset with probability labels, improves data quality through preprocessing, inputs the dataset into a scene recognition model to obtain predicted probabilities, and optimizes the model using a focus loss function combined with category weights and focus parameters. This enables the trained model to effectively address data imbalance issues, improve the accuracy and recall rate of identifying dangerous traffic scenes, and meet practical application needs. Furthermore, this embodiment acquires traffic scene images collected by vehicles, preprocesses them to adapt the model input, and uses the scene recognition model to accurately output the predicted probabilities of dangerous traffic scene categories, achieving real-time identification of dangerous scenes. This provides a reliable basis for autonomous driving decisions, helps trigger avoidance measures in advance, reduces the traffic accident rate, and ensures the safety of traffic participants.
[0157] The communication bus 1140 mentioned in the above-mentioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0158] The communication interface 1120 is used for communication between the above-mentioned electronic device and other devices.
[0159] The memory 1130 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0160] The processor 1110 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0161] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0162] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A scene recognition model, characterized in that, include: The core convolutional module, the fusion convolutional module, and the scene classification module; The core convolutional module is used to extract multi-scale features from the input image to obtain a compact feature map. The input image is obtained after preprocessing the acquired traffic scene image. The fusion convolution module is used to extract spatial features from the compact feature map, enhance key features of dangerous areas in the traffic scene image through a channel attention mechanism, suppress background noise, and obtain a scene enhancement feature map. The fusion convolution module includes: a spatial convolution unit, an attention enhancement unit, and a channel adjustment unit; The spatial convolutional unit is used to extract spatial features from the compact feature map to obtain a spatial feature map; The attention enhancement unit is used to obtain the first channel weight corresponding to each channel, multiply each channel of the spatial feature map by the corresponding first channel weight to obtain a low-level saliency feature map, wherein the first channel weight of the dangerous area in the traffic scene image is greater than the first channel weight of the non-dangerous area in the traffic scene image. The channel adjustment unit is used to adjust the number of channels in the low-level saliency feature map to obtain the scene enhancement feature map; The scene classification module is used to classify the scene enhanced feature map to obtain the probability that the scene enhanced feature map belongs to the dangerous traffic scene category; The scene recognition model is further configured to: obtain a scaling factor, adjust the number of layers of the core convolutional module and the fusion convolutional module based on the scaling factor, adjust the number of channels of the core convolutional module and the fusion convolutional module based on the scaling factor, and adjust the resolution of the traffic scene image based on the scaling factor.
2. The scene recognition model according to claim 1, characterized in that, The spatial convolutional unit is used to extract spatial features from the compact feature map using a regular 3x3 convolution to obtain a spatial feature map. The channel adjustment unit is used to adjust the number of channels in the low-level saliency feature map using 1x1 convolution to obtain the scene enhancement feature map.
3. The scene recognition model according to claim 1, characterized in that, The attention enhancement unit includes: a first channel weight generation unit, a first feature weighting unit, and a first residual optimization unit; The first channel weight generation unit is used to perform global average pooling on the spatial feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the first channel weight for each channel. The first feature weighting unit is used to multiply each channel of the spatial feature map by its corresponding first channel weight to obtain a first weighted feature map; The first residual optimization unit is used to perform residual processing on the first weighted feature map to obtain the low-level saliency feature map.
4. The scene recognition model according to claim 1, characterized in that, The core convolutional module includes: an expansion unit, a depthwise convolutional unit, a channel attention unit, and a compression unit; The expansion unit is used to expand the number of input channels of the input image from the original dimension to the first dimension using 1x1 convolution, extract high-dimensional features from the input image, and output a high-dimensional feature map. The depthwise convolutional unit is used to perform spatial convolution independently on each channel of the high-dimensional feature map using 3x3 depthwise separable convolution, keeping the number of channels unchanged, and outputting a depthwise feature map. The channel attention unit is used to obtain the second channel weights corresponding to each channel, and multiply each channel of the depth feature map by the corresponding second channel weights to obtain a high-level saliency feature map. The second channel weights of dangerous areas in the traffic scene image are greater than the second channel weights of non-dangerous areas in the traffic scene image. The compression unit is used to compress the number of channels of the high-level saliency feature map from the first dimension back to the original dimension using a 1x1 convolution to obtain the compact feature map.
5. The scene recognition model according to claim 4, characterized in that, The channel attention unit includes: a second channel weight generation unit, a second feature weighting unit, and a second residual optimization unit; The second channel weight generation unit is used to perform global average pooling on the depth feature map to generate a global feature vector for each channel, and to calculate the feature saliency based on the dependency relationship between the global feature vectors of each channel to obtain the second channel weight for each channel. The second feature weighting unit is used to multiply each channel of the depth feature map by the corresponding second channel weight to obtain the second weighted feature map; The second residual optimization unit is used to perform residual processing on the second weighted feature map to obtain the high-level saliency feature map.
6. A method for training a scene recognition model, characterized in that, include: Obtain a training dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; The traffic scene images in the training dataset are preprocessed to obtain multiple input images; The input image is input into the scene recognition model as described in any one of claims 1 to 5, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene; Obtain the category weights corresponding to the dangerous traffic scene categories and the focusing parameters corresponding to the degree of focus on the dangerous traffic scene categories; The predicted probability, the category weight, and the focusing parameter are input into the focus loss function to obtain the focus loss value; If the focus loss value is less than a preset loss value threshold, the scene recognition model is considered to have completed training.
7. The training method for the scene recognition model according to claim 6, characterized in that, Obtain the category weights corresponding to the dangerous traffic scene categories and the focus parameters corresponding to the degree of focus on the dangerous traffic scene categories, including: Obtain the initial weights corresponding to the dangerous traffic scene categories and the initial parameters corresponding to the degree of focus on the dangerous traffic scene categories; Obtain a verification dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; Each traffic scene image in the validation dataset is input into the scene recognition model so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene; The recall rate of the scene recognition model is determined based on the probability label and predicted probability of each traffic scene image; If the recall rate is less than a preset recall rate threshold, the initial weight is adjusted to obtain the category weight, and the initial parameters are adjusted to obtain the focus parameters.
8. A scene recognition method, characterized in that, include: Acquire traffic scene images captured by vehicles; The traffic scene image is preprocessed to obtain the input image; The input image is input into the scene recognition model as described in any one of claims 1 to 5, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene.
9. A training device for a scene recognition model, characterized in that, include: The first acquisition module is used to acquire a training dataset, which includes: multiple traffic scene images and probability labels for each traffic scene image as a dangerous traffic scene category; The first preprocessing module is used to preprocess the traffic scene images in the training dataset to obtain multiple input images; The first input module is used to input the input image into the scene recognition model as described in any one of claims 1 to 5, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene; The second acquisition module is used to acquire the category weights corresponding to the dangerous traffic scene categories and the focus parameters corresponding to the degree of focus on the dangerous traffic scene categories; The second input module is used to input the predicted probability, the category weight, and the focusing parameter into the focus loss function to obtain the focus loss value; The first determining module is used to determine that the scene recognition model has been trained if the focus loss value is less than a preset loss value threshold.
10. A scene recognition device, characterized in that, include: The third acquisition module is used to acquire traffic scene images collected by the vehicle; The second preprocessing module is used to preprocess the traffic scene image to obtain the input image; The third input module is used to input the input image into the scene recognition model as described in any one of claims 1 to 5, so that the scene recognition model outputs a predicted probability that the input image belongs to the category of dangerous traffic scene.
11. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When executing a program stored in memory, the processor implements the training method of the scene recognition model according to any one of claims 6 to 7, or the scene recognition method according to claim 8.
Citation Information
Patent Citations
Traffic scene risk assessment method and system based on multi-branch convolutional neural network
CN112016499A
Risk road scene recognition method based on multi-stage attention deep learning
CN114049532A