A detr model mixed precision quantization method based on foreground weight modulation

CN122368431BActive Publication Date: 2026-10-27XIDIAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610482114.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-04-13
Publication Date
2026-10-27
Estimated Expiration
2046-04-13

AI Technical Summary

Technical Problem

这种方法在遥感场景下暴露出以下局限:首先,由于未区分遥感图像中庞大背景与微小前景目标的重要性差异,导致关键目标特征在低比特位宽下被过度压缩;其次,量化引入的数值误差会严重削弱Transformer解码器中交叉注意力(Cross-Attention)对目标的响应能力,导致注意力权重分布趋于平滑,微弱的前景小目标及边缘模糊目标的注意力特征易被庞大的背景噪声所淹没,定位精度显著下降;最后,传统量化参数的优化仅关注数值重建误差,忽视了检测任务本身的性能诉求

Benefits of technology

本发明所提供的方案中,在Transformer解码器的交叉注意力计算底层引入“乘性调制”机制,通过前景分数图直接干预量化后的注意力权重分布,在不改变量化位宽的前提下,从算子层面有效补偿了量化误差对关键特征表达的破坏,实现了算子级的前景特征补偿;利用多尺度特征与前景调制的协同作用,自适应增强了目标区域的注意力响应。即使在低比特下,模型依然能精准聚焦微弱小目标与旋转目标,大幅减少了背景干扰带来的漏检和误检,增强了复杂背景下微小目标的低精度检测能力。本发明采用分层混合精度量化策略在保持硬件计算架构友好的同时,实现了约3倍的模型存储压缩和1.5倍的推理加速,且将目标检测的精度损失控制在2%以内,为DETR类大模型在算力受限边缘平台的实时部署提供了有效方案,达成了压缩率与高检测精度的平衡。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122368431B_ABST
    Figure CN122368431B_ABST
Patent Text Reader

Abstract

The application discloses a DETR model mixed precision quantization method based on foreground weight modulation, aiming at the problems of large remote sensing model parameter quantity, traditional quantization easily leading to cross attention mechanism degradation and weak target feature being submerged, integrating a lightweight foreground extraction head in the model neck, generating a foreground score map by using a Gaussian distribution soft label supervision, and simultaneously configuring a layered mixed precision strategy, wherein the main part and the neck adopt 4-bit, the Transform adopts 4-bit weight and 8-bit activation, and the detection head keeps FP32 full precision; in the cross attention layer of the Transform decoder, the foreground score map is used to perform operator-level multiplicative modulation on the initial attention weight, and the target region response is dynamically amplified to compensate for the quantization error; while realizing extremely low bit compression and high-speed reasoning of the model, the precision loss is controlled within a very small range, and an efficient scheme is provided for lightweight deployment of resource-constrained edge platforms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision and deep learning model compression technology, specifically involving a method for hybrid precision quantization of DETR models based on foreground weight modulation. Background Technology

[0002] Target detection technology in optical remote sensing images plays a crucial role in various fields such as national defense and resource protection. These images are typically captured by aerial imaging equipment, resulting in large-scale, long-distance images with uneven lighting and susceptibility to cloud interference. Due to the bird's-eye view, targets vary in size, and small targets are often numerous and densely distributed. Thanks to the development of deep learning, CNN-based detection algorithms include YOLO (You Only Look Once) and RTMDet (RTMDet: An Empirical Study of Designing Real-Time Object Detectors). These techniques usually rely on non-maximum suppression (NMS) for post-processing, which effectively removes redundant bounding boxes but also introduces problems such as increased inference time and hyperparameter sensitivity, easily affecting the stability of detection performance in complex environments.

[0003] Given the aforementioned problems, an increasing number of studies are shifting towards truly end-to-end target detection methods. DETR, as a Transformer-based end-to-end target detection model, fundamentally simplifies the detection process by eliminating the NMS step and cumbersome feature map decoding, avoiding the challenges of threshold selection and providing a new technical path for remote sensing target detection. For security and economic reasons, direct remote sensing target detection at the edge, such as on satellites or in aviation, is of great significance. Edge processing can reduce the burden on ground servers, avoid the risk of data transmission leakage, and improve system response speed. However, the high computational complexity and memory overhead of advanced models like DETR severely limit their deployment on resource-constrained edge devices.

[0004] To address this critical bottleneck, Quantization-aware-training (QAT) technology has emerged. QAT is a commonly used method for model compression. By quantizing model parameters and activation values ​​from high-precision floating-point representations to low-precision representations, it can significantly reduce the computational complexity and storage requirements of the model, enabling complex detection models to be efficiently deployed on edge devices. However, existing quantization-aware-training methods have significant technical shortcomings when applied to remote sensing DETR models. Existing QAT methods typically employ purely numerically driven quantization strategies, determining quantization parameters solely based on the statistical distribution of weights and activation values ​​(such as maximum and minimum values), lacking awareness of the task's semantic information. This method exhibits the following limitations in remote sensing scenarios: First, due to the failure to distinguish the importance differences between large backgrounds and small foreground targets in remote sensing images, key target features are over-compressed at low bit widths. Second, the numerical errors introduced by quantization severely weaken the response capability of cross-attention in the Transformer decoder, leading to a smoothing of attention weight distribution. Attention features of weak foreground targets and targets with blurred edges are easily submerged by massive background noise, resulting in a significant decrease in localization accuracy. Finally, traditional quantization parameter optimization focuses only on numerical reconstruction errors, neglecting the performance requirements of the detection task itself. Traditional methods treat quantization as a purely numerical compression problem, failing to fully consider the semantic differences between foreground and background in remote sensing scenarios. They lack mechanisms to preserve and compensate for differentiated features in the key cross-attention layer, ultimately making it difficult for quantization models to balance high compression rates with extremely low bit widths with high detection performance. Summary of the Invention

