Target detection method and device based on multi-scale contrast and dual-domain attention enhancement

By enhancing the backbone network through multi-scale contrast, employing dual-domain attention crossover, and fusing dynamic features, the accuracy and robustness issues of target detection from an aerial perspective are addressed, achieving efficient small target detection.

CN122493032APending Publication Date: 2026-07-31SOUTHWEAT UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHWEAT UNIV OF SCI & TECH
Filing Date
2026-05-27
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing target detection methods suffer from problems such as high false negative rate and inaccurate localization when viewed from an aerial perspective. These problems are mainly due to the lack of explicit modeling of the target and background in the backbone network, the attention mechanism working only in a single spatial domain, the non-adaptive upsampling operation of the feature pyramid, and insufficient detection head coverage.

Method used

A multi-scale contrast enhancement backbone network (C2f-MAC module) is used to explicitly model the contrast between the target and the background. Wavelet-prototype enhanced cross-attention (WP-AIFI) is introduced to enhance dual-domain features. The feature fusion process is optimized by a dynamic multi-level cross-scale feature fusion module (DM-CCFF) to extend the multi-level detection head to shallow high resolution.

Benefits of technology

While reducing the number of parameters by 30% and increasing the computational load by 11%, the accuracy of target detection was significantly improved, with mAP50 increasing by about 4 percentage points, and the recall capability and robustness for extremely small targets were enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122493032A_ABST
    Figure CN122493032A_ABST
Patent Text Reader

Abstract

This invention discloses a target detection method and apparatus based on multi-scale contrast and dual-domain attention enhancement, belonging to the field of image processing technology. Building upon a single-stage detection framework, this method enhances the target-background discriminative power of the backbone network by providing a multi-scale hole contrast module. It achieves dual-domain query refinement in both the frequency and spatial domains through parallel wavelet-enhanced cross-attention and prototype-guided cross-attention. A dynamic content-aware upsampler optimizes spatial information preservation during feature fusion, and an extended shallow high-resolution detection head improves recall for extremely small targets. Experimental results on the public dataset VisDrone2019 show that the proposed method improves mAP50 by approximately 4 percentage points while reducing the number of parameters by 30% and increasing computation by only 11%, achieving significant accuracy gains while maintaining high inference speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a target detection method and apparatus based on multi-scale contrast and dual-domain attention enhancement. Background Technology

[0002] Smart city transportation systems rely heavily on unmanned aerial vehicle (UAV) platforms for large-scale, high-efficiency visual monitoring. Robust object detection is a crucial prerequisite for vehicle recognition, pedestrian localization, and traffic situation awareness. However, aerial traffic images are characterized by extremely small target scale, variable perspectives, complex backgrounds, and susceptibility to occlusion and lighting changes. This often leads to high false negative rates and inaccurate localization for small targets in such scenarios, making it difficult for general object detection models to meet the dual requirements of detection accuracy and real-time performance in smart transportation systems.

[0003] Most existing real-time object detection methods are based on a single-stage detection framework, which improves representation capabilities through multi-scale feature fusion and attention mechanisms, but still have the following shortcomings: First, the standard convolutions in the backbone network lack explicit modeling of the contrast between the target and the background, which makes the discriminative features of very small targets easily submerged by the background. Secondly, the attention in the encoder usually only works in a single spatial domain, and has limited ability to perceive the collaborative texture of the target and global semantics. Third, the upsampling operation in the feature pyramid mostly uses fixed interpolation methods, which cannot adaptively recover spatial information based on the content, resulting in blurred target boundaries or positional shifts. Fourth, the detection head relies solely on high semantic level features, which does not provide sufficient coverage for extremely small targets. Summary of the Invention

[0004] In view of the above problems, the present invention provides a target detection method and apparatus based on multi-scale contrast and dual-domain attention enhancement to overcome the above problems or at least partially solve the above problems.

[0005] This invention provides the following solution: A target detection method based on multi-scale contrast and dual-domain attention enhancement includes: Obtain the input image; The input image is used to extract features through a multi-scale contrast enhancement backbone network to generate multi-level feature maps. The multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background. The highest-level feature map in the multi-level feature map is input into the wavelet-prototype enhancement scale-interaction module for encoding; the wavelet-prototype enhancement scale-interaction module includes a parallel structure of wavelet enhanced cross-attention (WCA) and prototype guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. The enhanced feature map and the shallow feature map are fused by a dynamic multi-level cross-scale feature fusion module. The dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The multi-scale fused features are used to perform target classification and bounding box regression by a multi-level detection head to obtain the detection results.

[0006] A target detection device based on multi-scale contrast and dual-domain attention enhancement, used to execute the above-mentioned target detection method based on multi-scale contrast and dual-domain attention enhancement, the device comprising: The image acquisition unit is used to acquire the input image; A multi-scale contrast feature extraction unit is used to extract features from the input image through a multi-scale contrast enhancement backbone network to generate multi-level feature maps; the multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background; A dual-attention coding unit is used to input the highest-level feature map into the wavelet-prototype-enhanced intra-scale feature interaction module for encoding; the wavelet-prototype-enhanced intra-scale feature interaction module includes a parallel structure of wavelet-enhanced cross-attention (WCA) and prototype-guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. A cross-scale feature fusion unit is used to fuse the enhanced feature map and the shallow feature map through a dynamic multi-level cross-scale feature fusion module. The dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The target recognition unit is used to perform target classification and bounding box regression on the multi-scale fusion features through a multi-level detection head to obtain the detection results.

[0007] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects: This invention provides a target detection method and apparatus based on multi-scale contrast and dual-domain attention enhancement. Building upon a single-stage detection framework, this method enhances the target background discrimination capability of the backbone network by providing a multi-scale hole contrast module. It achieves dual-domain query refinement in both the frequency and spatial domains through parallel wavelet-enhanced cross-attention and prototype-guided cross-attention. A dynamic content-aware upsampler optimizes spatial information preservation during feature fusion, and an extended shallow high-resolution detection head improves recall for extremely small targets. Experimental results on the public dataset VisDrone2019 show that the proposed method improves mAP50 by approximately 4 percentage points while reducing the number of parameters by 30% and increasing computation by only 11%, achieving significant accuracy gains while maintaining high inference speed. Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0008] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0009] Figure 1 This is a flowchart of the target detection method based on multi-scale contrast and dual-domain attention enhancement provided in the embodiments of the present invention; Figure 2 This is a diagram of the overall network architecture provided in an embodiment of the present invention; Figure 3 This is a C2f-MAC structure diagram provided in an embodiment of the present invention; Figure 4 This is a MAC structure diagram provided in an embodiment of the present invention; Figure 5 This is a structural diagram of WP-AIFI provided in an embodiment of the present invention; Figure 6 This is a WCA structure diagram provided in an embodiment of the present invention; Figure 7 This is a structural diagram of the MSCW provided in an embodiment of the present invention; Figure 8 This is a PCA structure diagram provided in an embodiment of the present invention; Figure 9 This is a WPA structure diagram provided in an embodiment of the present invention; Figure 10 This is a schematic diagram of a target detection device based on multi-scale contrast and dual-domain attention enhancement provided in an embodiment of the present invention; Figure 11This is a schematic diagram of a target detection device based on multi-scale contrast and dual-domain attention enhancement provided in an embodiment of the present invention. Detailed Implementation

