Real-time traffic target detection method and system based on adaptive attention perception
By introducing adaptive scaling factors into the multi-head attention mechanism and combining the multi-scale offset perceived attention module and the bidirectional cross-scale feature fusion module, the accuracy and robustness of traffic object detection in complex traffic scenarios are solved, and more efficient target detection results are achieved.
Patent Information
- Application Number
- CN202510344884.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2045-03-24
AI Technical Summary
The prior art is difficult to achieve accurate traffic target detection in complex traffic scenarios, especially in dense traffic flow and harsh environments, and the problem of missed target detection and reduced detection accuracy is prone to problems.
A real-time traffic object detection method based on adaptive perceptual attention is designed. By introducing an adaptive scaling factor into the multi-head attention mechanism, dynamically adjusting the attention intensity and attention distribution of the attention head for different characteristics, and combining the multi-scale offset perceptual attention module and the bidirectional cross-scale feature fusion module, the attention to local characteristics and the processing ability of complex scenarios is enhanced.
It improves the accuracy and robustness of traffic target detection, can more effectively process images in complex traffic scenes and harsh environments, and reduces target missed detection and information loss.
Smart Images

Figure CN119863613A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of traffic target detection, and in particular to a real-time traffic target detection method and system based on adaptive perceptual attention. Background Art
[0002] With the rapid development of the automobile industry, autonomous driving and assisted driving have gradually become important directions for alleviating traditional traffic problems. A key link in realizing autonomous driving and assisted driving is to accurately detect various road targets in the traffic environment. Accurately identifying and understanding the surrounding environment is the basis for ensuring that autonomous driving vehicles make correct decisions and is also a prerequisite for ensuring driving safety.
[0003] In the prior art, target detection methods based on vision technology are usually adopted. However, the existing target detection methods still have many defects when facing complex traffic scenes, especially in common dense traffic. Since multiple targets may block each other or there are some targets with small size, it may cause target missed detection, thereby affecting the accuracy of target detection. When target instances overlap with each other, the features extracted from the image may not be sufficient to support effective detection and classification, resulting in failure to successfully identify the target object. Secondly, in common harsh environments, such as at night or other low-light conditions, since the quality of the collected images is often low, some areas may become blurred due to insufficient light, further aggravating the difficulty of target detection.
[0004] Therefore, how to design a target detection method to avoid the influence of complex traffic scenes and improve the accuracy and robustness of target detection has become an urgent problem to be solved. Summary of the invention
[0005] Based on this, the present invention provides a real-time traffic target detection method and system based on adaptive perceptual attention. An adaptive scaling factor is designed on the basis of a multi-head attention mechanism to dynamically adjust the attention intensity and attention distribution of each attention head on different features, thereby improving the adaptability to different features and enhancing the attention to local features, thereby improving the accuracy of target detection. A multi-scale offset perceptual attention module is designed to enhance the spatial perception capability of the sampling offset generation process, thereby better focusing on key areas and improving the accuracy and robustness of target detection in complex scenarios. A bidirectional cross-scale feature fusion module is designed to perform cross-layer connections between different feature levels, thereby enhancing the feature fusion capability and reducing the information loss of features. A dynamic upsampling operator is added to perform more accurate upsampling, thereby further reducing the information loss of features and thereby improving the accuracy of target detection as a whole. The present invention improves the accuracy and robustness of the traffic target detection method.
[0006] The present invention proposes a real-time traffic target detection method based on adaptive perception attention, comprising: Acquire a real-time traffic target image and preprocess it, and input the preprocessed real-time traffic target image into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module, and a bidirectional cross-scale feature fusion module; Acquire basic image features of the real-time traffic target image, and then perform multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features, wherein the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head; Performing multi-scale feature enhancement processing on the multi-head attention enhancement feature according to the multi-scale offset-aware attention module to obtain a multi-scale enhanced feature, wherein the multi-scale feature enhancement processing is based on relative position information; Performing feature fusion capability enhancement processing on the multi-scale enhancement feature according to the bidirectional cross-scale feature fusion module to obtain fusion enhancement features, wherein the bidirectional cross-scale feature fusion module is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss; Target detection is performed based on the fused enhanced features to obtain a final traffic target detection result.
[0007] In summary, according to the above-mentioned real-time traffic target detection method based on adaptive perceptual attention, an adaptive scaling factor is designed on the basis of a multi-head attention mechanism to dynamically adjust the attention intensity and attention distribution of each attention head on different features, thereby improving the adaptability to different features, while enhancing the attention to local features and improving the accuracy of target detection. A multi-scale offset perceptual attention module is designed to enhance the spatial perception capability of the sampling offset generation process, so as to better focus on key areas and improve the accuracy and robustness of target detection in complex scenes. A bidirectional cross-scale feature fusion module is designed to perform cross-layer connections between different feature levels, thereby enhancing the feature fusion capability and reducing the information loss of features. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing the information loss of features, thereby improving the accuracy of target detection as a whole. The present invention improves the accuracy and robustness of the traffic target detection method.Specifically, a real-time traffic target image is obtained and preprocessed, and the preprocessed real-time traffic target image is input into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module and a bidirectional cross-scale feature fusion module, and the basic image features of the real-time traffic target image are obtained. Then, according to the attention internal scale feature interaction module, the basic image features are subjected to multi-head attention enhancement processing to obtain multi-head attention enhancement features, and the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head. An adaptive scaling factor is designed based on the multi-head attention mechanism to dynamically adjust the attention strength and attention distribution of each attention head to different features, thereby improving the adaptability to different features, while enhancing the attention to local features, and improving the accuracy of target detection. The multi-head attention enhancement features are subjected to multi-scale processing according to the multi-scale offset perception attention module. Feature enhancement processing is performed to obtain multi-scale enhanced features. The multi-scale feature enhancement processing is based on relative position information, and the spatial perception ability of the sampling offset generation process is enhanced to better focus on key areas, thereby improving the accuracy and robustness of target detection in complex scenes. The multi-scale enhanced features are subjected to feature fusion capability enhancement processing according to the bidirectional cross-scale feature fusion module to obtain fusion enhanced features. The bidirectional cross-scale feature fusion module is based on a cross-layer connection structure. The feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss. Cross-layer connections are performed between different feature levels, and feature fusion capability is enhanced to reduce feature information loss. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing feature information loss, thereby improving the accuracy of target detection as a whole. Target detection is performed according to the fusion enhanced features to obtain the final traffic target detection result. The present invention improves the accuracy and robustness of the traffic target detection method.
[0008] Furthermore, the step of performing multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhanced features specifically includes: Inputting the basic image features into an attention internal scale feature interaction module, wherein the attention internal scale feature interaction module includes a multi-head adaptive attention submodule; The multi-head adaptive attention submodule performs dimensional transformation on the basic image features to divide them into multi-head features, and linearly projects the multi-head features to generate query features, key features and value features, wherein any feature head of the multi-head features has a unique corresponding attention head; Input the query feature into an adaptive weight generation block, calculate an adaptive scaling factor of the query feature according to a fully connected layer, and multiply the adaptive scaling factor by the query feature to obtain an adaptively adjusted query feature; Performing a dot product operation on the adaptively adjusted query feature and the key feature to obtain a single-head attention weight, and then normalizing the single-head attention weight to generate a single-head attention matrix; Multiplying the single-head attention matrix by the value feature to obtain a single-head attention enhanced feature; The single-head attention enhanced features of all attention heads are concatenated to obtain multi-head attention enhanced features.
[0009] Furthermore, the attention internal scale feature interaction module specifically includes: The attention internal scale feature interaction module is a dual-branch structure, which divides the basic image features into two parts according to the number of channels and inputs them into different branches respectively. The dual-branch structure includes an unprocessed original branch and a continuous residual branch. The continuous residual branch includes two continuous residual structures, the first residual structure includes a first original branch and a first residual branch, the first residual branch includes a multi-head adaptive attention submodule, the outputs of the first original branch and the first residual branch are added, and then input into the second residual structure, the second residual structure includes a second original branch and a second residual branch, the second residual branch includes a convolution layer and an activation layer, the convolution layer includes two 1×1 convolution kernels, the activation layer is a ReLU activation function, and the outputs of the second original branch and the second residual branch are added, and then output from the continuous residual branch; The outputs of the unprocessed original branch and the continuous residual branch are concatenated, passed through a 1×1 convolutional layer and a ReLU activation layer, and output from the attention internal scale feature interaction module.
[0010] Furthermore, the step of performing multi-scale feature enhancement processing on the multi-head attention enhancement feature according to the multi-scale offset-aware attention module to obtain the multi-scale enhanced feature specifically includes: Divide the multi-head attention enhanced features according to the feature scale to obtain multi-scale features; Obtaining a query vector and a reference point of a multi-scale feature, and inputting the multi-scale feature, the query vector and the reference point into a multi-scale offset-aware attention module respectively; Feed the query vector into a linear layer to obtain the offset and attention weights; The reference point is input into the relative position information embedding submodule to obtain relative position information, and then the relative position information is added to the offset to obtain a sampling offset; Normalizing the sampling offset to match the sampling offset to different feature scales, and then adding the sampling offset to a reference point to obtain a sampling point; Selecting feature values of the multi-scale features according to the sampling points to obtain feature values at key positions, and multiplying the feature values at key positions by the attention weights to obtain attention weighted features; The attention weighted features are passed through a linear layer to obtain multi-scale enhanced features.
[0011] Furthermore, the relative position information embedding submodule specifically includes: The relative position information embedding submodule calculates the relative displacement of the sampling point in the sampling grid according to the spatial coordinates of the reference point and the sampling grid, wherein the relative displacement includes the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate; Inputting the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate into two perception blocks respectively to generate position embeddings of the horizontal coordinate and the vertical coordinate respectively, and then performing diffusion addition on the position embeddings of the horizontal coordinate and the vertical coordinate to generate global relative position information embedding features; The spatial distance is calculated according to the global relative position information embedding feature to screen and obtain key sampling points, and the relative position information is generated according to the key sampling points.
[0012] Furthermore, the step of performing feature fusion capability enhancement processing on the multi-scale enhancement feature according to the bidirectional cross-scale feature fusion module to obtain a fusion enhancement feature specifically includes: Input the multi-scale enhanced features into a bidirectional cross-scale feature fusion module, divide the multi-scale enhanced features into low-level features, middle-level features and high-level features according to the feature hierarchy, and bidirectionally connect the different feature hierarchies of the low-level features, middle-level features and high-level features, and the bidirectional connection is used to transfer the features from the low-level to the high-level or from the high-level to the low-level according to the order of the feature hierarchy; All features in each feature level of the low-level features, middle-level features and high-level features are weighted and fused to output low-level weighted fusion features, middle-level weighted fusion features and high-level weighted fusion features respectively; After the low-layer weighted fusion features, the middle-layer weighted fusion features and the high-layer weighted fusion features are concatenated, dimension reduction processing is performed according to the convolution layer to obtain fusion enhancement features.
[0013] Furthermore, the bidirectional cross-scale feature fusion module also includes: The bidirectional cross-scale feature fusion module includes a dynamic upsampling operator, which is used to generate corresponding weights of features; The dynamic upsampling operator includes a dynamic weight generation block, which performs a convolution operation on an input feature of the dynamic upsampling operator to obtain a weight feature, wherein the weight feature includes context information; Dynamically selecting each sampling position according to the weight feature to obtain a sampling point and a dynamic weight, wherein the dynamic weight uniquely corresponds to the sampling point; The pixel values of the input features are weighted summed according to the sampling points and the dynamic weights to generate dynamic up-sampling features.
[0014] The present invention proposes a real-time traffic target detection system based on adaptive perception attention, comprising: A preprocessing module, used to obtain and preprocess a real-time traffic target image, and input the preprocessed real-time traffic target image into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module, and a bidirectional cross-scale feature fusion module; an attention internal scale feature interaction module, used to obtain basic image features of the real-time traffic target image, and then perform multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features, wherein the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head; A multi-scale offset-aware attention module, used for performing multi-scale feature enhancement processing on the multi-head attention enhancement feature to obtain a multi-scale enhanced feature, wherein the multi-scale feature enhancement processing is based on relative position information; A bidirectional cross-scale feature fusion module, used for performing feature fusion capability enhancement processing on the multi-scale enhanced features to obtain fusion enhanced features, wherein the bidirectional cross-scale feature fusion module is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss; The detection output module is used to perform target detection according to the fusion enhancement features to obtain a final traffic target detection result.
[0015] The present invention also provides a storage medium, which stores one or more programs, and when the programs are executed by a processor, the real-time traffic target detection method based on adaptive perceptual attention as described above is implemented.
[0016] The present invention also provides a computer device, the computer device comprising a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, the real-time traffic target detection method based on adaptive perceptual attention as described above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A flowchart of a real-time traffic target detection method based on adaptive perception attention proposed in the first embodiment of the present invention; Figure 2 A flowchart of a real-time traffic target detection method based on adaptive perception attention proposed in a second embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a real-time traffic target detection system based on adaptive perception attention proposed in the third embodiment of the present invention.
[0018] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0019] In order to facilitate understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are provided in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0020] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0022] See also Figure 1 , which is a flow chart of a real-time traffic target detection method based on adaptive perception attention proposed in a first embodiment of the present invention, the real-time traffic target detection method based on adaptive perception attention comprises steps S01 to S05, wherein: Step S01: acquiring a real-time traffic target image and preprocessing it, and inputting the preprocessed real-time traffic target image into a traffic target detection model; It should be noted that the traffic target detection model described in this embodiment includes an attention internal scale feature interaction module, a multi-scale offset perception attention module and a bidirectional cross-scale feature fusion module.
[0023] Step S02: obtaining basic image features of the real-time traffic target image, and then performing multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features; It should be noted that the multi-head attention enhancement processing described in this embodiment is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head. In this embodiment, the basic image features are input into the attention internal scale feature interaction module, and the attention internal scale feature interaction module includes a multi-head adaptive attention submodule; The multi-head adaptive attention submodule performs dimensional transformation on the basic image features to divide them into multi-head features, and linearly projects the multi-head features to generate query features, key features and value features, wherein any feature head of the multi-head features has a unique corresponding attention head; Input the query feature into an adaptive weight generation block, calculate an adaptive scaling factor of the query feature according to a fully connected layer, and multiply the adaptive scaling factor by the query feature to obtain an adaptively adjusted query feature; Performing a dot product operation on the adaptively adjusted query feature and the key feature to obtain a single-head attention weight, and then normalizing the single-head attention weight to generate a single-head attention matrix; Multiplying the single-head attention matrix by the value feature to obtain a single-head attention enhanced feature; Concatenate the single-head attention enhancement features of all attention heads to obtain multi-head attention enhancement features; The attention internal scale feature interaction module is a dual-branch structure, which divides the basic image features into two parts according to the number of channels and inputs them into different branches respectively. The dual-branch structure includes an unprocessed original branch and a continuous residual branch. The continuous residual branch includes two continuous residual structures, the first residual structure includes a first original branch and a first residual branch, the first residual branch includes a multi-head adaptive attention submodule, the outputs of the first original branch and the first residual branch are added, and then input into the second residual structure, the second residual structure includes a second original branch and a second residual branch, the second residual branch includes a convolution layer and an activation layer, the convolution layer includes two 1×1 convolution kernels, the activation layer is a ReLU activation function, and the outputs of the second original branch and the second residual branch are added, and then output from the continuous residual branch; The outputs of the unprocessed original branch and the continuous residual branch are concatenated, passed through a 1×1 convolutional layer and a ReLU activation layer, and output from the attention internal scale feature interaction module.
[0024] Step S03: performing multi-scale feature enhancement processing on the multi-head attention enhancement features according to the multi-scale offset perception attention module to obtain multi-scale enhancement features; It should be noted that the multi-scale feature enhancement processing described in this embodiment is based on relative position information. In this embodiment, the multi-head attention enhancement features are divided according to the feature scale to obtain multi-scale features; Obtaining a query vector and a reference point of a multi-scale feature, and inputting the multi-scale feature, the query vector and the reference point into a multi-scale offset-aware attention module respectively; Feed the query vector into a linear layer to obtain the offset and attention weights; The reference point is input into the relative position information embedding submodule to obtain relative position information, and then the relative position information is added to the offset to obtain a sampling offset; Normalizing the sampling offset to match the sampling offset to different feature scales, and then adding the sampling offset to a reference point to obtain a sampling point; Selecting feature values of the multi-scale features according to the sampling points to obtain feature values at key positions, and multiplying the feature values at key positions by the attention weights to obtain attention weighted features; Passing the attention weighted features through a linear layer to obtain multi-scale enhanced features; The specific algorithm of the multi-scale offset perception attention module is as follows: offset=Linear(Query), weight=Linear(Query), sampling_offsets=offset+RPE(reference_points), sampling_points=Norm(sampling_offsets)+reference_points, sample_value=grid_sample(Value,sampling_points), output=sample_value*weight, Among them, offset represents offset, Linear represents linear layer, Query represents query vector, weight represents attention weight, sampling_offsets represents sampling offset, RPE represents relative position information embedding submodule, reference_points represents reference point, sampling_points represents sampling point, Norm represents normalization, sample_value represents key position feature value, grid_sample represents feature value selection, Value represents multi-scale feature, and output represents multi-scale enhanced feature output by multi-scale offset perception attention module; The relative position information embedding submodule calculates the relative displacement of the sampling point in the sampling grid according to the spatial coordinates of the reference point and the sampling grid, wherein the relative displacement includes the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate; Inputting the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate into two perception blocks respectively to generate position embeddings of the horizontal coordinate and the vertical coordinate respectively, and then performing diffusion addition on the position embeddings of the horizontal coordinate and the vertical coordinate to generate global relative position information embedding features; Calculating spatial distances according to the global relative position information embedding features to screen and obtain key sampling points, and generating relative position information according to the key sampling points; The specific algorithm of the relative position information embedding submodule is as follows: xmin, ymin, xmax, ymax=reference_points, Δx=[xmin−xi,xmax−xi],∀xi∈Pgrid(0,w), Δy=[ymin−yj,ymax−yj],∀yj∈Pgrid(0,h), RPEx=MLP(Δx), RPEy=MLP(Δy), RPElevel=RPEx+RPEy, topk_indices=TopK(distance,k=num_points), RPEselected=RPElevel[: , : , topk_indices , : , :], Among them, xmin, ymin, xmax, and ymax represent the spatial coordinates of the reference point respectively, Δx and Δy represent the relative displacement of the lateral coordinate and the longitudinal coordinate respectively, xi and yj represent the coordinates of the sampling point respectively, Pgrid represents the sampling grid, w and h represent the width and height of the sampling grid respectively, MLP represents the perception block, RPElevel represents the global relative position information embedding feature, topk_indices represents the key sampling point, TopK represents the key sampling point screening, distance represents the Euclidean distance, k represents the number of key sampling points screened, num_points represents the total number of sampling points, and RPEselected represents the relative position information.
[0025] Step S04: performing feature fusion capability enhancement processing on the multi-scale enhancement features according to the bidirectional cross-scale feature fusion module to obtain fusion enhancement features; It should be noted that the bidirectional cross-scale feature fusion module in this embodiment is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, which is used to reduce feature loss. In this embodiment, the multi-scale enhanced feature is input into the bidirectional cross-scale feature fusion module, and the multi-scale enhanced feature is divided into low-level features, middle-level features and high-level features according to the feature level. The low-level features, middle-level features and high-level features are bidirectionally connected between different feature levels, and the bidirectional connection is used to transfer the features from the low layer to the high layer or from the high layer to the low layer in the order of the feature level; All features in each feature level of the low-level features, middle-level features and high-level features are weighted and fused to output low-level weighted fusion features, middle-level weighted fusion features and high-level weighted fusion features respectively; After the low-layer weighted fusion features, the middle-layer weighted fusion features and the high-layer weighted fusion features are feature spliced, dimensionality reduction processing is performed according to the convolution layer to obtain fusion enhancement features; The bidirectional cross-scale feature fusion module includes a dynamic upsampling operator, which is used to generate corresponding weights of features; The dynamic upsampling operator includes a dynamic weight generation block, which performs a convolution operation on an input feature of the dynamic upsampling operator to obtain a weight feature, wherein the weight feature includes context information; Dynamically selecting each sampling position according to the weight feature to obtain a sampling point and a dynamic weight, wherein the dynamic weight uniquely corresponds to the sampling point; The pixel values of the input features are weighted summed according to the sampling points and the dynamic weights to generate dynamic up-sampling features.
[0026] Step S05: Perform target detection based on the fused enhanced features to obtain the final traffic target detection result.
[0027] In summary, according to the above-mentioned real-time traffic target detection method based on adaptive perceptual attention, an adaptive scaling factor is designed on the basis of a multi-head attention mechanism to dynamically adjust the attention intensity and attention distribution of each attention head on different features, thereby improving the adaptability to different features, while enhancing the attention to local features and improving the accuracy of target detection. A multi-scale offset perceptual attention module is designed to enhance the spatial perception capability of the sampling offset generation process, so as to better focus on key areas and improve the accuracy and robustness of target detection in complex scenes. A bidirectional cross-scale feature fusion module is designed to perform cross-layer connections between different feature levels, thereby enhancing the feature fusion capability and reducing the information loss of features. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing the information loss of features, thereby improving the accuracy of target detection as a whole. The present invention improves the accuracy and robustness of the traffic target detection method.Specifically, a real-time traffic target image is obtained and preprocessed, and the preprocessed real-time traffic target image is input into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module and a bidirectional cross-scale feature fusion module, and the basic image features of the real-time traffic target image are obtained. Then, according to the attention internal scale feature interaction module, the basic image features are subjected to multi-head attention enhancement processing to obtain multi-head attention enhancement features, and the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head. An adaptive scaling factor is designed based on the multi-head attention mechanism to dynamically adjust the attention strength and attention distribution of each attention head to different features, thereby improving the adaptability to different features, while enhancing the attention to local features, and improving the accuracy of target detection. The multi-head attention enhancement features are subjected to multi-scale processing according to the multi-scale offset perception attention module. Feature enhancement processing is performed to obtain multi-scale enhanced features. The multi-scale feature enhancement processing is based on relative position information, and the spatial perception ability of the sampling offset generation process is enhanced to better focus on key areas, thereby improving the accuracy and robustness of target detection in complex scenes. The multi-scale enhanced features are subjected to feature fusion capability enhancement processing according to the bidirectional cross-scale feature fusion module to obtain fusion enhanced features. The bidirectional cross-scale feature fusion module is based on a cross-layer connection structure. The feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss. Cross-layer connections are performed between different feature levels, and feature fusion capability is enhanced to reduce feature information loss. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing feature information loss, thereby improving the accuracy of target detection as a whole. Target detection is performed according to the fusion enhanced features to obtain the final traffic target detection result. The present invention improves the accuracy and robustness of the traffic target detection method.
[0028] See also Figure 2 , which is a flow chart of a real-time traffic target detection method based on adaptive perception attention proposed in a second embodiment of the present invention, the real-time traffic target detection method based on adaptive perception attention comprises steps S11 to S16, wherein: Step S11: acquiring a real-time traffic target image and performing preprocessing, inputting the preprocessed real-time traffic target image into a traffic target detection model, and acquiring basic image features of the real-time traffic target image; It should be noted that the traffic target detection model in this embodiment is a Transformer model, including an attention internal scale feature interaction module, a multi-scale offset perception attention module and a bidirectional cross-scale feature fusion module.
[0029] Step S12: input the basic image features into the attention internal scale feature interaction module, the multi-head adaptive attention submodule performs dimension transformation on the basic image features to divide them into multi-head features, linearly project the multi-head features respectively to generate query features, key features and value features, input the query features into the adaptive weight generation block, calculate the adaptive scaling coefficient of the query features according to the fully connected layer, multiply the adaptive scaling coefficient by the query features to obtain the adaptively adjusted query features, perform dot product operation on the adaptively adjusted query features and the key features to obtain the single-head attention weights, and then normalize the single-head attention weights to generate the single-head attention matrix, multiply the single-head attention matrix by the value features to obtain the single-head attention enhancement features, and perform feature splicing on the single-head attention enhancement features of all attention heads to obtain the multi-head attention enhancement features; Step S13: Divide the multi-head attention enhanced features according to the feature scale to obtain multi-scale features, obtain the query vector and reference point of the multi-scale features, input the multi-scale features, the query vector and the reference point into the multi-scale offset perception attention module respectively, input the query vector into the linear layer to obtain the offset and the attention weight, input the reference point into the relative position information embedding submodule to obtain the relative position information, then add the relative position information to the offset to obtain the sampling offset, normalize the sampling offset to match the sampling offset to different feature scales, then add the sampling offset to the reference point to obtain the sampling point, select the feature value of the multi-scale features according to the sampling point to obtain the key position feature value, multiply the key position feature value by the attention weight to obtain the attention weighted feature, and pass the attention weighted feature through the linear layer to obtain the multi-scale enhanced feature; Step S14: the relative position information embedding submodule calculates the relative displacement of the sampling point in the sampling grid according to the spatial coordinates in the reference point and the sampling grid, and inputs the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate into two perception blocks respectively to generate the position embedding of the horizontal coordinate and the vertical coordinate respectively, and then diffuses and adds the position embedding of the horizontal coordinate and the vertical coordinate to generate the global relative position information embedding feature, calculates the spatial distance according to the global relative position information embedding feature, so as to screen and obtain the key sampling points, and generates the relative position information according to the key sampling points; Step S15: input the multi-scale enhanced features into the bidirectional cross-scale feature fusion module, divide the multi-scale enhanced features into low-level features, middle-level features and high-level features according to the feature level, perform weighted fusion on all features in each feature level of the low-level features, middle-level features and high-level features, so as to output low-level weighted fusion features, middle-level weighted fusion features and high-level weighted fusion features respectively, perform feature splicing on the low-level weighted fusion features, middle-level weighted fusion features and high-level weighted fusion features, perform dimensionality reduction processing according to the convolution layer, so as to obtain fusion enhanced features; Step S16: Perform target detection based on the fused enhanced features to obtain the final traffic target detection result.
[0030] In summary, according to the above-mentioned real-time traffic target detection method based on adaptive perceptual attention, an adaptive scaling factor is designed on the basis of a multi-head attention mechanism to dynamically adjust the attention intensity and attention distribution of each attention head on different features, thereby improving the adaptability to different features, while enhancing the attention to local features and improving the accuracy of target detection. A multi-scale offset perceptual attention module is designed to enhance the spatial perception capability of the sampling offset generation process, so as to better focus on key areas and improve the accuracy and robustness of target detection in complex scenes. A bidirectional cross-scale feature fusion module is designed to perform cross-layer connections between different feature levels, thereby enhancing the feature fusion capability and reducing the information loss of features. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing the information loss of features, thereby improving the accuracy of target detection as a whole. The present invention improves the accuracy and robustness of the traffic target detection method.Specifically, a real-time traffic target image is obtained and preprocessed, and the preprocessed real-time traffic target image is input into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module and a bidirectional cross-scale feature fusion module, and the basic image features of the real-time traffic target image are obtained. Then, according to the attention internal scale feature interaction module, the basic image features are subjected to multi-head attention enhancement processing to obtain multi-head attention enhancement features, and the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head. An adaptive scaling factor is designed based on the multi-head attention mechanism to dynamically adjust the attention strength and attention distribution of each attention head to different features, thereby improving the adaptability to different features, while enhancing the attention to local features, and improving the accuracy of target detection. The multi-head attention enhancement features are subjected to multi-scale processing according to the multi-scale offset perception attention module. Feature enhancement processing is performed to obtain multi-scale enhanced features. The multi-scale feature enhancement processing is based on relative position information, and the spatial perception ability of the sampling offset generation process is enhanced to better focus on key areas, thereby improving the accuracy and robustness of target detection in complex scenes. The multi-scale enhanced features are subjected to feature fusion capability enhancement processing according to the bidirectional cross-scale feature fusion module to obtain fusion enhanced features. The bidirectional cross-scale feature fusion module is based on a cross-layer connection structure. The feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss. Cross-layer connections are performed between different feature levels, and feature fusion capability is enhanced to reduce feature information loss. At the same time, a dynamic upsampling operator is added to perform more accurate upsampling, further reducing feature information loss, thereby improving the accuracy of target detection as a whole. Target detection is performed according to the fusion enhanced features to obtain the final traffic target detection result. The present invention improves the accuracy and robustness of the traffic target detection method.
[0031] See also Figure 3 , which is a schematic diagram of the structure of a real-time traffic target detection system based on adaptive perception attention proposed in the third embodiment of the present invention, the system comprises: A preprocessing module 10 is used to obtain and preprocess a real-time traffic target image, and input the preprocessed real-time traffic target image into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module, and a bidirectional cross-scale feature fusion module; An attention internal scale feature interaction module 20 is used to obtain basic image features of the real-time traffic target image, and then perform multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features, wherein the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head; A multi-scale offset-aware attention module 30, configured to perform multi-scale feature enhancement processing on the multi-head attention enhancement feature to obtain a multi-scale enhanced feature, wherein the multi-scale feature enhancement processing is based on relative position information; A bidirectional cross-scale feature fusion module 40 is used to perform feature fusion capability enhancement processing on the multi-scale enhanced features to obtain fusion enhanced features, wherein the bidirectional cross-scale feature fusion module is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss; The detection output module 50 is used to perform target detection according to the fusion enhancement feature to obtain a final traffic target detection result.
[0032] The present invention also proposes a computer storage medium on which one or more programs are stored, and when the program is executed by a processor, the above-mentioned real-time traffic target detection method based on adaptive perception attention is implemented.
[0033] The present invention also proposes a computer device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the above-mentioned real-time traffic target detection method based on adaptive perceptual attention.
[0034] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain storage, communication, propagation or transmission of a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0035] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0036] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0037] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0038] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A real-time traffic target detection method based on adaptive perceptual attention, characterized in that: include: Acquire a real-time traffic target image and preprocess it, and input the preprocessed real-time traffic target image into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module, and a bidirectional cross-scale feature fusion module; Acquire basic image features of the real-time traffic target image, and then perform multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features, wherein the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head; Performing multi-scale feature enhancement processing on the multi-head attention enhancement feature according to the multi-scale offset-aware attention module to obtain a multi-scale enhanced feature, wherein the multi-scale feature enhancement processing is based on relative position information; Performing feature fusion capability enhancement processing on the multi-scale enhancement feature according to the bidirectional cross-scale feature fusion module to obtain fusion enhancement features, wherein the bidirectional cross-scale feature fusion module is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss; Target detection is performed based on the fused enhanced features to obtain a final traffic target detection result.
2. The real-time traffic target detection method based on adaptive perceptual attention according to claim 1 is characterized in that: The step of performing multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features specifically includes: Inputting the basic image features into an attention internal scale feature interaction module, wherein the attention internal scale feature interaction module includes a multi-head adaptive attention submodule; The multi-head adaptive attention submodule performs dimensional transformation on the basic image features to divide them into multi-head features, and linearly projects the multi-head features to generate query features, key features and value features, wherein any feature head of the multi-head features has a unique corresponding attention head; Input the query feature into an adaptive weight generation block, calculate an adaptive scaling factor of the query feature according to a fully connected layer, and multiply the adaptive scaling factor by the query feature to obtain an adaptively adjusted query feature; Performing a dot product operation on the adaptively adjusted query feature and the key feature to obtain a single-head attention weight, and then normalizing the single-head attention weight to generate a single-head attention matrix; Multiplying the single-head attention matrix by the value feature to obtain a single-head attention enhanced feature; The single-head attention enhanced features of all attention heads are concatenated to obtain multi-head attention enhanced features.
3. The real-time traffic target detection method based on adaptive perceptual attention according to claim 2 is characterized in that: The attention internal scale feature interaction module specifically includes: The attention internal scale feature interaction module is a dual-branch structure, which divides the basic image features into two parts according to the number of channels and inputs them into different branches respectively. The dual-branch structure includes an unprocessed original branch and a continuous residual branch. The continuous residual branch includes two continuous residual structures, the first residual structure includes a first original branch and a first residual branch, the first residual branch includes a multi-head adaptive attention submodule, the outputs of the first original branch and the first residual branch are added, and then input into the second residual structure, the second residual structure includes a second original branch and a second residual branch, the second residual branch includes a convolution layer and an activation layer, the convolution layer includes two 1×1 convolution kernels, the activation layer is a ReLU activation function, and the outputs of the second original branch and the second residual branch are added, and then output from the continuous residual branch; The outputs of the unprocessed original branch and the continuous residual branch are concatenated, passed through a 1×1 convolutional layer and a ReLU activation layer, and output from the attention internal scale feature interaction module.
4. The real-time traffic target detection method based on adaptive perceptual attention according to claim 1 is characterized in that: The step of performing multi-scale feature enhancement processing on the multi-head attention enhancement feature according to the multi-scale offset perception attention module to obtain the multi-scale enhancement feature specifically includes: Divide the multi-head attention enhanced features according to the feature scale to obtain multi-scale features; Obtaining a query vector and a reference point of a multi-scale feature, and inputting the multi-scale feature, the query vector and the reference point into a multi-scale offset-aware attention module respectively; Feed the query vector into a linear layer to obtain the offset and attention weights; The reference point is input into the relative position information embedding submodule to obtain relative position information, and then the relative position information is added to the offset to obtain a sampling offset; Normalizing the sampling offset to match the sampling offset to different feature scales, and then adding the sampling offset to a reference point to obtain a sampling point; Selecting feature values of the multi-scale features according to the sampling points to obtain feature values at key positions, and multiplying the feature values at key positions by the attention weights to obtain attention weighted features; The attention weighted features are passed through a linear layer to obtain multi-scale enhanced features.
5. The real-time traffic target detection method based on adaptive perceptual attention according to claim 4 is characterized in that: The relative position information embedding submodule specifically includes: The relative position information embedding submodule calculates the relative displacement of the sampling point in the sampling grid according to the spatial coordinates of the reference point and the sampling grid, wherein the relative displacement includes the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate; Inputting the relative displacement of the horizontal coordinate and the relative displacement of the vertical coordinate into two perception blocks respectively to generate position embeddings of the horizontal coordinate and the vertical coordinate respectively, and then performing diffusion addition on the position embeddings of the horizontal coordinate and the vertical coordinate to generate global relative position information embedding features; The spatial distance is calculated according to the global relative position information embedding feature to screen and obtain key sampling points, and the relative position information is generated according to the key sampling points.
6. The real-time traffic target detection method based on adaptive perceptual attention according to claim 1 is characterized in that: The step of performing feature fusion capability enhancement processing on the multi-scale enhancement feature according to the bidirectional cross-scale feature fusion module to obtain a fusion enhancement feature specifically includes: Input the multi-scale enhanced features into a bidirectional cross-scale feature fusion module, divide the multi-scale enhanced features into low-level features, middle-level features and high-level features according to the feature hierarchy, and bidirectionally connect the different feature hierarchies of the low-level features, middle-level features and high-level features, and the bidirectional connection is used to transfer the features from the low-level to the high-level or from the high-level to the low-level according to the order of the feature hierarchy; All features in each feature level of the low-level features, middle-level features and high-level features are weighted and fused to output low-level weighted fusion features, middle-level weighted fusion features and high-level weighted fusion features respectively; After the low-layer weighted fusion features, the middle-layer weighted fusion features and the high-layer weighted fusion features are concatenated, dimension reduction processing is performed according to the convolution layer to obtain fusion enhancement features.
7. The method for real-time traffic target detection based on adaptive perceptual attention according to claim 6, characterized in that: The bidirectional cross-scale feature fusion module also includes: The bidirectional cross-scale feature fusion module includes a dynamic upsampling operator, which is used to generate corresponding weights of features; The dynamic upsampling operator includes a dynamic weight generation block, which performs a convolution operation on an input feature of the dynamic upsampling operator to obtain a weight feature, wherein the weight feature includes context information; Dynamically selecting each sampling position according to the weight feature to obtain a sampling point and a dynamic weight, wherein the dynamic weight uniquely corresponds to the sampling point; The pixel values of the input features are weighted summed according to the sampling points and the dynamic weights to generate dynamic up-sampling features.
8. A real-time traffic target detection system based on adaptive perceptual attention, characterized in that: include: A preprocessing module, used to obtain and preprocess a real-time traffic target image, and input the preprocessed real-time traffic target image into a traffic target detection model, wherein the traffic target detection model includes an attention internal scale feature interaction module, a multi-scale offset perception attention module, and a bidirectional cross-scale feature fusion module; an attention internal scale feature interaction module, used to obtain basic image features of the real-time traffic target image, and then perform multi-head attention enhancement processing on the basic image features according to the attention internal scale feature interaction module to obtain multi-head attention enhancement features, wherein the multi-head attention enhancement processing is based on an adaptive scaling factor, and the adaptive scaling factor is used to dynamically adjust the feature attention strength of the attention head; A multi-scale offset-aware attention module, used for performing multi-scale feature enhancement processing on the multi-head attention enhancement feature to obtain a multi-scale enhanced feature, wherein the multi-scale feature enhancement processing is based on relative position information; A bidirectional cross-scale feature fusion module, used for performing feature fusion capability enhancement processing on the multi-scale enhanced features to obtain fusion enhanced features, wherein the bidirectional cross-scale feature fusion module is based on a cross-layer connection structure, and the feature fusion capability enhancement processing is based on a dynamic upsampling operator, and the dynamic upsampling operator is used to reduce feature loss; The detection output module is used to perform target detection according to the fusion enhancement features to obtain a final traffic target detection result.
9. A storage medium, characterized in that: The storage medium stores one or more programs, which, when executed by the processor, implement the real-time traffic target detection method based on adaptive perceptual attention as described in any one of claims 1 to 7.
10. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, it implements the real-time traffic target detection method based on adaptive perceptual attention as described in any one of claims 1-7.
Citation Information
Patent Citations
Traffic person and vehicle non-target detection method for small target
CN114332780A
Traffic sign detection and identification method and system based on multi-scale attention
CN118470685A
RGB-D salient target detection method and system based on cross-modal correlation learning
CN119360177A
Power equipment detection method and system
CN119649004A
Multi-task joint sensing network model and detection method for traffic road surface information
WO2024138993A1
Cited By
Traditional Chinese medicine tumor collaborative treatment clinical data analysis method
CN120853773A
A traditional Chinese medicine tumor synergistic treatment clinical data analysis method
CN120853773B
Traffic monitoring video rapid target extraction method for edge device
CN120953871A
An edge device-oriented traffic monitoring video fast target extraction method
CN120953871B