[0005] To address the aforementioned problems in the existing technology, this invention provides a method for mixing precision quantization of DETR models based on foreground weight modulation. The technical problem to be solved by this invention is achieved through the following technical solution: This invention provides a method for quantizing the mixed precision of a DETR model based on foreground weight modulation, the method comprising: The image to be detected is preprocessed, and the preprocessed image is input into the pre-trained target detection model. Multi-scale image features are extracted through the backbone network and the neck network. A foreground score map is generated based on multi-scale image features using a foreground extraction head introduced in the neck network; Hybrid precision quantization is performed on the DETR encoder-decoder in the pre-trained object detection model. During the forward propagation of the decoder, the initial attention weights generated by its cross-attention layer are obtained. The corresponding foreground score is sampled from the foreground score map according to the reference point coordinates of the target query. The initial attention weights are multiplicatively modulated using the foreground score in the decoder to obtain the modulated enhanced attention weights. The decoder forward propagation is performed based on the modulated enhanced attention weights, and the final target detection result is output through the detection head that maintains floating-point precision. The target detection model is configured with a backbone network, a neck network, and a Transformer module. The backbone network uses ResNet50; the neck network uses Channel Mapper; all convolutional layers in the backbone and neck networks use a lightweight first preset weight and activation precision quantization strategy; the Transformer module includes a multi-scale deformable attention layer and a feedforward network; all linear layers in the Transformer module use a second preset weight and activation hybrid precision quantization strategy.

[0006] In one embodiment of the present invention, preprocessing of the image to be detected includes: The sliding window method is used to segment the image to be detected according to a preset window size and a preset step size to obtain a preprocessed image.

[0007] In one embodiment of the present invention, the training process of the target detection model includes: S01, the initial remote sensing image samples are segmented using the sliding window method, and a remote sensing image sample set is constructed by converting the annotation format; S02, based on the Deformable DETR architecture, performs end-to-end full-precision training on a remote sensing image sample set to obtain a floating-point benchmark model; S03 integrates a lightweight extraction branch into the neck of the floating-point benchmark model, and trains it using Gaussian soft labels and a joint loss function to obtain a model with foreground awareness. S04. Configure quantization strategies for the backbone network, neck network, and Transformer linear layer in the model with foreground awareness. In the model with foreground awareness, introduce a foreground weight modulation operator into the cross-attention layer of the decoder. Use the LSQ algorithm for quantization awareness training to achieve collaborative optimization of quantization step size parameters and foreground modulation parameters, and obtain a pseudo-quantized model. S05, convert the format of the weights of the pseudo-quantization model, extract the quantization scaling factor, and export the mixed precision deployment model; S06, perform edge-end inference deployment and verification of the mixed-precision deployment model, and determine whether the model performance meets the standards through fixed-point inference calculation: If the performance meets the requirements, the mixed-precision deployment model will be output as the pre-trained object detection model. If the performance does not meet the target, adjust the guidance strength, quantization bit width, or training strategy, return to step S04, and repeat steps S04-S06 until the performance meets the target. Then, output the mixed-precision deployment model as the pre-trained object detection model.

[0008] In one embodiment of the invention, a lightweight foreground extraction head is integrated for each feature scale in the neck network, and the foreground extraction head for each feature scale adopts the same network architecture and shares parameters.

[0009] In one embodiment of the present invention, the process of generating a foreground score map based on multi-scale image features includes: The feature maps of each feature scale in the multi-scale image feature are initially reduced in dimensionality by layer normalization and fully connected layers, and then activated by the GELU function to obtain the dimensionality-reduced features. The dimensionality reduction features are divided into local features and global features along the channel dimension. The global features are then combined with the local features after average pooling to obtain the fused features. The fused features are gradually reduced in dimensionality using a fully connected network to obtain a foreground score map.

[0010] In one embodiment of the present invention, the expression for the modulated enhanced attention weights is as follows: ; in, This represents the modulated enhanced attention weights. This represents the initial attention weights after quantization. This indicates element-wise multiplication. This represents the hyperparameter controlling the modulation intensity. This indicates the prospect score.

[0011] In one embodiment of the present invention, the expression for the Gaussian soft label is as follows: ; in, Represents pixels The corresponding Gaussian soft tag, N This represents the total number of bounding boxes in the image. Indicates the first i The center coordinates of the target bounding box Indicates the first i The Gaussian standard deviation of the target boxes.

[0012] In one embodiment of the present invention, the expression for the joint loss function is as follows: ; in, Denotes the joint loss function. Indicates the target detection loss. This represents the first loss weighting coefficient. Indicates the foreground extraction loss. This represents the second loss weighting coefficient. This indicates the quantization regularization term.

[0013] In one embodiment of the present invention, the target detection loss includes: Classification loss Bounding box regression loss and IoU loss .

[0014] In one embodiment of the present invention, the precision quantization strategy of the first preset weight and activation is a precision quantization strategy of 4-bit weight and 4-bit activation; the mixed precision quantization strategy of the second preset weight and activation is a mixed precision quantization strategy of 4-bit weight and 8-bit activation.