[0010] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention are within the scope of protection of the present invention.

[0011] See Figure 1 This invention provides a target detection method based on multi-scale contrast and dual-domain attention enhancement, as exemplified by the present invention. Figure 1 As shown, the method may include: S101: Obtain the input image; S102: Feature extraction is performed on the input image using a multi-scale contrast enhancement backbone network to generate multi-level feature maps; the multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background; in specific implementation, the processing steps of the C2f-MAC module of the multi-scale contrast enhancement backbone network can be provided as follows: The number of channels in the input feature map is compressed to the target value through 1×1 pointwise convolution; The compressed feature map is uniformly split into direct connection branches and convolutional branches along the channel dimension; The convolutional branch undergoes feature transformation via the MAC module, and the direct connection branch performs identity mapping. The outputs of the direct connection branch and the convolutional branch are concatenated along the channel dimension to fuse shallow details and deep semantics. Channel fusion is performed through 1×1 pointwise convolution, and then the output is output after global residual connection with the module input.

[0012] Furthermore, the processing steps of the MAC module include: The input feature map is uniformly split into four branches along the channel dimension; Perform an identity mapping on the first branch to preserve the original pixel-level detail features and output the first feature; Perform a 3×3 depthwise convolution and ReLU activation on the second branch to output the second feature; After adding the third branch to the second feature, perform a 5×5 depthwise convolution and ReLU activation to output the third feature; After performing the addition operation on the fourth branch and the third feature, the two outputs are added in parallel through 3×3 depth convolution and 3×3 depth dilated convolution, and then batch normalization and ReLU activation are performed sequentially to output the fourth feature. The first, second, third, and fourth features are concatenated along the channel dimension, fused by 3×3 convolution, and then residually connected to the input of the MAC module before being activated by ReLU and output.

[0013] S103: Input the highest-level feature map in the multi-level feature map into the wavelet-prototype-enhanced intra-scale feature interaction module for encoding; the wavelet-prototype-enhanced intra-scale feature interaction module includes a parallel structure of wavelet-enhanced cross-attention (WCA) and prototype-guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. The processing steps of the wavelet-enhanced cross-attention (WCA) include: The input feature map is decomposed into one low-frequency sub-band and three high-frequency sub-bands by two-dimensional wavelet transform, and the input feature map is pooled to reduce the amount of computation. The three high-frequency subbands are added together and then fused with the low-frequency subbands. Adaptive weights are generated through a multi-scale channel weighting module. The adaptive weights are multiplied point by point with the high-frequency features and then added with the low-frequency features to obtain the fused frequency domain feature map. The frequency domain feature map is flattened into a key-value token, and cross-attention is calculated between it and the query token obtained by flattening the input features. The result is then output after layer normalization.

[0014] The processing steps of the prototype-guided cross-attention PCA include: Local features of the input feature map are extracted using a 3×3 depthwise separable convolution. The local features are used to generate prototype weights through a linear layer, and then aggregated through matrix multiplication to obtain a small target prototype. After fusing the small target prototype with the input features, attention weights are generated through a multi-scale channel weighting module; The attention weights are multiplied element-wise by the original tokens and then output after layer normalization.

[0015] S104: The enhanced feature map and the shallow feature map are fused through a dynamic multi-level cross-scale feature fusion module; the dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path, and expands the feature pyramid to the shallow level (P2 level), outputting multi-scale fused features; in specific implementation, the processing steps of the dynamic content-aware upsampler DySample in this embodiment of the invention include: The sampling point offset is generated by a 1×1 convolutional layer, and the number of channels of the offset is 2g×s², where g is the number of channel groups and s is the upsampling factor. The offset is scaled by multiplying it by a static range factor of 0.25; The scaled offset is added to the initial sampling grid generated based on the bilinear initialization rule to obtain the final set of sampling point coordinates; Based on the set of sampling point coordinates, sampling is performed on the input feature map to obtain the upsampled feature map.

[0016] The multi-level feature map includes four levels: P2, P3, P4, and P5, which correspond to 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input image resolution, respectively.

[0017] The lowest-level expansion steps in the dynamic multi-level cross-scale feature fusion module include: The fused features of the P3 layer are upsampled to the same resolution as the features of the backbone P2 layer using DySample. The upsampled P3 features are concatenated with the backbone P2 features mapped by a 1×1 convolutional channel by channel dimension. The spliced ​​features are input into the RepC3 module for feature fusion. The RepC3 module is composed of multiple stacked RepConv residual blocks.

[0018] S105: The multi-scale fusion features are classified and bounding box regressed using a multi-level detection head to obtain the detection results.

[0019] In specific implementation, the embodiments of the present invention can provide that the method is based on the RT-DETR single-stage end-to-end detection framework, and the entire network is trained end-to-end through joint supervision of classification loss and regression loss.

[0020] The target detection method based on multi-scale contrast and dual-domain attention enhancement provided in this invention provides a multi-scale contrast enhancement backbone network that replaces the basic residual module with a C2f-MAC module. It utilizes parallel multi-scale dilated contrastive convolution kernels to explicitly model the contrast information between the target and the background, effectively enhancing the feature response of small targets of different sizes.

[0021] The Wavelet-Prototype Enhanced Intra-Scale Feature Interaction Module (WP-AIFI) is adopted, which introduces Wavelet Enhanced Cross Attention (WCA) and Prototype Guided Cross Attention (PCA) into the high-level feature interaction stage of the encoder. The original single spatial domain multi-head self-attention is replaced with a parallel structure, and the query vector is complementarily enhanced from the frequency domain and spatial domain, providing a higher quality initial query for subsequent detection.

[0022] A dynamic content-aware upsampling algorithm, DySample, is introduced. By learning the sampling point position offset, the upsampling during feature fusion can adaptively adjust the interpolation position according to the content, effectively mitigating the problem of spatial detail loss. The multi-level detection head is extended to the P2 layer to fully utilize the fine spatial information in the shallow high-resolution features, significantly improving the detection recall rate of extremely small targets.

[0023] This method, based on a single-stage detection framework, enhances the target-background discriminative power of the backbone network by providing a multi-scale hole contrast module. It achieves dual-domain query refinement in both the frequency and spatial domains through parallel wavelet-enhanced cross-attention and prototype-guided cross-attention. A dynamic content-aware upsampler optimizes spatial information preservation during feature fusion, and an extended shallow high-resolution detection head improves recall for extremely small targets. Experimental results on the public dataset VisDrone2019 demonstrate that the proposed method achieves a 4-percentage-point improvement in mAP50 while reducing the number of parameters by 30% and increasing computation by only 11%, achieving significant accuracy gains while maintaining high inference speed.

[0024] The target detection method based on multi-scale contrast and dual-domain attention enhancement provided by the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0025] The detection method provided in this invention is based on the RT-DETR single-stage end-to-end detection framework. It addresses the problems of extremely small target scale, complex background, and insufficient feature discriminative power in small target detection from the perspective of drones in smart city traffic scenarios by providing multi-module collaborative optimization. The improved overall network architecture is as follows: Figure 2 As shown, it mainly consists of four core parts: a multi-scale contrast enhancement backbone network, a wavelet-prototype enhanced intra-scale feature interaction module (WP-AIFI), a dynamic content-aware upsampling module, and a multi-level feature pyramid detection head.

[0026] like Figure 2 As shown, the input image is first processed by a multi-scale contrast enhancement backbone network to extract multi-level features. This backbone network replaces the basic residual module in the original RT-DETR with a C2f-MAC module, which integrates multi-scale dilated contrastive convolution (MAC). Through parallel multi-branch dilated contrast calculation, it enhances the contrast between the target and the background, and outputs feature maps at four levels: P2, P3, P4, and P5, corresponding to 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input resolution, respectively.

[0027] Subsequently, the highest-level feature P5 enters the WP-AIFI module in the efficient hybrid encoder for intra-scale feature interaction. WP-AIFI replaces the single spatial domain multi-head self-attention in the original AIFI with a parallel structure of wavelet-enhanced cross-attention (WCA) and prototype-guided cross-attention (PCA), complementarily enhancing the query vector from the frequency and spatial domains to generate encoded features with stronger discriminative power.

[0028] In the cross-scale feature fusion stage, a dynamic multi-level cross-scale feature fusion module (DM-CCFF) is constructed. The enhanced encoded feature P5 is gradually fused with the shallow features P2, P3, and P4 through the cross-scale fusion module. The conventional upsampling in CCFF is replaced by a dynamic content-aware upsampling unit DySample, which achieves content-adaptive feature resolution recovery by learning the sampling point position offset, generating the enhanced multi-scale fused features F2, F3, F4, and F5.

[0029] Finally, the RT-DETR detection head performs target classification and bounding box regression on the fused features at four scales: P2, P3, P4, and P5. The entire network is trained end-to-end under joint supervision of classification and regression losses, ultimately outputting multi-scale detection results. Furthermore, without significantly increasing computational overhead, it significantly improves the detection accuracy and robustness of small targets in smart city traffic scenarios.

[0030] Multi-scale contrast-enhanced backbone network: In object detection tasks, the backbone network is responsible for extracting multi-scale feature representations from the input image, and its extraction quality directly affects the prediction accuracy of subsequent detection heads. The original RT-DETR uses the ResNet series as the backbone network, with its basic building blocks being standard residual modules, internally using standard convolutions for feature transformation. However, standard convolutions perform indiscriminate weighting of all spatial locations, lacking the ability to explicitly model the contrast relationship between the target and the background. In the drone-view scenario of smart city traffic, many targets occupy only a few pixels and are often in complex backgrounds. Standard convolutions struggle to effectively distinguish small targets from the surrounding background areas, causing discriminative features to be gradually submerged by background information during the layer-by-layer transmission process.

[0031] To address the aforementioned issues, this invention provides a multi-scale contrast enhancement backbone network, which replaces the original basic residual module with a C2f-MAC module, and introduces a multi-scale atrous-contrast convolution (MAC) as the core feature transformation unit.

[0032] Overall architecture of the C2f-MAC module: like Figure 3As shown, the C2f-MAC module, while retaining the efficient feature reuse characteristics of Cross-Stage Locally Connected Networks (CSP), replaces the standard convolution in the original bottleneck layer with a MAC module. The complete execution flow of C2f-MAC first compresses the number of channels in the input feature map to the target value through 1×1 pointwise convolutions, reducing the subsequent computational load. Its mathematical representation is as follows:

[0033] In the formula: Indicates the input feature map, This represents the output of the convolution. This represents a 1×1 pointwise convolution, where the activation function is the SiLU activation function.

[0034] Then, the compressed feature map is uniformly split into two independent branches along the channel dimension: a direct connection branch and a convolutional branch. The convolutional branch undergoes deep feature mining via a MAC module. Afterward, the original features from the direct connection branch and the deep features from the convolutional branch are concatenated along the channel dimension, fusing shallow details with deep semantics. Finally, a 1×1 pointwise convolution is used to perform channel fusion on the concatenated features, and a global residual connection is performed with the module input to output the final feature map. Its expression is:

[0035]

[0036] In the formula Indicates the input feature map, They are The direct connection branches and convolutional branches are uniformly split along the channel dimension. B is the batch size, C is the number of input feature map channels, H is the input feature map height, and W is the input feature map width. This indicates that the tensor belongs to a four-dimensional tensor space over the real number field. This represents a multi-scale dilated contrastive convolution module. This indicates a splicing operation along the channel dimension. This indicates the output feature map.

[0037] MAC module architecture: The core of the C2f-MAC module is the MAC multi-scale dilated contrastive convolutional module. MAC is a parameter-free feature enhancement module. Its core design idea is to directly amplify the gray-level difference between the target and the background in the feature space by using a manual kernel with fixed weights. Compared with traditional learnable convolutional kernels, the MAC module does not need to learn target features through a large amount of data training. It can complete feature enhancement and achieve target-background contrast enhancement through mathematical operations, which is highly compatible with the needs of small target detection scenarios in urban traffic aerial photography.