[0015] The beneficial effects of this invention are: The solution provided in this invention introduces a "multiplicative modulation" mechanism at the underlying level of cross-attention calculation in the Transformer decoder. This mechanism directly intervenes in the distribution of attention weights after quantization through the foreground score map, effectively compensating for the destruction of key feature representation by quantization errors at the operator level without changing the quantization bit width. This achieves operator-level foreground feature compensation. By leveraging the synergistic effect of multi-scale features and foreground modulation, the attention response of the target region is adaptively enhanced. Even at low bit depths, the model can still accurately focus on weak and rotating targets, significantly reducing false negatives and false negatives caused by background interference, and enhancing the low-precision detection capability of small targets in complex backgrounds. This invention employs a hierarchical hybrid precision quantization strategy, achieving approximately 3x model storage compression and 1.5x inference acceleration while maintaining hardware-friendly computing architecture, and controlling the accuracy loss of target detection to within 2%. This provides an effective solution for the real-time deployment of large DETR-type models on computationally limited edge platforms, achieving a balance between compression ratio and high detection accuracy. Attached Figure Description

[0016] Figure 1 A schematic diagram illustrating the steps of a DETR model hybrid precision quantization method based on foreground weight modulation provided in an embodiment of the present invention; Figure 2 This is a flowchart illustrating the training process of the target detection model in a DETR model hybrid precision quantization method based on foreground weight modulation, as provided in an embodiment of the present invention. Figure 3This is a schematic diagram of the training process of deformable attention mechanism in a mixed precision quantization method for a DETR model based on foreground weight modulation, provided in an embodiment of the present invention. Figure 4 This is a visualization comparison of multiple models on DOTA images. Detailed Implementation

[0017] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.

[0018] The present invention provides a method for mixing precision quantization of a DETR model based on foreground weight modulation, such as... Figure 1 As shown, it may include the following steps: S1: Preprocess the image to be detected, input the preprocessed image into the pre-trained target detection model, and extract multi-scale image features through the backbone network and neck network.

[0019] Preprocessing of the image to be detected may include: The sliding window method is used to segment the image to be detected according to a preset window size and a preset step size to obtain a preprocessed image.

[0020] To address the problem of large remote sensing image sizes, this invention employs a sliding window method for segmentation to obtain preprocessed images, thereby constructing a remote sensing image sample set of a preset size.

[0021] When using the sliding window method, the preset window size can be 1024×1024, and the preset step size can be 824 pixels.

[0022] This invention uses Deformable DETR as its basic architecture to build an end-to-end target detection model based on Transformer, configures a backbone network (such as ResNet50) and a multi-scale deformable attention mechanism, extracts features from the input remote sensing image, and outputs a multi-scale feature map.

[0023] S2 utilizes a foreground extraction head introduced in the neck network to generate a foreground score map based on multi-scale image features.

[0024] To address the problem that faint targets in remote sensing images are easily confused with the background, this embodiment of the invention integrates a lightweight foreground extraction head for each feature scale in the neck network of the target detection model. The foreground extraction head for each feature scale adopts the same network architecture and shares parameters.

[0025] The process of generating a foreground fraction map based on multi-scale image features may include: The feature maps of each feature scale in the multi-scale image feature are initially reduced in dimensionality by layer normalization and fully connected layers, and then activated by the GELU function to obtain the dimensionality-reduced features. The dimensionality reduction features are divided into local features and global features along the channel dimension. The global features are then combined with the local features after average pooling to obtain the fused features. The fused features are gradually reduced in dimensionality using a fully connected network to obtain a foreground score map.

[0026] The specific structure can be as follows: Obtain a feature map at a certain scale (let the dimensions be B×C×H×W), perform initial dimensionality reduction through layer normalization (LayerNorm) and fully connected layers, and activate it using the GELU function; divide the dimensionality-reduced features into local and global features along the channel dimension, and then concatenate the global features with the local features after average pooling; perform progressive dimensionality reduction through a 3-layer fully connected network, outputting a foreground score map with dimensions of B×N×1×1. The numerical range in this foreground score map is mapped to... , is used to characterize the probability that the corresponding spatial location belongs to the foreground target.

[0027] The specific process of generating the foreground score map is as follows: the foreground extraction head is constructed using a lightweight multilayer perceptron (MLP); during the model training phase, the center of the bounding box of the real target is used as the origin, and a Gaussian decay function is used to convert the discrete bounding box labels into continuous soft labels, and the soft labels are used to supervise the training of the foreground extraction head, thereby extracting the foreground-background spatial prior information adapted to small targets and rotating targets.

[0028] S3 performs hybrid precision quantization on the DETR encoder-decoder in the pre-trained object detection model. During the forward propagation of the decoder, the initial attention weights generated by its cross-attention layer are obtained. Based on the reference point coordinates of the target query, the corresponding foreground score is sampled from the foreground score map. In the decoder, the foreground score is used to multiplicatively modulate the initial attention weights to obtain the modulated enhanced attention weights.

[0029] The expression for the modulated attention enhancement weights is as follows: ; in, This represents the modulated enhanced attention weights. This represents the initial attention weights after quantization. This indicates element-wise multiplication. This represents the hyperparameter controlling the modulation intensity. This indicates the prospect score.

[0030] After completing multiplicative modulation, for A renormalization process is performed to ensure that the sum of attention weights is 1. This mechanism compensates for the weakening of foreground target feature representation by quantization error directly at the operator level without changing the underlying quantization bit width.