[0038] like Figure 4 As shown, MAC first compresses the number of channels in the input feature map to the target value using a 1×1 pointwise convolution. Then, it evenly splits the input feature map into four independent branches along the channel dimension, with each branch having 1 / 4 the number of channels of the input. Its mathematical representation is as follows:

[0039] In the formula, This is the input feature map for the MAC module. These are the four branch feature maps after uniform splitting along the channel dimension.

[0040] Then, different operations are performed on the four branch features after the split, starting with the first branch. Performing an identity mapping operation fully preserves the original pixel-level details and prevents the edges of small objects from being overly smoothed by subsequent convolution operations. Its mathematical representation is:

[0041] For the second branch By using a 3×3 depthwise convolution and a simple contrastive convolution kernel, the contrast between small targets with very few pixels and the background is enhanced, effectively improving the perception of small targets. Its mathematical representation is as follows:

[0042] The convolution is a depthwise convolution, and the activation function is the ReLU activation function. This represents the output feature map of the second branch.

[0043] Third Branch First, output the second branch. Cross-branch residual summation, followed by 5×5 depthwise convolution with an expanded contrast kernel, enhances the contrast between small targets with relatively many pixels and the background, validating its ability to perceive slightly larger targets. Its mathematical representation is:

[0044] Here, the convolution is a depthwise convolution, and the activation function is the ReLU activation function. This represents the output feature map of the third branch.

[0045] The fourth branch first performs cross-branch residual fusion with the small target enhancement features output from the third branch. Then, it obtains two feature paths through 3×3 depthwise convolutions (dilation rate 1) and 3×3 depthwise dilated convolutions (dilation rate 2), respectively. These two feature paths are then element-wise added and fused, followed by batch normalization (BN) and ReLU activation functions. The two convolution paths employ 3×3 average pooling kernels and 3×3 peripheral inhibition kernels, respectively, to extract local smooth background and global edge texture information while maintaining lightweight efficiency. This constructs a hybrid receptive field of 3×3 and 7×7, providing a stable multi-scale background reference for small targets and significantly improving the model's ability to distinguish similar texture noise in complex aerial photography backgrounds. Its mathematical representation is as follows:

[0046] The first convolution is a depthwise convolution, the second convolution is a dilated convolution (with a dilation rate of 2), BN represents batch normalization, and the activation function is the ReLU activation function. This represents the output feature map of the fourth branch.

[0047] The feature maps from multiple branches are concatenated along the channel dimension to achieve complementary fusion of multi-scale and multi-granular features. The concatenated features are then fused and dimensionality-normalized using a 3×3 convolution, and the residuals are added to the input features of the MAC module after channel transformation. Finally, the output is processed through a ReLU activation function to form a complete MAC multi-scale dilated contrast enhancement feature. Its mathematical representation is as follows:

[0048]

[0049] in, This indicates the entire output of the MAC module. This represents the input features after channel transformation.

[0050] The mathematical representations of all hand-crafted convolution kernels are as follows:

[0051]

[0052]

[0053] All kernels are defined on a two-dimensional integer coordinate grid (x, y), with the kernel center located at the origin (0, 0), and the kernel size is k × k (k is an odd number). This represents the contrastive convolution kernel, where t represents the pixel length of the central region. This represents the average pooling kernel. This indicates the surrounding suppressor nucleus.

[0054] Wavelet-Prototype Enhanced Intra-Scale Feature Interaction Module (WP-AIFI): In the efficient hybrid encoder of RT-DETR, the attention-based intra-scale feature interaction module (AIFI) is responsible for globally modeling the highest-level feature P5 of the backbone network. The original AIFI employs a standard multi-head self-attention mechanism, where queries, keys, and values ​​all originate from the same feature map, capturing long-distance dependencies by calculating pairwise similarities across all locations in the spatial dimension. However, standard self-attention operates only in a single spatial domain, uniformly calculating similarity across all spatial locations, lacking the ability to specifically model different frequency components and semantically critical regions. In the drone-view scenario of smart city traffic, targets are typically extremely small in scale, have low contrast, and are easily submerged in complex backgrounds. Single-spatial-domain attention interaction struggles to simultaneously capture the fine edge details of the target and the global semantic context, limiting the initialization quality of subsequent query vectors.

[0055] This invention replaces the single-domain multi-head self-attention in the original AIFI with a parallel structure of wavelet-enhanced and prototype-guided attention (WPA), constructing a wavelet-prototype-enhanced intra-scale feature interaction module (WP-AIFI). The overall structure of WP-AIFI is as follows: Figure 5 As shown, the core idea is to complementarily enhance the query vector through parallel processing in both the frequency and spatial domains: the WCA path performs multi-frequency decomposition and adaptive modulation of features in the wavelet domain, giving the query a high sensitivity to the detailed texture of the target; the PCA path aggregates key region information in the spatial domain through learnable semantic prototypes, guiding the query to focus on the salient region of the target. The outputs of the two paths are added element-wise and then connected with the input query to form a residual connection. This residual connection is further transformed by a feedforward network to finally output the enhanced encoded features.

[0056] Wavelet-enhanced cross-attention (WCA): In the frequency domain, different frequency components of a feature map carry different types of information: low-frequency components describe the overall structure and smooth areas of the image, while high-frequency components contain details such as the edges and textures of the target. For small target detection, high-frequency details are a key breakthrough in distinguishing the target from the background, but they are also easily affected by background noise. The design goal of WCA is to fully utilize the detail representation capabilities of high-frequency components while suppressing noise components through an adaptive modulation mechanism.

[0057] like Figure 6As shown, Wavelet Enhanced Cross-Attention (WCA) decomposes features into high and low frequency components through discrete wavelet transform, specifically enhancing high-frequency details in small target sets while suppressing large-scale background noise. First, a two-dimensional wavelet pooling transform is used to pool the input feature map to reduce computation, simultaneously decomposing it into one low-frequency subband (LL) and three high-frequency subbands (LH, HL, HH), represented as follows:

[0058] WavePool is the wavelet pooling operation. The feature maps are for one low-frequency subband (LL) and three high-frequency subbands (LH, HH, HL).

[0059] After obtaining different high and low frequency features, adaptive high and low frequency fusion is performed. The high-frequency subbands are added together and then fused with the low-frequency subbands, as shown below. Figure 7 As shown, adaptive weights are generated through a multi-scale channel weighting module (MSCW). Finally, the weights are multiplied point by point with the high-frequency features, and then the low-frequency features are added to obtain the feature map in the frequency domain.

[0060] Its mathematical expression is:

[0061]

[0062]

[0063] GAP stands for Global Average Pooling. It is the sigmoid function. It is the weight of high-frequency features. It is a frequency domain feature map.