[0031] The object detection model is configured with a backbone network, a neck network, and a Transformer module; The backbone network uses ResNet50; the neck network uses Channel Mapper; all convolutional layers in the backbone and neck networks use a lightweight first preset weight and activation precision quantization strategy; the Transformer module includes a multi-scale deformable attention layer and a feedforward network; all linear layers in the Transformer module use a second preset weight and activation hybrid precision quantization strategy.

[0032] The embodiments of this invention employ a hierarchical hybrid precision quantization architecture for model compression: based on the differences in quantization sensitivity of each module of the DETR model, 4-bit weights and 4-bit activation quantization are used for the backbone network and neck network; 4-bit weights and 8-bit activation quantization are used for the Transformer decoder; and the detection head module maintains FP32 precision.

[0033] S4 performs decoder forward propagation based on modulated enhanced attention weights, and outputs the final target detection result through a detection head that maintains floating-point precision.

[0034] To address the issues of large parameter counts in remote sensing models and the tendency of traditional quantization to degrade cross-attention mechanisms and obscure weak target features, this invention integrates a lightweight foreground extraction head into the model neck layer, utilizing Gaussian distributed soft-label supervision to generate a foreground score map. Simultaneously, a hierarchical mixed precision strategy is configured, with the backbone and neck networks employing 4-bit precision, the Transformer using 4-bit weights and 8-bit activation, and the detection head maintaining full FP32 precision. In the cross-attention layer of the Transformer decoder, the initial attention weights are multiplicatively modulated using the foreground score map, dynamically amplifying the target region response to compensate for quantization errors. This invention achieves extremely low bit compression and high-speed inference while minimizing precision loss, providing an efficient solution for lightweight deployment on resource-constrained edge platforms.

[0035] The training process of an object detection model, such as Figure 2 As shown, it may include: S01, the initial remote sensing image samples are segmented using the sliding window method, and a remote sensing image sample set is constructed by converting the annotation format.

[0036] S02, based on the Deformable DETR architecture, performs end-to-end full-precision training on a remote sensing image sample set to obtain a floating-point benchmark model.

[0037] S03 integrates a lightweight extraction branch into the neck of the floating-point benchmark model, and trains it using Gaussian soft labels and a joint loss function to obtain a model with foreground awareness capabilities.

[0038] In the model training phase, to address the problem that traditional 0 / 1 binary hard labels cannot accurately represent the ambiguity of target boundaries, this embodiment of the invention introduces a soft label construction method based on a two-dimensional Gaussian distribution. For each pixel in the image... The Gaussian attenuation score is calculated based on the center of the actual target bounding box. Specifically, this applies to Gaussian soft labels in multi-target overlapping scenarios. Using a pixel-wise maximum value fusion strategy, the expression for the Gaussian soft label is as follows: ; in, Represents pixels The corresponding Gaussian soft tag, N This represents the total number of bounding boxes in the image. Indicates the first i The center coordinates of the target bounding box Indicates the first i The Gaussian standard deviation of the target boxes.

[0039] In an embodiment of the present invention, The value is adaptively determined based on the size of the target bounding box, and its value is related to the width of the target bounding box. wi and height hi It is proportional to the smaller value in the middle. , The hyperparameter for controlling the Gaussian kernel diffusion range is preferably 0.5. Through this step, the target center region obtains a high confidence score close to 1, while the score smoothly decays to 0 when transitioning to the boundary, more realistically reflecting the geometric characteristics of the remotely sensed target.

[0040] The foreground extraction head is trained under supervision using generated continuous Gaussian soft labels. To address the extreme class imbalance between the foreground (small target) and the background (large area), Sigmoid Focal Loss is used as the foreground extraction loss function. , The expression is as follows: ; in, p The foreground probabilities predicted by the model and activated by Sigmoid. y This represents the actual Gaussian soft label value. (Preferred value: 0.25) is used to control the weight balance of positive and negative samples. γ (Option 2) is used to encourage the model to focus on difficult-to-classify samples. During training, the foreground extraction loss and the conventional target detection loss are jointly optimized to complete the end-to-end training of the FP32 format full-precision augmented model, enabling it to simultaneously possess accurate foreground region perception and target localization capabilities.

[0041] S04. Configure quantization strategies for the backbone network, neck network, and Transformer linear layer in the model with foreground awareness. In the model with foreground awareness, introduce a foreground weight modulation operator into the cross-attention layer of the decoder. Use the LSQ algorithm for quantization awareness training to achieve collaborative optimization of quantization step size parameters and foreground modulation parameters, and obtain a pseudo-quantized model.

[0042] This invention employs the LSQ (Learned Step Size Quantization) algorithm to perform quantization-based training on models with foreground perception capabilities. A flowchart illustrating the quantization training process of the deformable attention mechanism in the DETR model's mixed precision quantization method is shown below. Figure 3As shown, during the quantization training of the deformable attention mechanism, firstly, mixed-precision linear mapping is performed to obtain the corresponding full-precision offset layer weight W_off(fp32) for the full-precision query input. This weight is then processed by the 4-bit pseudo-quantization node Quant(LSQ+4bit) based on the LSQ algorithm and compressed into a low-bit quantized weight W_off_q(sim int4). Subsequently, the query features and this quantized weight are fed into the offset linear layer Offset Linear for feature mapping. Truncation and pseudo-quantization are performed by the 8-bit activation quantization node Act Quant(LSQ+8bit), ultimately calculating the 8-bit precision sampling point offset Δp(sim 8bit). Based on the sampling point offset Δp(sim 8bit), the full-precision weight W_atten(fp32) of the attention layer is obtained, and similarly processed by the 4-bit pseudo-quantization node Quant(LSQ+4bit) to generate the quantized attention weight W_atten_q(sim int4). Subsequently, the network utilizes this quantization weight to perform cross-attention forward computation in the Atten Linear+Softmax layer, which includes linear mapping and normalization, outputting the uncompensated initial floating-point attention feature W_value(fp32). To compensate for the attention mechanism degradation and background noise interference caused by low-bit quantization (sim int4 and sim 8bit) in the preceding steps, after obtaining the initial attention feature W_value(fp32), the network introduces a foreground score S_fg(fp32) generated based on Gaussian soft labels as a bypass. To ensure the high fidelity of the compensation signal, this foreground score strictly maintains full precision (FP32) and does not participate in quantization. Subsequently, at the operator level, W_value(fp32) and the foreground score S_fg(fp32) are multiplied element-wise to generate a guided attention feature W_guided(fp32) with foreground awareness capability and corrected quantization error. Next, W_guided(fp32) is transformed into quantized input W_value(simint4) through a 4-bit quantization node Quant(LSQ+4bit). This is then fed into the Value Linear layer for final feature aggregation calculation; its output, after passing through an activated quantization node, generates an 8-bit aggregated feature V_quant(sim 8bit). Finally, the spatial sampling position is determined by combining the sampling point offset Δp generated in the first stage, and this quantized feature is dequantized, ultimately outputting a full-precision deformable cross-attention feature Output(fp32), which is then passed to the next layer of the network.To avoid repetitive descriptions of the quantization process in the specification, all network layers using 4-bit and 8-bit quantization in this embodiment of the invention follow the following unified LSQ quantization rules: For weight tensors Through learnable scaling factors The formulas for normalization, truncation, and rounding are as follows: , ; For activation value tensors A Introducing zero-point offset parameter To accommodate asymmetric distributions, the formula is as follows: ; ; in, and These are the lower and upper bounds of the quantization bit width (4-bit). 8-bit ).

[0043] To address the differences in the sensitivity of different modules in the network to feature representation, this invention proposes the following hybrid precision quantization strategy: Quantification of the backbone and neck networks: In this embodiment of the invention, ResNet50 is used as the backbone network and Channel Mapper is used as the neck network (composed of multiple independent 1×1 1×1 convolutions to uniformly map multi-scale features to 256 dimensions). For all convolutional layers in the backbone network and the neck network, an extremely lightweight 4-bit weight and 4-bit activation precision quantization strategy is adopted.

[0044] DETR encoder-decoder mixed precision quantization: The Transformer module consists of a multi-scale deformable attention layer and a feedforward network. In this embodiment of the invention, to preserve sufficient spatial feature information at extremely low bit depths, a hybrid precision quantization strategy of 4-bit weights and 8-bit activations is used for quantization of all linear layers of the Transformer. Specifically, the forward computation process of the multi-scale deformable attention layer includes four key linear layers, performing the following quantized forward propagation: The query feature is linearly transformed using the quantized offset prediction layer weights (4-bit) to obtain the sampling position offset, which is then added to the reference point coordinates to obtain the final sampling position. P sampleThe importance coefficients of each sampling point are predicted using a quantized weight prediction layer (4-bit), and the initial attention weights are obtained after Softmax normalization. .

[0045] according to P sample In quantized 8-bit multi-scale feature maps V quant Perform bilinear interpolation to extract sampling features. V sampled Finally, attention weights are used to... V sampled The weighted summation is performed, and the output is linearly transformed through the quantized 4-bit output projection layer, followed by 8-bit activation quantization to obtain the final output of the layer.

[0046] This invention introduces an operator-level foreground weight modulation mechanism in the cross-attention layer of the Transformer decoder to compensate for the decrease in feature representation capability caused by quantization. The specific forward implementation process is as follows: For each query in the decoder It corresponds to a reference point. (Normalized coordinates) Multi-scale foreground fraction map output by the foreground extraction head Bilinear interpolation sampling is performed to obtain the foreground scores of each level. The foreground score vector is obtained. Based on the sampled foreground scores, the quantized attention weights are adjusted. Spatial adaptive modulation is performed using the following multiplicative modulation formula for matrix / vector elements: ; in, This represents the modulated enhanced attention weights. This represents the initial attention weights after quantization. This indicates element-wise multiplication. This represents the hyperparameter controlling the modulation intensity. This indicates the prospect score. To guide the intensity hyperparameter (preferably 0.30), this multiplicative modulation enhances the attention weight of the foreground region (when...). The magnification factor is While the background area remains unchanged (when...), (The amplification factor is 1); the modulated weights no longer satisfy the probability distribution constraints and need to be re-normalized. The specific normalization formula is as follows: ; Normalized Enhanced Attention Weights Used for quantized multi-scale sampling features V sampled Perform weighted aggregation to obtain aggregated features. O guided The aggregation calculation formula is as follows: ; Aggregation features O guided Input to include quantization weights The output of the cross-attention layer is projected and then subjected to 8-bit activation quantization to obtain the final output of the cross-attention layer. O final , O final The formula is: .