[0064] The fused frequency features are flattened into tokens, which are used as keys and values. These tokens, along with the flattened tokens of the input features, are used as queries for cross-attention. The results are then residually concatenated with the original tokens. Finally, layer normalization is performed to obtain the output of WCA, expressed as follows:

[0065]

[0066] Where CrossAttn represents cross-attention. This is the output of the WCA attention module.

[0067] Prototype-guided cross-attention (PCA): In the spatial domain, standard all-pair and all-cross attention requires calculating similarity matrices at all spatial locations, which is not only computationally complex but also dilutes the query's focus on the target's key regions due to the involvement of a large number of background regions. PCA aims to reduce the interference of background redundancy on query updates by introducing a set of learnable semantic prototypes to dynamically aggregate the most discriminative semantic information from image features. It addresses the attention drift problem in small object detection by using small object prototypes learned from input features as priors to guide attention to the true target region and filter out similar texture noise in the background.

[0068] like Figure 8 As shown, the input feature map is first processed by a 3×3 depthwise separable convolution to extract local features. These local features are then processed through a linear layer to generate prototype weights, which are then aggregated using matrix multiplication to obtain small target prototypes. Finally, the prototypes are fused with the input and processed by a second multi-scale channel weighting module (MSCW) to generate attention weights. These weights are then multiplied element-wise with the original tokens, and residual connections and layer normalization are performed to obtain the PCA output. Its expression is:

[0069]

[0070]

[0071]

[0072] in, For prototype weights, For attention weights, This is the output of PCA.

[0073] Wavelet Enhancement and Prototype-Guided Attention (WPA): like Figure 9 As shown, the input feature map is processed by WCA and PCA to obtain two outputs. The two outputs are then added element-wise, and the tensor dimension is transformed to [B, C, H, W] to obtain the output feature map of WPA. Its mathematical representation is:

[0074] in, This indicates the output of WPA.

[0075] By introducing a parallel dual-domain attention mechanism in the high-level semantic interaction stage of the encoder, the WP-AIFI module successfully combines the detail enhancement capabilities of the frequency domain with the semantic focusing capabilities of the spatial domain, providing higher-quality encoded features for subsequent query initialization by the detector. Compared to the original AIFI design that relies solely on self-attention in a single spatial domain, WP-AIFI effectively improves the feature response quality for weak targets in complex scenes without significantly increasing computational complexity.

[0076] Dynamic Multi-Level Cross-Scale Feature Fusion Module (DM-CCFF): In the efficient hybrid encoder of RT-DETR, the Cross-Scale Feature Fusion (CCFF) module is responsible for fusing the top-level encoded features output by AIFI with the shallow features P3 and P4 of the backbone network at multiple scales to construct a bidirectional feature pyramid. CCFF contains two information transmission paths: a top-down path that transmits high-level semantic information to shallower layers, achieving cross-scale injection of semantic information; and a bottom-up path that transmits shallow detail information back to deeper layers, enhancing the spatial localization capabilities of each level. However, the original CCFF still has shortcomings in two key aspects: firstly, in the top-down path, bilinear interpolation is used for upsampling when fusing low-resolution features to high-resolution features. This fixed-rule interpolation method cannot adaptively adjust the sampling position according to the feature content, easily leading to blurred or offset target boundary information; secondly, the original CCFF only performs feature fusion at three levels: P3, P4, and P5, lacking utilization of the shallow high-resolution features of layer P2, limiting the network's ability to perceive extremely small targets.

[0077] To address the aforementioned issues, this invention makes two targeted improvements to CCFF, constructing a Dynamic Multi-level Cross-scale Feature Fusion (DM-CCFF): First, the standard bilinear interpolation upsampling in the top-down path is replaced with a dynamic content-aware upsampler DySample, achieving content-adaptive feature resolution restoration; second, a P2 layer is added to the fusion path, further transferring the fused features from the P3 layer to the P2 layer, constructing a four-level feature pyramid from P2 to P5.

[0078] Dynamic content-aware upsampling (DySample): This invention introduces the DySample dynamic upsampler to replace bilinear interpolation, reconstructing the upsampling process from the perspective of point sampling. The core idea of ​​DySample is to view upsampling as a process of resampling on a continuous feature map, where each output pixel corresponds to a learnable sampling point position, and the coordinates of the sampling point are dynamically generated by the input feature content.

[0079] Specifically, given a low-resolution feature map and upsampling factor (in DM-CCFF) DySample first passed Convolutional layers generate sampling point offsets The number of input channels of this convolutional layer is The number of output channels is ,in This represents the number of channel groups (default is 4), with a factor of 2 corresponding to the horizontal and vertical offsets of each sampling point. This corresponds to the number of upsampling points generated for each input pixel. Its mathematical expression is:

[0080] To control the offset range and maintain sampling stability, DySample introduces a static range factor to scale the offset by multiplying it by a coefficient of 0.25. This ensures that adjacent sampling points do not overlap under standard conditions, thus avoiding sampling chaos in boundary regions.

[0081] Furthermore, DySample changes the initial sampling location from nearest neighbor initialization to bilinear initialization. In the nearest neighbor initialization scheme, the corresponding sampling locations for the same input point are... All output sampling points are initialized to the same shared location, ignoring the relative spatial relationships between output points. Bilinear initialization assigns different initial coordinates to each sampling point based on its position in the target grid, making the sampling result equivalent to bilinear interpolation in the zero-offset case.

[0082] In the formula, The initial sampling grid generated according to the bilinear initialization rule has a shape similar to... Consistent, This is the final set of sampling point coordinates. The features are divided along the channel dimension... DySample achieves a good balance between computational efficiency and sampling flexibility by grouping samples into sets, each sharing the same set of sampling locations. Finally, it uses PyTorch's built-in `grid_sample` function to sample the data based on the coordinates of the sampling points. In input features Sampling is performed on the continuous interpolation representation to obtain the upsampled features:

[0083] The `grid_sample` function internally uses bilinear interpolation to calculate the feature value of each sampling point. The entire process is fully differentiable and supports end-to-end gradient backpropagation. Standard bilinear interpolation has been replaced with `DySample`. With adaptive sampling point offset for convolutional learning content, DySample can dynamically adjust the upsampling position according to the semantic distribution of the current features, so that the features of the target boundary region can be more accurately restored to the high-resolution feature map, effectively reducing the spatial information loss during the upsampling process.