[0047] After feature processing by the Transformer decoder, the final feature vector is fed into the detection head (including classification and regression branches). Since the number of parameters in the detection head accounts for only about 5% of the total model and is crucial to the accuracy of the final coordinate prediction, the detection head is not quantized, maintaining full-precision FP32 calculation. This design maximizes the overall compression ratio of the model while effectively ensuring the detection accuracy of remote sensing micro-targets, achieving a balance between compression ratio and accuracy.

[0048] This invention employs an end-to-end approach, simultaneously optimizing the DETR model weights, quantization parameters (scaling factor and zero-point offset), and a lightweight foreground extraction head. The expression for the network's joint loss function is as follows: ; in, Denotes the joint loss function. Indicates the target detection loss. This represents the first loss weighting coefficient. This represents the foreground extraction loss (Focal Loss). This represents the second loss weighting coefficient. This represents the quantization regularization term. Preferably, It can be 1.0. It can be 0.01.

[0049] Object detection loss can include: Classification loss Bounding box regression loss and IoU loss .

[0050] The training in this embodiment of the invention uses the AdamW optimizer, with a learning rate set to... (Reduced by half compared to floating-point training to ensure stable learning of quantization parameters), weight decay is... The quantization parameter learning rate is set to 0.1 times the main learning rate to prevent drastic fluctuations in the quantization range. After training for 10 epochs, the model weights are obtained after quantization-aware training. This model is fully adapted to low-bit quantization errors, and the foreground weight modulation mechanism is embedded in the underlying parameters.

[0051] S05 converts the format of the weights in the pseudo-quantization model, extracts the quantization scaling factor, and exports the mixed-precision deployment model.

[0052] In this embodiment of the invention, the pseudo-quantized weights in FP32 format in the trained pseudo-quantized model are formally converted into INT4 integer weights, and the corresponding quantization scaling factors are extracted and saved. Redundant training data (such as optimizer states) are removed, and a compact INT4 / INT8 mixed precision deployment model is exported.

[0053] This compact INT4 / INT8 mixed-precision deployment model is deployed to resource-constrained edge computing devices (such as aerospace platforms or UAV-borne equipment). During the actual inference phase, real-time acquired remote sensing images are input into the deployment model. In the forward propagation matrix operations, the model utilizes hardware-supported low-precision (INT4 / INT8) multiply-accumulate units for efficient computation and dynamically performs inverse quantization operations, outputting the target category and bounding box coordinates in the remote sensing image through a full-precision detection head. This deployment mode compresses the model's storage footprint to approximately one-third of its original size while maintaining the detection accuracy for small targets.

[0054] S06, perform edge-end inference deployment and verification of the mixed-precision deployment model, and determine whether the model performance meets the standards through fixed-point inference calculation: If the performance meets the requirements, the mixed-precision deployment model will be output as the pre-trained object detection model. If the performance does not meet the target, adjust the guidance strength, quantization bit width, or training strategy, return to step S04, and repeat steps S04-S06 until the performance meets the target. Then, output the mixed-precision deployment model as the pre-trained object detection model.

[0055] To fully verify the effectiveness and technical advantages of the proposed method for mixed precision quantization of DETR model based on foreground weight modulation in this invention, corresponding experimental verification and effect evaluation are conducted below.

[0056] Test environment and data preparation: The test hardware platform of this invention employs GPU computing nodes with sufficient video memory (e.g., configured with an RTX4090 and 256GB RAM), and the software environment is built based on a common deep learning framework (e.g., PyTorch) and an object detection library (e.g., mmdetection). The test data uses the publicly available DOTA-v1.0 dataset in the remote sensing field. Considering the large size of remote sensing images, a preset pixel sliding segmentation strategy is adopted (e.g., a 1024×1024 window with 200 pixels of overlap), ultimately constructing a standardized remote sensing image test set containing over 10,000 training sub-images and over 5,000 validation sub-images.

[0057] Evaluation scheme design: To fully demonstrate the performance retention capability of the embodiments of the present invention under extremely low bit compression, the embodiments of the present invention designed the following three progressive test schemes for comparative evaluation: Baseline model group (FP32 full precision): The unquantized Deformable DETR original model is used, with weights and activation values ​​maintaining FP32 floating-point precision, serving as an upper limit reference for detection accuracy.

[0058] Conventional quantization group (INT4 / INT8 mixed precision, no modulation mechanism): Only conventional quantization parameters for remote sensing image optimization are applied to the baseline model. The backbone network and neck network use 4-bit, and the Transformer uses 4-bit weights and 8-bit activation, but the foreground extraction head and cross-attention modulation mechanism of this embodiment are not introduced.

[0059] The embodiment group of this invention (INT4 / INT8 mixed precision + foreground weight modulation): Based on the mixed precision quantization strategy of the above conventional quantization group, the core scheme proposed in the embodiment of this invention is fully implemented, that is, in the cross attention layer of the Transformer decoder, the foreground score obtained by Gaussian soft label training is used to perform operator-level attention weight multiplicative modulation.

[0060] Test result evaluation: The three models described above were subjected to forward inference on the same DOTA-v1.0 validation set to evaluate the overall detection accuracy (mAP) and single-class accuracy. The test evaluation and comparison results of this embodiment are shown in Tables 1, 2, and 3 below.

[0061] Table 1. Overall accuracy metrics of the present invention and the comparative method on the DOTA-v1.0 dataset.

[0062] Table 2 shows the single-class accuracy metrics of the present invention and the comparative method on the DOTA-v1.0 dataset.

[0063] Table 3. Other metrics data of the present invention and the comparison method on the DOTA-v1.0 dataset.

[0064] Analysis of experimental results: As can be seen from the overall accuracy metrics in Table 1, the INT4 / INT8 hybrid precision quantization significantly impacted model performance. The quantized model without foreground weight modulation showed a 7.2 percentage point decrease in accuracy (AP) compared to the FP32 baseline, representing a 12.5% ​​accuracy loss. This degradation was consistent across different IoU thresholds. In terms of target detection performance at different scales, small targets were most affected by quantization, with an accuracy loss of 4.9 percentage points. This reflects the sparse features and small pixel footprint of small remote sensing targets, making them more sensitive to information loss due to 4-bit discretization during quantization. The foreground weight modulation quantization method proposed in this embodiment significantly improved quantization accuracy loss while maintaining almost the same model size and compression ratio, resulting in a 4.8 percentage point improvement in AP. 50 An increase of 3.8 percentage points, AP 75 The 5.3 percentage point improvement indicates that the foreground weight modulation mechanism not only enhances target recognition capabilities but also effectively improves bounding box localization accuracy. The relatively higher improvement rate for small targets verifies that the foreground weight modulation mechanism can effectively compensate for the impact of quantization errors on feature-sparse targets in multi-scale deformable attention layers.

[0065] Table 2 shows the difference in detection accuracy across categories, highlighting the varying impacts of INT4 / INT8 hybrid precision quantization on different categories. The foreground weight modulation quantization method of this invention improved accuracy in all 15 categories, with the improvement magnitude closely related to category characteristics. The most significant improvements were observed in the following categories: football field (+6.9%), large vehicles (+4.2%), port (+4.9%), basketball court (+3.2%), and roundabout (+3.2%). For the football field, a large-scale, regular target, the foreground weight modulation mechanism provides spatial priors on multi-scale feature maps, enabling the Transformer decoder's attention to more accurately locate the target boundary, effectively compensating for feature degradation and blurring after quantization. For targets like large vehicles and ports, the foreground score map enhances the saliency of the target region relative to complex backgrounds (such as roads and sea surfaces), allowing the quantized model to maintain high foreground and background discrimination capabilities. Improvements were also seen for smaller targets such as small vehicles (+1.1%) and swimming pools (+1.3%), fully validating the foreground weight modulation mechanism's accuracy compensation capability for small-scale, high-contrast targets.

[0066] As can be seen from the comparison of resource consumption and inference efficiency in Table 3, INT4 / INT8 hybrid precision quantization achieves significant storage compression and computational acceleration while maintaining a relatively constant number of model parameters. Compared to the FP32 baseline, the file size of the quantized model is compressed from 472MB to 157MB, a compression ratio of 3.00×, saving 66.7% of storage space, making the model more suitable for edge device deployment. The computational load (FLOPs) is reduced from 156.8G to 39.2G, a reduction of 75.0%, mainly due to the fact that 70% of the network layers use INT4 operations to replace FP32 floating-point operations. Although the actual number of operations is not significantly reduced, the low power consumption of integer operations greatly improves the inference energy efficiency ratio. The inference speed is increased from 3.8 FPS to 5.7 FPS, a speedup of 1.5×, verifying the inference acceleration effect of quantization in real-world deployment scenarios.

[0067] Visual comparison of multiple models on DOTA images, such as Figure 4 As shown in the figure, this comparison illustrates the detection results of three models in complex remote sensing scenarios. The comparison clearly shows that direct low-bit quantization... Figure 4 The second column in the table can lead to feature overload and cross-attention divergence, resulting in severe missed detections of weak targets. Figure 4 The first and second rows of the text) and the fragmented overlapping anomaly boxes of slender targets ( Figure 4 The third line in the text). In contrast, the foreground modulation model provided in the embodiments of the present invention ( Figure 4 The third column in the model effectively corrects these quantization biases: by injecting full-precision (FP32) foreground fractions to perform multiplicative modulation, it not only amplifies the response of weak targets and accurately recalls missed targets, but also successfully suppresses background noise, forcibly guides attention to refocus, and completely eliminates overlapping false detections, making the performance of the quantization model highly close to the full-precision baseline.

[0068] The DETR model hybrid precision quantization method based on foreground weight modulation provided in this invention significantly overcomes the attention degradation problem of existing quantization techniques when processing remote sensing images, and has the following advantages: Achieve operator-level foreground feature compensation: Existing quantization training focuses only on global numerical compression. This invention innovatively introduces a "multiplicative modulation" mechanism at the underlying level of cross-attention computation in the Transformer decoder. By directly intervening in the distribution of attention weights after quantization through the foreground score map, it effectively compensates for the damage to key feature representation caused by quantization errors at the operator level without changing the quantization bit width.

[0069] Enhance the ability to detect low-precision targets in complex backgrounds: To address the challenge of sparse target features in remote sensing images, which are easily obscured by the background, this invention utilizes the synergistic effect of multi-scale features and foreground modulation to adaptively enhance the attention response of the target region. Even at low bit depths, the model can still accurately focus on small and rotating targets, significantly reducing false negatives and false positives caused by background interference.

[0070] Achieving a balance between compression ratio and high detection accuracy: This invention combines the sensitivity of each module of the model to quantization and adopts a hierarchical hybrid precision quantization strategy. While maintaining hardware computing architecture friendliness, it achieves approximately 3 times model storage compression and 1.5 times inference acceleration, and controls the accuracy loss of target detection to within 2%. It provides an effective solution for the real-time deployment of large DETR-type models on computing-constrained edge platforms.

[0071] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0072] 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 method for mixed-precision quantization of a DETR model based on foreground weight modulation, characterized in that, include: The image to be detected is preprocessed, and the preprocessed image is input into the pre-trained target detection model. Multi-scale image features are extracted through the backbone network and the neck network. A foreground score map is generated based on multi-scale image features using a foreground extraction head introduced in the neck network; Hybrid precision quantization is performed on the DETR encoder-decoder in the pre-trained object detection model. During the forward propagation of the decoder, the initial attention weights generated by its cross-attention layer are obtained. Based on the reference point coordinates of the target query, the corresponding foreground score is sampled from the foreground score map. In the decoder, the foreground score is used to multiplicatively modulate the initial attention weights to obtain the modulated enhanced attention weights. The decoder forward propagation is performed based on the modulated enhanced attention weights, and the final target detection result is output through the detection head that maintains floating-point precision. The target detection model is configured with a backbone network, a neck network, and a Transformer module. The backbone network uses ResNet50; the neck network uses Channel Mapper; all convolutional layers in the backbone and neck networks use a lightweight first preset weight and activation precision quantization strategy; the Transformer module includes a multi-scale deformable attention layer and a feedforward network; all linear layers in the Transformer module use a second preset weight and activation hybrid precision quantization strategy.