[0084] P2 level expansion: The original CCFF only constructs feature pyramids at three levels: P3, P4, and P5. The spatial resolution of the fused features output from the P3 layer is only 1 / 8 of the input image. In the drone-view scenario of smart city traffic, many targets (such as distant pedestrians and small vehicles) occupy only a few to a dozen pixels, providing almost no effective spatial response. To compensate for this deficiency, DM-CCFF adds a P2 layer to the fusion path, expanding the feature pyramid to the P2 layer (with a resolution of 1 / 4 of the input image).

[0085] The newly added P2-level fusion path follows the output of the P3 layer in the top-down path. Specifically, the P3 layer fusion features... Upsampled to the P2 layer of the backbone using DySample At the same resolution, with through The features after convolutional channel mapping are concatenated along the channel dimension:

[0086] The concatenated features are then fused using the RepC3 module. The RepC3 module consists of multiple RepCon modules. The residual blocks are stacked together. During the training phase, a multi-branch structure is used to enhance feature representation capabilities. During the inference phase, the multi-branch structure is merged into a single-path convolution through structural reparameterization, balancing fusion effect and inference efficiency.

[0087] Features after P2 layer fusion It boasts a high spatial resolution, one-quarter that of the input image, and also possesses strong semantic discrimination capabilities due to the incorporation of high-level semantic information passed down from top to bottom. In the bottom-up path, After standard convolution downsampling with stride 2 and By stitching and merging, the fine spatial information of the P2 layer is further transmitted back to the higher layers, enhancing the positioning accuracy of each layer.

[0088] In summary, by introducing the DySample dynamic upsampler and extending the P2 layer, DM-CCFF outputs four-layer multi-scale fused features. , , , These correspond to 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input resolution, respectively. DySample provides more accurate spatial information preservation for feature transfer between different levels, while the P2 level extension extends the coverage of the feature pyramid to extremely small target scales. The two work together to effectively improve the overall quality of multi-scale feature fusion, laying a solid feature foundation for accurate prediction by subsequent multi-level detection heads.

[0089] Experimental results and analysis.

[0090] Dataset introduction: To evaluate the performance of the proposed method in detecting small targets from a UAV perspective in urban traffic scenarios, the VisDrone2019 dataset was used for training and testing. VisDrone2019 is a benchmark dataset for large-scale target detection from a UAV perspective released by Tianjin University. All images were acquired by high-definition cameras mounted on UAVs under different urban environments, at different heights, and from different perspectives. The scenes cover a variety of typical urban environments, including city streets, squares, residential areas, campuses, and transportation hubs, and can comprehensively reflect the real imaging conditions in smart city traffic monitoring.

[0091] The VisDrone 2019 dataset contains 10 object categories: pedestrian, person, bicycle, car, van, truck, tricycle, awning-tricycle, bus, and motorcycle. The dataset contains a total of 8,624 images: 6,471 in the training set, 548 in the validation set, and 1,610 in the test set. Both the training and validation sets provide complete bounding box annotations. The image resolutions vary widely, with the longest side approximately 2,000 pixels and the shortest side approximately 400 pixels.

[0092] The VisDrone 2019 dataset presents a significant challenge for small target detection in urban traffic, with its key characteristics summarized in three aspects. First, the targets are extremely small and exhibit significant differences in scale. Because drones typically fly at altitudes ranging from tens to hundreds of meters, the scale distribution of targets in the images is extremely wide—pedestrians and bicycles often occupy only a few to tens of pixels, representing typical extremely small targets; while vehicles such as buses and trucks have relatively larger scales, reaching hundreds of pixels. This dramatic scale difference places high demands on the detector's multi-scale perception capabilities. Second, targets are densely distributed and have variable perspectives. In urban traffic scenes, pedestrians and vehicles are often densely clustered, with many targets spatially adjacent or even partially occluded. Simultaneously, the drone's perspective differs from the fixed angle of conventional surveillance cameras; its shooting angle dynamically changes with flight attitude, resulting in significant pitch variations and appearance diversity of targets, increasing the difficulty of detection. Third, the background is complex and lighting conditions vary greatly. The urban environment includes diverse background elements such as buildings, roads, greenery, and transportation facilities. In addition, the changes in natural lighting at different times of day, as well as interference factors such as shadows and reflections, make it more difficult to distinguish between the target and the background.

[0093] Experimental environment: This invention's experiments are implemented using the PyTorch deep learning framework and conducted in an Ubuntu operating system environment. Detailed experimental configuration parameters are summarized in Table 1.

[0094] Table 1 Experimental Environment Configuration

[0095] The model was trained for 200 epochs with a batch size of 4, and input images were uniformly scaled to 640×640 pixels. The AdamW optimizer was used with an initial learning rate of 1×10, a momentum coefficient of 0.9, and a weight decay coefficient of 1×10. Cosine annealing was employed for learning rate scheduling. For data augmentation, considering the extremely small and densely distributed targets in the VisDrone2019 dataset, Mosaic and Mixup augmentations were disabled to avoid mosaic stitching or sample mixing that could disrupt the spatial integrity of small targets. Only random horizontal flipping (probability 0.5) and HSV color space perturbations (hue 0.015, saturation 0.7, brightness 0.4) were used to increase sample diversity while maintaining the plausibility of the target appearance. During the validation phase, the IoU threshold was set to 0.7, the confidence threshold to 0.001, and the maximum number of detections to 300. All experiments were performed on a single RTX 3090 GPU, with a fixed random seed of 0 and deterministic mode enabled to ensure reproducibility.

[0096] Evaluation indicators: To comprehensively evaluate the detection performance of the method of this invention, the experiment selected evaluation indicators from two dimensions: detection accuracy and model efficiency.

[0097] Regarding detection accuracy, the mean precision (AP), a common evaluation metric in the field of target detection, is used as the core evaluation indicator. AP is defined as the area under the precision-recall curve, and the formulas for precision and recall are as follows:

[0098] In the formula, TP represents true positives, FP represents false positives, and FN represents false negatives. The mean precision is obtained by averaging the AP values ​​for all classes.

[0099] In the formula, This represents the total number of target categories in the VisDrone2019 dataset. This invention employs two commonly used metrics: mAP@0.5 and mAP@0.5:0.95. mAP@0.5 refers to the average accuracy when the IoU threshold is fixed at 0.5, while mAP@0.5:0.95 refers to the average accuracy across 10 thresholds with an IoU threshold ranging from 0.5 to 0.95 and a step size of 0.05. The latter more comprehensively reflects the overall performance of the detector under different positioning accuracy requirements.

[0100] In terms of model efficiency evaluation, this invention uses the number of parameters and the number of billion floating-point operations (GFLOPs) to measure the computational complexity of the model.