2. The method for hybrid precision quantization of a DETR model based on foreground weight modulation according to claim 1, characterized in that, The preprocessing of the image to be detected includes: The sliding window method is used to segment the image to be detected according to a preset window size and a preset step size to obtain a preprocessed image.

3. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 1, characterized in that, The training process of the target detection model includes: S01, the initial remote sensing image samples are segmented using the sliding window method, and a remote sensing image sample set is constructed by converting the annotation format; S02, based on the Deformable DETR architecture, performs end-to-end full-precision training on a remote sensing image sample set to obtain a floating-point benchmark model; S03 integrates a lightweight extraction branch into the neck of the floating-point benchmark model, and trains it using Gaussian soft labels and a joint loss function to obtain a model with foreground awareness. S04. Configure quantization strategies for the backbone network, neck network, and Transformer linear layer in the model with foreground awareness. In the model with foreground awareness, introduce a foreground weight modulation operator into the cross-attention layer of the decoder. Use the LSQ algorithm for quantization awareness training to achieve collaborative optimization of quantization step size parameters and foreground modulation parameters, and obtain a pseudo-quantized model. S05, convert the format of the weights of the pseudo-quantization model, extract the quantization scaling factor, and export the mixed precision deployment model; S06, perform edge-end inference deployment and verification of the mixed-precision deployment model, and determine whether the model performance meets the standards through fixed-point inference calculation: If the performance meets the requirements, the mixed-precision deployment model will be output as the pre-trained object detection model. If the performance does not meet the target, adjust the guidance strength, quantization bit width, or training strategy, return to step S04, and repeat steps S04-S06 until the performance meets the target. Then, output the mixed-precision deployment model as the pre-trained object detection model.

4. The method for hybrid precision quantization of a DETR model based on foreground weight modulation according to claim 1, characterized in that, In the neck network, a lightweight foreground extraction head is integrated for each feature scale, and the foreground extraction head for each feature scale adopts the same network architecture and shares parameters.

5. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 1, characterized in that, The process of generating a foreground fraction map based on multi-scale image features includes: The feature maps of each feature scale in the multi-scale image feature are initially reduced in dimensionality by layer normalization and fully connected layers, and then activated by the GELU function to obtain the dimensionality-reduced features. The dimensionality reduction features are divided into local features and global features along the channel dimension. The global features are then combined with the local features after average pooling to obtain the fused features. The fused features are gradually reduced in dimensionality using a fully connected network to obtain a foreground score map.

6. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 1, characterized in that, The expression for the modulated enhanced attention weights is as follows: ; in, This represents the modulated enhanced attention weights. This represents the initial attention weights after quantization. This indicates element-wise multiplication. This represents the hyperparameter controlling the modulation intensity. This indicates the prospect score.

7. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 3, characterized in that, The expression for the Gaussian soft tag is as follows: ; in, Represents pixels The corresponding Gaussian soft tag, N This represents the total number of bounding boxes in the image. Indicates the first i The center coordinates of the target bounding box Indicates the first i The Gaussian standard deviation of the target boxes.

8. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 3, characterized in that, The expression for the joint loss function is as follows: ; in, Denotes the joint loss function. Indicates the target detection loss. This represents the first loss weighting coefficient. Indicates the foreground extraction loss. This represents the second loss weighting coefficient. This indicates the quantization regularization term.

9. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 8, characterized in that, The target detection loss includes: Classification loss Bounding box regression loss and IoU loss .

10. The method for quantizing the mixed precision of a DETR model based on foreground weight modulation according to claim 1, characterized in that, The first preset weight and activation precision quantization strategy is a 4-bit weight and 4-bit activation precision quantization strategy; the second preset weight and activation hybrid precision quantization strategy is a 4-bit weight and 8-bit activation hybrid precision quantization strategy.

Citation Information

Patent Citations

  • Aerial photography target detection method based on dynamic attention and double-frequency feature enhancement

    CN121415288A

  • Method for detecting small targets in remote sensing image based on RSTR model

    CN121725368A