[0101] Model performance comparison: To fully verify the effectiveness of the improved method proposed in this invention, this section provides a quantitative analysis from two aspects: comparative experiments with mainstream detection models and ablation experiments of each improved module.

[0102] Comparative experiment: To evaluate the overall performance of the improved model of this invention, it was compared with the original RTDETR-r18 baseline model and three current mainstream lightweight detection models, YOLOv10m, YOLOv11m, and YOLOv12m, on the VisDrone2019 validation set. The experimental results are shown in Table 2.

[0103] Table 2 Comparative Experiments

[0104] As shown in Table 2, the model of this invention achieved the best results in all accuracy metrics. Compared with the original RTDETR-r18 baseline, the model of this invention improved precision by 1.6 percentage points, recall by 3.8 percentage points, mAP@0.5 by 3.9 percentage points, and mAP@0.5:0.95 by 3.4 percentage points. The significant improvement in recall indicates that by introducing a multi-scale contrast-enhanced backbone network and a P2 detector, the model significantly reduced the false negative rate for extremely small targets; while the simultaneous improvement in precision indicates that the dual-domain attention mechanism in WP-AIFI effectively suppressed false positives caused by complex backgrounds.

[0105] In terms of model efficiency, the improved model exhibits a significant advantage. The number of parameters is only 11.4M, a 42.4% reduction compared to the original RTDETR-r18, and only 56.4% of YOLOv12m. This is mainly due to the channel grouping and shared convolutional kernel weights design in the C2f-MAC module, which effectively reduces parameter redundancy. GFLOPs increased from the baseline of 57.0 to 63.3, an increase of approximately 11%. This increase is primarily due to the introduction of the P2 detection head. The P2 layer requires additional top-down and bottom-up fusion paths, increasing the computation of feature concatenation, RepC3 convolution, and subsequent detection heads at various scales. Nevertheless, the improved model's GFLOPs are still lower than YOLOv10m (64.0), YOLOv11m (68.5), and YOLOv12m (68.1). Considering its accuracy advantage, the improved model achieves a better balance between detection performance and computational efficiency.

[0106] As can be seen, to address the problem of insufficient detection accuracy caused by the extremely small target scale and complex background in smart city traffic scenarios from the perspective of drones, this invention provides a small target detection method based on multi-scale contrast and dual-domain attention enhancement. Building upon the RT-DETR single-stage end-to-end detection framework, this method effectively achieves accurate detection of small targets and robust suppression of complex backgrounds through four core improvements: a multi-scale contrast enhancement backbone network, a wavelet-prototype enhanced intra-scale feature interaction module, a dynamic multi-level cross-scale feature fusion module, and a multi-level detection head extension.

[0107] Experiments show that this method achieves state-of-the-art detection performance on the VisDrone2019 dataset. Compared to the original RTDETR-r18 baseline, the improved model achieves a 3.9 percentage point improvement in mAP@0.5 to 50.3% and a 3.8 percentage point improvement in Recall to 48.1%, while reducing the number of parameters by 42.4%. Compared to mainstream lightweight detectors such as YOLOv10m, YOLOv11m, and YOLOv12m, the improved model outperforms them by 7.3, 4.7, and 5.0 percentage points in mAP@0.5, respectively, fully validating its good balance between accuracy and efficiency.

[0108] In summary, the target detection method based on multi-scale contrast and dual-domain attention enhancement provided in this invention effectively solves the problems of insufficient discriminative power of small target features, spatial information loss during cross-scale fusion, and insufficient multi-scale detection coverage, providing an effective solution for real-time target detection in aerial photography in urban traffic scenarios. Future research can further explore model lightweighting and inference acceleration, and investigate the transfer and application of the multi-scale contrast enhancement and dual-domain attention mechanism proposed in this invention to broader visual tasks such as multimodal detection and instance segmentation.

[0109] See Figure 10 The present invention can also provide a target detection device based on multi-scale contrast and dual-domain attention enhancement, such as... Figure 10 As shown, the device may include: Image acquisition unit 1001 is used to acquire input images; The multi-scale contrast feature extraction unit 1002 is used to extract features from the input image through a multi-scale contrast enhancement backbone network to generate multi-level feature maps; the multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background; The dual attention coding unit 1003 is used to input the highest-level feature map into the wavelet-prototype enhancement scale feature interaction module for encoding; the wavelet-prototype enhancement scale feature interaction module includes a parallel structure of wavelet enhanced cross attention (WCA) and prototype guided cross attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. The cross-scale feature fusion unit 1004 is used to fuse the enhanced feature map and the shallow feature map through the dynamic multi-level cross-scale feature fusion module; the dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The target recognition unit 1005 is used to perform target classification and bounding box regression on the multi-scale fusion features through a multi-level detection head to obtain the detection result.

[0110] This invention can also provide a target detection device based on multi-scale contrast and dual-domain attention enhancement, the device including a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the steps of the above-described object detection method based on multi-scale contrast and dual-domain attention enhancement according to the instructions in the program code.

[0111] like Figure 11 As shown in the figure, an embodiment of the present invention provides a target detection device based on multi-scale contrast and dual-domain attention enhancement, which may include: a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, the memory 11, and the communication interface 12 all communicate with each other through the communication bus 13.

[0112] In this embodiment of the invention, the processor 10 may be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic devices.

[0113] The processor 10 can call programs stored in the memory 11. Specifically, the processor 10 can execute operations in the embodiments of the target detection method based on multi-scale contrast and dual-domain attention enhancement.

[0114] The memory 11 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 11 stores at least a program for implementing the following functions: Obtain the input image; The input image is used to extract features through a multi-scale contrast enhancement backbone network to generate multi-level feature maps. The multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background. The highest-level feature map in the multi-level feature map is input into the wavelet-prototype enhancement scale-interaction module for encoding; the wavelet-prototype enhancement scale-interaction module includes a parallel structure of wavelet enhanced cross-attention (WCA) and prototype guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. The enhanced feature map and the shallow feature map are fused by a dynamic multi-level cross-scale feature fusion module. The dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The multi-scale fused features are used to perform target classification and bounding box regression by a multi-level detection head to obtain the detection results.

[0115] In one possible implementation, the memory 11 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function (such as file creation or data read / write). The data storage area may store data created during use, such as initialization data.

[0116] In addition, memory 11 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0117] Communication interface 12 can be an interface for the communication module, used to connect with other devices or systems.

[0118] Of course, it should be noted that, Figure 11 The structure shown does not constitute a limitation on the target detection device based on multi-scale contrast and dual-domain attention enhancement in the embodiments of the present invention. In practical applications, the target detection device based on multi-scale contrast and dual-domain attention enhancement may include more than Figure 11 More or fewer components as shown, or combinations of certain components.

[0119] This invention also provides a computer-readable storage medium for storing program code that performs the steps of the above-described object detection method based on multi-scale contrast and dual-domain attention enhancement.

[0120] It should be noted that in this invention, 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.

[0121] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.

[0122] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0123] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A target detection method based on multi-scale contrast and dual-domain attention enhancement, characterized in that, The method includes: Obtain the input image; The input image is used to extract features through a multi-scale contrast enhancement backbone network to generate multi-level feature maps. The multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background. The highest-level feature map in the multi-level feature map is input into the wavelet-prototype enhancement scale-interaction module for encoding; the wavelet-prototype enhancement scale-interaction module includes a parallel structure of wavelet enhanced cross-attention (WCA) and prototype guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. The enhanced feature map and the shallow feature map are fused by a dynamic multi-level cross-scale feature fusion module. The dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The multi-scale fused features are used to perform target classification and bounding box regression by a multi-level detection head to obtain the detection results.

2. The method according to claim 1, characterized in that, The processing steps of the C2f-MAC module include: The number of channels in the input feature map is compressed to the target value through 1×1 pointwise convolution; The compressed feature map is uniformly split into direct connection branches and convolutional branches along the channel dimension; The convolutional branch undergoes feature transformation via the MAC module, and the direct connection branch performs identity mapping. The outputs of the direct connection branch and the convolutional branch are concatenated along the channel dimension to fuse shallow details and deep semantics. Channel fusion is performed through 1×1 pointwise convolution, and then the output is output after global residual connection with the module input.

3. The method according to claim 2, characterized in that, The processing steps of the MAC module include: The input feature map is uniformly split into four branches along the channel dimension; Perform an identity mapping on the first branch to preserve the original pixel-level detail features and output the first feature; Perform a 3×3 depthwise convolution and ReLU activation on the second branch to output the second feature; After adding the third branch to the second feature, perform a 5×5 depthwise convolution and ReLU activation to output the third feature; After performing the addition operation on the fourth branch and the third feature, the two outputs are added in parallel through 3×3 depth convolution and 3×3 depth dilated convolution, and then batch normalization and ReLU activation are performed sequentially to output the fourth feature. The first, second, third, and fourth features are concatenated along the channel dimension, fused by 3×3 convolution, and then residually connected to the input of the MAC module before being activated by ReLU and output.

4. The method according to claim 1, characterized in that, The processing steps of the wavelet-enhanced cross-attention (WCA) include: The input feature map is decomposed into one low-frequency sub-band and three high-frequency sub-bands by two-dimensional wavelet transform, and the input feature map is pooled to reduce the amount of computation. The three high-frequency subbands are added together and then fused with the low-frequency subbands. Adaptive weights are generated through a multi-scale channel weighting module. The adaptive weights are multiplied point by point with the high-frequency features and then added with the low-frequency features to obtain the fused frequency domain feature map. The frequency domain feature map is flattened into a key-value token, and cross-attention is calculated between it and the query token obtained by flattening the input features. The result is then output after layer normalization.

5. The method according to claim 1, characterized in that, The processing steps of the prototype-guided cross-attention PCA include: Local features of the input feature map are extracted using a 3×3 depthwise separable convolution. The local features are used to generate prototype weights through a linear layer, and then aggregated through matrix multiplication to obtain a small target prototype. After fusing the small target prototype with the input features, attention weights are generated through a multi-scale channel weighting module; The attention weights are multiplied element-wise by the original tokens and then output after layer normalization.

6. The method according to claim 1, characterized in that, The processing steps of the dynamic content-aware upsampler DySample include: The sampling point offset is generated by a 1×1 convolutional layer, and the number of channels of the offset is 2g×s², where g is the number of channel groups and s is the upsampling factor. The offset is scaled by multiplying it by a static range factor of 0.25; The scaled offset is added to the initial sampling grid generated based on the bilinear initialization rule to obtain the final set of sampling point coordinates; Based on the set of sampling point coordinates, sampling is performed on the input feature map to obtain the upsampled feature map.

7. The method according to claim 1, characterized in that, The multi-level feature map includes four levels: P2, P3, P4, and P5, which correspond to 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input image resolution, respectively.

8. The method according to claim 7, characterized in that, The lowest-level expansion steps in the dynamic multi-level cross-scale feature fusion module include: The fused features of the P3 layer are upsampled to the same resolution as the features of the backbone P2 layer using DySample. The upsampled P3 features are concatenated with the backbone P2 features mapped by a 1×1 convolutional channel by channel dimension. The spliced ​​features are input into the RepC3 module for feature fusion. The RepC3 module is composed of multiple stacked RepConv residual blocks.

9. The method according to claim 1, characterized in that, The method is based on the RT-DETR single-stage end-to-end detection framework, and the entire network is trained end-to-end through joint supervision of classification loss and regression loss.

10. A target detection device based on multi-scale contrast and dual-domain attention enhancement, characterized in that, The apparatus for performing the target detection method based on multi-scale contrast and dual-domain attention enhancement as described in any one of claims 1-9, the apparatus comprising: The image acquisition unit is used to acquire the input image; A multi-scale contrast feature extraction unit is used to extract features from the input image through a multi-scale contrast enhancement backbone network to generate multi-level feature maps; the multi-scale contrast enhancement backbone network includes a C2f-MAC module, which integrates a multi-scale dilated contrastive convolutional MAC module for explicitly modeling the contrast information between the target and the background; A dual-attention coding unit is used to input the highest-level feature map into the wavelet-prototype-enhanced intra-scale feature interaction module for encoding; the wavelet-prototype-enhanced intra-scale feature interaction module includes a parallel structure of wavelet-enhanced cross-attention (WCA) and prototype-guided cross-attention (PCA) to complementarily enhance features from the frequency domain and spatial domain, and output the enhanced encoded features. A cross-scale feature fusion unit is used to fuse the enhanced feature map and the shallow feature map through a dynamic multi-level cross-scale feature fusion module. The dynamic multi-level cross-scale feature fusion module includes a dynamic content-aware upsampler DySample in the top-down path and expands the feature pyramid to the shallow level to output multi-scale fused features. The target recognition unit is used to perform target classification and bounding box regression on the multi-scale fusion features through a multi-level detection head to obtain the detection results.