Environment change oriented target detection adaptive hybrid precision quantization method

By using an adaptive hybrid precision quantization method, the quantization grid configuration is dynamically adjusted using a bit controller and environmental feature vectors. This solves the problems of detection accuracy and computational power consumption of edge target detection models under environmental changes, and achieves more efficient real-time target detection.

CN123160997APending Publication Date: 2026-11-24BEIJING JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611362490.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-03
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing edge target detection models struggle to balance detection accuracy and computational power consumption when the environment changes, especially in video stream inference scenarios where real-time processing frame rates are low and overall computational power consumption is high.

Method used

An adaptive hybrid precision quantization method for target detection is adopted to adapt to environmental changes. The quantization grid configuration is generated by a bit controller and dynamically adjusted in combination with environmental feature vectors. The quantization grid configuration is updated only when the environment changes abruptly or gradually over a long period of time, thereby reducing redundant calculations.

Benefits of technology

The training process has been optimized, improving the model's detection accuracy and real-time performance under changing environments, reducing the computing power consumption of edge devices, and demonstrating strong adaptability. It can balance inference computation overhead and detection performance under different lighting conditions and target distribution scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160997A_ABST
    Figure CN123160997A_ABST
Patent Text Reader

Abstract

This invention discloses an adaptive hybrid precision quantization method for target detection accommodating environmental changes. Offline, the quantization sensitivity of the network is calculated layer by layer, and a weighted loss function is constructed to train the bit controller. Training prioritizes protecting highly sensitive detection layers, accelerating convergence and improving detection accuracy. The device initializes a gradual frame count. The first frame generates a quantization grid through the bit controller. Inference is completed through layer-by-layer quantization, integer operations, and dequantization. Illumination, target quantity and size, and background complexity are stitched together to generate a baseline environmental feature vector. Subsequent frames extract feature vectors, and cosine similarity is used to calculate the difference. A dual threshold is used to distinguish between slightly stable, continuously changing, and abruptly changing environmental scenarios. If the gradual frame count has not reached the threshold, the quantization grid is reused. When a sudden change occurs or the cumulative gradual frame count reaches the threshold, a new quantization grid is generated and the baseline vector is updated. This invention eliminates redundant calculations in frame-by-frame adjustment, balancing quantization compression, detection accuracy, and real-time inference efficiency for edge devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of neural network quantization and edge target detection technology, specifically relating to an adaptive hybrid precision quantization method for target detection oriented towards environmental changes. Background Technology

[0002] When deploying target detection models on edge devices such as robots and surveillance equipment, mixed-precision quantization is commonly used to reduce floating-point computation overhead. Currently, mainstream dynamic quantization schemes rely on bit controllers to dynamically allocate quantization bit widths for each layer of the image. However, this approach has significant shortcomings in practical implementation: firstly, the model training phase has slow convergence speed, and target detection accuracy is prone to significant decrease after quantization; secondly, in video stream inference scenarios, the overall computational cost is high, and the real-time processing frame rate is relatively low. Existing quantization strategies do not fully integrate real-time environmental conditions such as image lighting, target distribution, and background to dynamically adjust quantization configurations. This makes it difficult to simultaneously balance model detection accuracy and edge device computational overhead in different scenarios with continuous gradual or abrupt environmental changes, resulting in poor adaptability. Summary of the Invention

[0003] This invention provides an adaptive hybrid precision quantization method for target detection oriented towards environmental changes, comprising: performing initial processing, initializing the gradual cumulative frame number variable to zero, and generating a quantization grid configuration based on a first frame image using a pre-trained bit controller; performing quantization and dequantization operations layer by layer on the first frame image according to the quantization grid configuration to complete target detection inference, and extracting a reference environmental feature vector from the first frame image; acquiring the next frame image, extracting the current frame environmental feature vector, comparing the current frame environmental feature vector with the reference environmental feature vector, and performing an environmental change determination; confirming that the determination result is to maintain the existing quantization grid configuration, performing quantization and dequantization operations layer by layer on the current frame image using the current quantization grid configuration to complete target detection inference; or confirming that the determination result is to update the quantization grid configuration, re-calling the bit controller to generate a new quantization grid configuration, and updating the reference environmental feature vector to the current frame environmental feature vector.

[0004] According to one embodiment of the present invention, the method further includes: performing a pre-training step on the bit controller, which further includes: calculating the quantization sensitivity of each network layer of the target detection network layer by layer, constructing a weighted loss function based on the quantization sensitivity; using the weighted loss function to complete the training of the bit controller, and storing the trained bit controller in a device.

[0005] According to one embodiment of the present invention, the bit controller, which has been pre-trained, generates a quantization grid configuration based on a first frame image, comprising: inputting the first frame image into the pre-trained bit controller; the bit controller outputting quantization bit parameters allocated to each network layer according to the quantization sensitivity of each network layer of the target detection network; calculating the upper and lower quantization limit intervals of the corresponding layer by combining the quantization bit parameters of each network layer; and integrating the quantization bit parameters and quantization upper and lower limit intervals of all network layers to generate the quantization grid configuration.

[0006] According to one embodiment of the present invention, the step of performing quantization operations on the first frame image layer by layer according to the quantization grid configuration includes: reading the quantization bit parameters allocated to each layer of the target detection network in the quantization grid configuration, determining the upper and lower quantization limit intervals corresponding to each layer; obtaining the floating-point image data input to the current network layer, and mapping the floating-point data to integer discrete quantization values ​​in combination with the upper and lower quantization limit intervals of the corresponding layer.

[0007] According to one embodiment of the present invention, the step of performing dequantization operation on the first frame image layer by layer according to the quantization grid configuration includes: reading the quantization bit parameters and quantization upper and lower limit intervals of the corresponding network layer in the quantization grid configuration; obtaining the integer discrete quantization value obtained by quantization of the current layer; and obtaining approximate floating-point data by reverse mapping the quantization upper and lower limit intervals of the current layer.

[0008] According to one embodiment of the present invention, the completion of target detection inference includes: performing quantization operation, network integer feature operation, and dequantization operation layer by layer and passing feature data layer by layer; wherein, the network integer feature operation takes the integer discrete quantization value output by the quantization operation as input, performs convolution operation, pooling operation, or fully connected operation to generate the integer feature result of the current layer; and parses the feature data finally output after layer-by-layer operation to obtain the category, coordinates, and confidence of the target in the image.

[0009] According to one embodiment of the present invention, the extraction of the reference environmental feature vector of the first frame image and the extraction of the environmental feature vector of the current frame include: performing global pixel statistics on the image to be processed to obtain the overall average brightness, global contrast, and average values ​​of each color channel; performing target detection, filtering valid targets with confidence scores higher than a preset confidence threshold, counting the number of valid targets, the size of each valid target, and evaluating the image background complexity; combining and concatenating the average brightness, the global contrast, the average values ​​of each color channel, the number of valid targets, the size of each valid target, and the image background complexity to generate the environmental feature vector of the corresponding frame; and storing the generated environmental feature vector as the reference environmental feature vector for the first frame image.

[0010] According to one embodiment of the present invention, comparing the current frame environment feature vector with the reference environment feature vector to perform environment change determination includes: calculating the cosine similarity between the current frame environment feature vector and the reference environment feature vector, and converting the cosine similarity to obtain a feature difference degree; comparing the feature difference degree with a first threshold and a second threshold respectively, wherein the first threshold is less than the second threshold; determining that the feature difference degree is less than the first threshold, and determining that the environment is in a slightly stable stage; determining that the feature difference degree is greater than or equal to the first threshold and less than the second threshold, and determining that the environment is in a continuous gradual change stage; determining that the feature difference degree is greater than or equal to the second threshold, and determining that the environment is in an environment sudden change stage.

[0011] According to one embodiment of the present invention, the confirmation determination result of maintaining the existing quantitative grid configuration includes: confirming that the environment is in a slightly stable stage, or confirming that the environment is in a continuous gradual change stage and the cumulative number of gradual change frames is less than a preset frame number threshold, and determining to maintain the existing quantitative grid configuration; after completing the target detection inference of the current frame, performing an increment operation on the cumulative number of gradual change frames.

[0012] According to one embodiment of the present invention, the confirmation determination result of updating the quantization grid configuration includes: confirming that the environment is in an environment change phase, or confirming that the environment is in a continuous gradual change phase and the cumulative number of gradual change frames reaches a preset frame number threshold, and determining to update the quantization grid configuration; after generating a new quantization grid configuration, replacing the reference environment feature vector with the current frame environment feature vector, and clearing the cumulative number of gradual change frames to zero.

[0013] This solution optimizes the overall training process of the bit controller by constructing corresponding weighted loss functions based on the quantization sensitivity of each network layer to participate in model training. This significantly improves the convergence speed during training and protects key network layers that affect detection accuracy. The model achieves better target detection results at the same compression ratio (same degree of compression). This solution reduces redundant computation during the inference phase by using multi-dimensional environmental feature vectors of the image combined with two-level thresholds to determine environmental changes. Quantization grid configurations are only regenerated in scenarios with abrupt changes or long-term gradual environmental shifts, eliminating the need to activate the bit controller for every frame. This reduces computational consumption on edge devices and improves the real-time performance of continuous video image processing. This solution has stronger adaptability to various environmental scenarios. It collects image brightness, contrast, color information, target-related parameters, and background information to construct environmental features. Different environmental states are distinguished and quantization configurations are adjusted based on the degree of feature change. This solution can balance inference computation overhead and target detection output performance under various lighting conditions and target distribution scenarios. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0015] Figure 1 This is a flowchart of an adaptive hybrid precision quantization method for target detection in response to environmental changes.

[0016] Figure 2 This is a flowchart of offline training for the bit controller.

[0017] Figure 3 This is a flowchart of a bit controller that generates a quantization grid configuration based on the first frame image through pre-training.

[0018] Figure 4 It is a flowchart of performing quantization operations layer by layer on the first frame image based on the quantization grid configuration.

[0019] Figure 5 It is a flowchart of performing dequantization operations layer by layer on the first frame image based on the quantization grid configuration.

[0020] Figure 6 This is a flowchart for completing the object detection inference.

[0021] Figure 7 This is a flowchart for extracting the baseline environmental feature vector of the first frame image and the environmental feature vector of the current frame.

[0022] Figure 8 It is a flowchart that compares the current frame's environmental feature vector with the baseline environmental feature vector to determine environmental changes.

[0023] Figure 9 This is a flowchart confirming that the determination result is to maintain the existing mass-produced grid configuration.

[0024] Figure 10 This is a flowchart confirming the judgment result as an update to the quantization grid configuration.

[0025] Figure 11 This is a schematic diagram of the hierarchical adaptive bit width allocation architecture of the bit controller of the present invention.

[0026] Figure 12 This is a schematic diagram of the two-stage architecture of the overall technical solution of the present invention.

[0027] Figure 13 This is a schematic diagram of the baseline quantization model generation process in the offline initialization stage of this invention.

[0028] Figure 14 This is a schematic diagram of the layer-by-layer perturbation calculation process for the quantization sensitivity assessment of layer-by-layer perturbation quantization sensitivity loss according to the present invention.

[0029] Figure 15 This is a schematic diagram of the complete process of dual-threshold adaptive quantization inference during the deployment phase of this invention.

[0030] Figure 16 This is a comparison curve of the training loss convergence between the present invention with and without ODOL loss. Figure 17 This is the second curve comparing the convergence of training loss with and without the ODOL loss introduced in this invention. In the legend, w / ODOL represents the introduction of layer-by-layer perturbation quantization sensitivity loss, and w / o ODOL represents the absence of this loss constraint. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0032] To facilitate a clear understanding of the technical solutions corresponding to the technical steps and figures below, the main technical terms in the text will be explained first.

[0033] Quantization is the process of converting floating-point weights and activation values ​​in a neural network model into low-bit-width integer representations to reduce model storage and hardware computation overhead.

[0034] Hybrid precision quantization: This refers to assigning independent quantization bit widths to different convolutional and fully connected layers of the network, so as to balance model compression rate and target detection accuracy through differentiated bit width settings.

[0035] Compression ratio: This represents the ratio of the computational and storage volume of the quantized model to that of the original floating-point model. The smaller the value, the higher the degree of model compression. This solution can guarantee detection accuracy under the same compression ratio (degree of compression).

[0036] Calibration set: A representative set of unlabeled image samples, mainly used to statistically analyze the activation value range of each layer of the network and to solve for the scaling factor and zero-point parameters required for quantization.

[0037] Validation set: This is a labeled image dataset, mainly used for calculating the quantization sensitivity of each network layer and evaluating the accuracy of the quantized model.

[0038] Straight-Through Estimator (STE): This is a gradient approximation method used to solve the problem of non-differentiability of quantization operations. During backpropagation, the gradient of the quantization operation is approximated as 1, ensuring that the network can be trained iteratively normally.

[0039] Overall Disturbance Oriented Loss (ODOL): Using the output of the baseline high-bit-width model as a reference, the quantization bit width of a single layer is perturbed layer by layer. The sensitivity of each network layer is calculated based on the deviation of the detection output before and after the perturbation. An auxiliary training loss function is constructed based on the sensitivity weighting and used to constrain the allocation of quantization bit width of each layer during bit controller training.

[0040] The following is combined with Figures 1 to 10 This invention describes an adaptive hybrid precision quantization method for target detection in response to environmental changes.

[0041] Figure 1 This is a flowchart of the adaptive hybrid precision quantization method for target detection oriented towards environmental changes provided by the present invention, such as... Figure 1 As shown, the method includes the following: In step S100, initial processing is performed, the gradual cumulative frame number variable is initialized to zero, and the quantization grid configuration is generated based on the first frame image by the pre-trained bit controller; In step S200, the first frame image is quantized and dequantized layer by layer according to the quantization grid configuration to complete the target detection inference and extract the reference environment feature vector of the first frame image. In step S300, the next frame image is acquired, the current frame environment feature vector is extracted, the current frame environment feature vector is compared with the reference environment feature vector, and an environment change determination is performed. In step S400, the determination result is confirmed to maintain the existing quantized grid configuration. The current quantized grid configuration is used to perform quantization and dequantization operations on the current frame image layer by layer to complete the target detection inference. In step S500, if the determination result is confirmed to be an update of the quantization grid configuration, the bit controller is called again to generate a new quantization grid configuration and the reference environment feature vector is updated to the current frame environment feature vector.

[0042] Specifically, before executing step S100, the device has completed offline training and storage of the bit controller. During the offline phase, the quantization sensitivity of each network layer of the target detection network is calculated layer by layer. A weighted loss function is constructed based on the quantization sensitivity. After training the bit controller using the weighted loss function, it is stored locally on the device. The initial processing corresponding to step S100 is not limited to the device power-on startup scenario. It can also be triggered when the model is reloaded, the monitoring screen scene is switched, or the quantization parameters are manually reset, etc., when the initial quantization grid configuration needs to be regenerated. When the initial processing is triggered, the gradual cumulative frame count variable is first initialized to zero. The pre-trained bit controller stored locally is read, and the first frame image acquired is input into the bit controller. The bit controller outputs the quantization bit parameters allocated to each network layer according to the quantization sensitivity of each network layer of the target detection network. The quantization upper and lower limit intervals of the corresponding layer are calculated by combining the quantization bit parameters of each network layer. The quantization bit parameters and quantization upper and lower limit intervals of all network layers are integrated to generate a quantization grid configuration adapted to the first frame image.

[0043] Step S200 uses the quantization grid configuration output in step S100 as the basis for calculation, reads the quantization bit parameters allocated to each layer of the target detection network in the quantization grid configuration layer by layer, and determines the quantization upper and lower limit intervals corresponding to each layer; obtains the floating-point image data input to the current network layer, and maps the floating-point data to integer discrete quantization values ​​in combination with the quantization upper and lower limit intervals of the corresponding layer, completing the layer-by-layer quantization operation; after the network layer completes the convolution operation, pooling operation, or fully connected operation to generate the integer feature result of the current layer, reads the quantization bit parameters and quantization upper and lower limit intervals of the corresponding network layer in the quantization grid configuration, obtains the integer discrete quantization value obtained by quantization of the current layer, and obtains the approximate floating-point data by reverse mapping in combination with the quantization upper and lower limit intervals of the current layer, completing the layer-by-layer dequantization operation; after completing the quantization operation, network layer feature calculation, and dequantization operation layer by layer and passing the feature data layer by layer, the feature data output by the last layer is parsed to obtain the category, coordinates, and confidence of the target in the image, and the target detection inference is completed. Simultaneously, an environment feature vector extraction operation is performed on the first frame of the image to be processed. Global pixel statistics are performed on the image to be processed to obtain the overall average brightness, global contrast, and average values ​​of each color channel. Based on the object detection inference results, target filtering is performed to select valid targets with confidence scores higher than a preset confidence threshold. The number of valid targets, the size of each valid target, and the image background complexity are counted. The average brightness, global contrast, average values ​​of each color channel, number of valid targets, size of each valid target, and image background complexity are combined and concatenated to generate the environment feature vector of the corresponding frame, and this environment feature vector is stored as the baseline environment feature vector.

[0044] Step S300 involves continuously acquiring video stream images as subsequent images, using the same extraction logic as the first frame image to generate the current frame's environmental feature vector, retrieving the reference environmental feature vector stored in the device, calculating the cosine similarity between the current frame's environmental feature vector and the reference environmental feature vector, and converting the cosine similarity to obtain the feature difference. The feature difference is then compared with a first threshold and a second threshold, where the first threshold is less than the second threshold. If the feature difference is less than the first threshold, the environment is determined to be in a slightly stable stage; if the feature difference is greater than or equal to the first threshold and less than the second threshold, the environment is determined to be in a continuous gradual change stage; if the feature difference is greater than or equal to the second threshold, the environment is determined to be in a sudden change stage, thus completing the environmental change determination.

[0045] Step S400 corresponds to the decision branch of maintaining the existing quantized grid configuration. When the decision environment is in a slightly stable stage, or when the decision environment is in a continuous gradual change stage and the cumulative number of gradual change frames is less than the preset frame number threshold, it is determined to maintain the existing quantized grid configuration. The current quantized grid configuration is used to perform quantization and dequantization operations layer by layer on the current frame image. After the target detection inference of the current frame is completed, the cumulative number of gradual change frames is incremented by one, and then the process jumps to step S300.

[0046] Step S500 corresponds to the decision branch for updating the quantization grid configuration. When the environment is in a sudden change phase or the environment is in a continuous gradual change phase and the cumulative number of gradual change frames reaches a preset frame threshold, the decision is made to update the quantization grid configuration. The current frame image is input into the pre-trained bit controller, the bit controller is called again to generate a new quantization grid configuration, the reference environment feature vector stored in the device is replaced with the current frame environment feature vector, and the cumulative number of gradual change frames is cleared to zero. Then, the process jumps to step S300.

[0047] The entire process does not require repeatedly calling the bit controller to generate quantization grid configuration for each frame of image. The quantization grid configuration is only updated in the event of sudden environmental changes or long-term continuous gradual changes, which greatly reduces the amount of redundant computation in the inference stage. At the same time, it accurately perceives changes in the scene environment based on multi-dimensional environmental feature vectors. With the bit controller optimized and trained by quantization sensitivity weighted loss, it can simultaneously balance the computing power of edge devices and the target detection output effect in various lighting and target distribution scenarios.

[0048] Figure 2 This is a flowchart of the offline training process for the bit controller. Figure 12 A schematic diagram of the overall two-stage architecture. (See diagram below.) Figure 2 As shown, according to an embodiment of the present invention, the method further includes: performing a pre-training step on the bit controller, which further includes: In step SP001, the quantization sensitivity of each network layer of the target detection network is calculated layer by layer, and a weighted loss function is constructed based on the quantization sensitivity; In step SP002, a weighted loss function is used to train the bit controller, and the trained bit controller is stored in the device.

[0049] Specifically, the offline training operation is a typical implementation of bit controller pre-training. After the offline process is started, the construction of the benchmark quantization model is completed first. The operator calls the pre-trained target detection model and performs post-training quantization operation with the calibration set data to obtain a benchmark quantization model with a unified high bit width configuration. This model serves as a unified reference standard for subsequent quantization sensitivity calculation.

[0050] For the complete generation process of the benchmark quantization model, please refer to Figure 13 .

[0051] After the baseline model preparation is completed, the computation step corresponding to step SP001 is entered. Quantization perturbation processing is carried out on each layer inside the target detection network in sequence. Each operation only adjusts a single layer to the low bit width candidate configuration, while the other network layers keep the baseline quantization bit width unchanged. Validation set sample data is input into the model that has completed the perturbation adjustment, and the target detection loss caused by the perturbation operation is calculated.

[0052] The process of calculating the layer-by-layer perturbation of the quantization sensitivity of each network layer can be found in [reference needed]. Figure 14 .

[0053] The detection loss is recorded as The corresponding operation expression is as follows: ; In the formula, This represents the total number of samples contained in the validation set; for the One sample, This represents the number of detection boxes generated within the sample; The function takes two sets of classification probability distributions as input, and the two distributions are respectively represented by the sign... and express; The function takes two sets of detection box coordinates and dimensions as input, and the two sets of data are respectively represented by symbols. and Representation; Letters This is an adjustable hyperparameter used to balance the proportion of classification loss and localization loss. It iterates through all candidate quantization bit widths of a single-layer network, and calculates the average of the detection loss obtained from multiple calculations. The corresponding expression is as follows: ; In the formula, Indicates the network layer currently participating in the computation. This represents the total number of candidate quantization bits available in a single network layer. This average value reflects the impact of low-bit quantization on detection accuracy in the corresponding network layer; a larger value indicates higher quantization sensitivity for that layer. After calculating the average detection loss for all network layers, a linear normalization operation is performed. The corresponding expression is as follows: ; In the formula, Indicates the first i The dimensionless values ​​obtained after normalization of the layer network, with the following symbols. Indicates the first The average detection loss corresponding to the layer network, This represents the minimum value among all network layers' average detection loss. This represents the maximum value in the average detection loss of all network layers. This operation maps the average detection loss of each layer to a value range of 0 to 1, which facilitates subsequent weight mapping calculations.

[0054] The normalized result is then mapped using a negative exponential method to obtain the sensitivity weights for each network layer. The corresponding calculation expression is as follows: ; In the formula, , , All are adjustable hyperparameters. After mapping, network layers with higher quantization sensitivity receive smaller weights, and network layers with lower quantization sensitivity receive larger weights. The weighted loss function used for bit controller training is constructed by combining the sensitivity weights of all network layers. The corresponding expression is as follows: ; In the formula, This represents the total weighted loss used during the bit controller training process. This represents the basic loss term corresponding to the object detection task. This is an adjustable hyperparameter used to adjust the weight of bit-width overhead loss within the total loss. The summation operation within the expression iterates through all network layers, with the upper bound of the summation set to letters. The summation variable represents the total number of network layers in the object detection network. Corresponding to a single-layer network number, Representative assigned to the first The expression represents the bit operation overhead caused by the quantization bit width of the network layers. It adds the task detection loss to the layer-weighted bit width overhead loss to obtain the total loss. During training, this total loss is used as the optimization objective, automatically assigning appropriate quantization bit widths to network layers with different sensitivities. Before training with the weighted loss function, the original pre-trained object detection model is first quantized using a calibration set to generate a baseline quantized model with a uniform high bit width configuration as the sensitivity calculation benchmark. The quantization perturbation rule is to reduce the bit width of only a single candidate layer at a time, while maintaining the baseline high bit width for all other network layers. The average detection loss is calculated by traversing all candidate bit widths. As a quantification of sensitivity, the average loss of all levels is linearly normalized to the 0-1 interval, and then mapped using negative exponential mapping. Sensitivity weights are generated for each layer, with smaller weights corresponding to higher-sensitivity networks. During training, the bit width penalty for high-sensitivity layers is automatically reduced. A comparison of training convergence performance using ODOL loss can be found in [link to documentation]. Figure 16 , Figure 17 After all calculations in step SP001 are completed, the processing flow corresponding to step SP002 begins. The constructed weighted loss function is used as the training constraint for the bit controller. During the training phase, Gumbel-Softmax combined with a straight-through estimator (STE) is used to handle the non-differentiability problem caused by the discrete bit width selection, approximating the gradient of the quantization operation to ensure normal iterative training of the network. The internal parameters of the bit controller are continuously updated iteratively until the training loss stabilizes and the detection metric on the validation set no longer improves, at which point training stops. After training, the complete parameters of the bit controller are stored locally on the device, which can be directly read and used during subsequent online inference processes without repeating the entire offline training process. This offline training process utilizes quantization sensitivity to construct a weighted loss for training, which can accelerate training convergence compared to existing schemes using equal constraint losses. Under the same quantization compression conditions, it can maintain better target detection accuracy, providing an optimized bit controller for generating quantization grid configurations adapted to image content during the online phase of the device. The bit controller after training convergence possesses… Figure 11 The layered adaptive bit-width output capability is shown.

[0055] Figure 3 This is a flowchart illustrating how a pre-trained bit controller generates a quantization grid configuration based on the first frame of the image. (Example:) Figure 3 As shown, according to an embodiment of the present invention, a pre-trained bit controller generates a quantization grid configuration based on a first frame image, including: In step S110, the first frame image is input into the pre-trained bit controller; In step S120, the bit controller outputs the quantization bit parameters allocated to each network layer based on the quantization sensitivity of each network layer of the target detection network. In step S130, the quantization upper and lower limit intervals of the corresponding layer are calculated by combining the quantization bit parameters of each network layer, and the quantization bit parameters and quantization upper and lower limit intervals of all network layers are integrated to generate the quantization grid configuration.

[0056] Specifically, the bit controller, trained and stored offline, can be directly invoked and executed during online inference. After the device acquires the first frame image, it enters the operation process corresponding to step S110, directly sending the complete image data to the pre-trained bit controller stored locally. The original pixel data of the image enters the feature extraction module built into the bit controller to complete the basic feature extraction work. The extracted image features are used as the input basis for the bit controller's output bit width allocation strategy. In this scheme, the bit controller adopts a lightweight dual-module structure. The first is a shared feature extraction module, which directly reuses the shallow weights of the target detection backbone without adding additional network parameters. The second is a multilayer perceptron module composed of two fully connected layers, which can output the selection probability of each candidate quantization bit in each layer with only two linear transformations. Finally, the dedicated quantization bit parameters for each layer are determined based on the probability distribution, which greatly reduces the computing power overhead of the bit controller itself. After the image input operation is completed, the operation flow corresponding to step S120 is entered. The bit controller will retrieve the quantization sensitivity data of each network layer of the target detection network calculated during the offline training phase. Combined with the image features extracted from the current input image, it will output exclusive quantization bit parameters for each layer of the target detection network. The quantization bit parameters represent the integer bit width value used in the quantization process of the corresponding network layer. The network layer with a higher quantization sensitivity value will be assigned a larger quantization bit parameter value to ensure that the detection accuracy of the key network layer after quantization will not be significantly reduced. The network layer with a lower quantization sensitivity value will be assigned a smaller quantization bit parameter value to reduce the computing power consumption of the overall inference stage.

[0057] After all the dedicated quantization bit parameters for each network layer are output, the processing flow corresponding to step S130 is entered. The quantization bit parameters corresponding to each layer are read sequentially. Based on the range of integer values ​​that the quantization bit parameters can represent, the upper and lower quantization limits of the floating-point data of the current network layer are calculated. The upper and lower quantization limits define the complete value boundaries of the floating-point data of the current layer mapped to the integer space. Each layer generates a set of matching quantization bit parameters and quantization upper and lower limits. After traversing all layers of the object detection network, the two sets of parameters corresponding to all layers are collected. The parameter information of all layers is integrated and summarized into unified structured data. This structured data is the quantization grid configuration adapted to the content of the current first frame image. Subsequent inference stages can directly read this quantization grid configuration to perform layer-by-layer quantization and dequantization operations.

[0058] The entire generation process relies entirely on the quantization sensitivity data obtained from offline training to perform hierarchical bit width allocation. It can generate an appropriate hierarchical quantization configuration based on the content of the first frame image, providing a unified quantization standard for subsequent complete object detection inference processes. For the complete hierarchical bit width allocation logic, please refer to [link to documentation / documentation]. Figure 11 Overall architecture diagram.

[0059] Figure 4 This is a flowchart illustrating the layer-by-layer quantization operation of the first frame image based on the quantization grid configuration. For example... Figure 4 As shown, according to an embodiment of the present invention, quantization operations are performed layer by layer on the first frame image based on the quantization grid configuration, including: In step S211, the quantization bit parameters allocated to each layer of the target detection network in the quantization grid configuration are read to determine the upper and lower quantization limit ranges for each layer. In step S212, the floating-point image data input to the current network layer is obtained, and the floating-point data is mapped to integer discrete quantization values ​​by combining the upper and lower quantization limits of the corresponding layer.

[0060] Specifically, the entire set of quantization calculation basis Figure 3 The quantization grid configuration generated in the process is executed. The quantization grid configuration internally stores the matching quantization bit parameters and corresponding quantization upper and lower bound ranges for each layer of the target detection network. When processing the quantization of the first frame image, the device executes steps S211 and S212 sequentially according to the network hierarchy. During step S211, the system reads the stored information within the quantization grid configuration according to the target detection network hierarchy from beginning to end, extracts the quantization bit parameters corresponding to the current network layer, and determines the numerical range that the current integer space can carry based on these quantization bit parameters. Combined with this numerical range, the upper and lower bound ranges of the quantization are defined to fit the floating-point data of the current layer. These quantization upper and lower bound ranges are used to limit the integer value boundaries after mapping all floating-point pixels and feature data in the current layer, avoiding numerical overflow during the mapping process. This scheme uses hierarchical asymmetric uniform quantization for each layer, and after determining the integer value range based on the allocated quantization bit parameters, the corresponding scaling factor is calculated. With zero point The quantization mapping process uses the clamp clipping function to constrain the values. The same set of parameters is reused for both forward floating-point to integer conversion and reverse integer to floating-point conversion. , The parameters are fully quantized. The forward and reverse mappings follow the standard formula of asymmetric affine quantization in deep learning to complete the numerical conversion. The scaling factor and zero point are used to complete the mapping between floating point and integer. The clip function is used to uniformly clip the boundary to prevent feature value overflow and distortion.

[0061] After completing the single-layer parameter and interval reading operations, the process proceeds to step S212. The original floating-point image data input to the current network layer is collected. This floating-point data includes image pixels and floating-point feature information passed from the upper layer. Combined with the quantization upper and lower limits determined in step S211, numerical mapping and transformation are performed, converting continuously distributed floating-point values ​​into discretely distributed integer quantized values. The converted discrete integer quantized values ​​are directly used as input data for subsequent convolutional pooling operations in the current network layer. After the single-layer floating-point data mapping is completed, the system automatically jumps to the next network layer and repeats all operations in steps S211 and S212 until all layers of the object detection network have completed layer-by-layer quantization operations, generating a complete integer feature data stream for subsequent network computation. This quantization operation uses pre-generated layered quantization parameters throughout, with each layer matching a dedicated numerical transformation boundary, balancing quantization compression effects with image feature restoration, providing standardized and uniform input data for subsequent network integer operations.

[0062] Figure 5 This is a flowchart illustrating the dequantization operation performed layer by layer on the first frame of the image based on the quantization grid configuration. For example... Figure 5 As shown, according to an embodiment of the present invention, the first frame image is subjected to inverse quantization layer by layer according to the quantization grid configuration, including: In step S221, the quantization bit parameters and quantization upper and lower limit ranges of the corresponding network layer in the quantization grid configuration are read; In step S222, the integer discrete quantization value obtained by quantization of the current layer is obtained, and the approximate floating-point data is obtained by reverse mapping the upper and lower limits of quantization of the current layer.

[0063] Specifically, the dequantization operation is executed immediately after the integer operation of the corresponding network layer, forming a complete two-way floating-point to integer conversion link with the layer-by-layer quantization operation. The entire set of operations is based on... Figure 3The generated quantization grid is configured and deployed. Within the quantization grid, the pre-determined quantization bit parameters and matching quantization upper and lower bound intervals for each layer are simultaneously stored, ensuring that forward vectorization and reverse mapping use a unified numerical constraint standard. During step S221, the system retrieves the stored information of the current layer to be processed according to the network's traversal order from front to back. Simultaneously, it reads the quantization bit parameters and corresponding quantization upper and lower bound intervals allocated to that layer. This set of parameters and intervals is completely consistent with the content read during the quantization stage in step S211, thus ensuring that forward vectorization and reverse mapping use the same set of integer value constraints, eliminating interval mismatch problems during the conversion process, and avoiding numerical offsets during reverse conversion. After completing the parameter reading, the system enters the processing flow corresponding to step S222. It retrieves the integer discrete quantization value output after the current network layer's convolution or pooling operation, and performs reverse numerical conversion using the quantization upper and lower bound intervals obtained in step S221. This restores the discrete integer value to approximate floating-point data close to the original state. The restored floating-point feature data is then passed to the next layer of the network as input. After a single layer of inverse quantization is completed, the program automatically switches to the next layer of the network, repeatedly executing all operations of steps S221 and S222 until all layers of the object detection network have completed the inverse mapping from integers to floating points. The entire layer-by-layer inverse quantization process corresponds one-to-one with the quantization process, relying on unified layer-by-layer quantization constraints to complete numerical restoration, fully preserving the original distribution information of the image and features, providing continuous floating-point data stream support for subsequent multi-layer feature overlay and target feature extraction, and ensuring that the final object detection result will not be significantly distorted due to quantization integer operations.

[0064] Figure 6 This is a flowchart illustrating the object detection inference process. For example... Figure 6 As shown, according to an embodiment of the present invention, target detection inference is performed, including: In step S231, quantization operation, network integer feature operation and dequantization operation are performed layer by layer in sequence, and feature data is passed layer by layer. In step S232, the network integer feature operation takes the integer discrete quantized value output by the quantization operation as input, performs convolution operation, pooling operation or fully connected operation, and generates the integer feature result of the current layer. In step S233, the category, coordinates, and confidence level of the target in the image are obtained by parsing the feature data output after layer-by-layer operation.

[0065] Specifically, the entire inference process is executed cyclically from front to back according to the network hierarchy. Step S231 coordinates the complete data transformation and flow logic of a single layer. Within each layer's processing cycle, three types of operations are completed sequentially: quantization, feature calculation, and dequantization. After each layer's processing is completed, the transformed feature data is passed to the next layer, forming a coherent data flow transmission link. The system first retrieves the quantization grid configuration matching the current layer, and then... Figure 4 The recorded processing logic converts floating-point data into discrete integer values. The converted integer data is directly fed into the network computation stage, corresponding to the computational operations recorded in step S232. Step S232 restricts the network computation to be performed entirely based on discrete integer values, without introducing floating-point values ​​into the computation. The device matches the corresponding computational logic according to the function type of the current network layer. If the current layer is a feature extraction layer, convolution is performed; if it is a downsampling layer, pooling is performed; if it is a feature fusion layer, fully connected operations are performed. All types of operations are performed in integer format. After the computation is completed, the integer feature results of the corresponding layer are output. After the integer feature results are generated, the quantization grid configuration of this layer is retrieved again, according to... Figure 5 The recorded dequantization processing logic converts integer features into approximate floating-point data. This floating-point data serves as the raw input for the next layer. After completing the entire processing flow of a single layer, steps S231 and S232 are executed repeatedly before moving to the next layer. This process continues layer by layer until the last layer of the target detection network is reached. At this point, the processing flow corresponding to step S233 is entered. The final feature data output by the dequantization of the last layer is read. Based on the various information contained within the features analyzed by the detection branch, the category of the target in the image, the coordinate position of the target within the image, and the confidence value of the corresponding target are identified. This completes the entire target detection inference process for a single frame image. The entire inference process uniformly adopts hierarchical quantization grid constraint value conversion, and uses integer operations as the main calculation form throughout. This can significantly reduce the computing power consumption caused by floating-point operations on edge devices. At the same time, the combination of hierarchical quantization and dequantization can reduce feature distortion caused by low-bit quantization, ensuring that the target information obtained in the final analysis has reliable accuracy.

[0066] Figure 7 This is a flowchart for extracting the baseline environment feature vector of the first frame image and the environment feature vector of the current frame. For example... Figure 7 As shown, according to an embodiment of the present invention, extracting the reference environment feature vector of the first frame image and extracting the environment feature vector of the current frame image includes: In step S311, global pixel statistics are performed on the image to be processed to obtain the overall average brightness, global contrast, and average values ​​of each color channel. In step S312, target detection is performed, valid targets with confidence scores higher than a preset confidence threshold are selected, the number of valid targets and the size of each valid target are counted, and the complexity of the image background is evaluated. In step S313, the average brightness, global contrast, average values ​​of each color channel, number of effective targets, size of each effective target, and image background complexity are combined and spliced ​​to generate the environmental feature vector of the corresponding frame. In step S314, for the first frame image, the generated environmental feature vector is stored as a reference environmental feature vector.

[0067] Specifically, after object detection inference is completed for each frame of the image, the environmental feature extraction process is executed synchronously. The first frame and subsequent ordinary frames reuse the same extraction logic, only distinguishing whether the S314 baseline vector storage operation is executed. First, step S311 is executed to traverse all pixels of the image to be processed to complete global statistics, and calculate the overall average brightness, global contrast, and average values ​​of each color channel. This set of parameters is used to characterize the basic lighting and color environment of the image and is not affected by the distribution of objects within the image.

[0068] After completing the pixel dimension statistics, proceed to step S312, reuse the target detection output of the current frame, filter the valid target boxes with confidence scores higher than the preset threshold, count the total number of valid targets and the size of each target, and then combine the proportion of the target in the screen and the degree of background texture clutter to comprehensively evaluate the image background complexity, and at this moment draw the target distribution scene in the current screen.

[0069] Then, step S313 is executed, where all feature indicators obtained in steps S311 and S312 are linearly concatenated in a fixed order to generate an environmental feature vector with uniform dimensions. This ensures that the structure and dimensions of the vectors generated in all frames are completely consistent, providing standardized data for subsequent vector similarity comparison.

[0070] Finally, step S314, differential processing, is performed: If it is the first frame of the initial processing stage, the stitched environmental feature vector will be stored in the cache and fixed as the global reference environmental feature vector; if it is a subsequent ordinary video frame, only the current feature vector will be temporarily cached, without overwriting the reference vector.

[0071] The entire feature extraction process integrates multi-dimensional scene information such as light and shadow, color, target, and background, which can fully depict the overall environmental state of a single frame. The standardized vector format is the prerequisite for subsequent environmental difference calculation and hierarchical judgment.

[0072] Figure 8 This is a flowchart that compares the current frame's environmental feature vector with a baseline environmental feature vector to determine environmental changes. For example... Figure 8 As shown, according to an embodiment of the present invention, the current frame environment feature vector is compared with a reference environment feature vector to perform an environment change determination, including: In step S321, the cosine similarity between the current frame environment feature vector and the reference environment feature vector is calculated, and the feature difference is obtained based on the cosine similarity. In step S322, the feature difference is compared with the first threshold and the second threshold respectively, wherein the first threshold is less than the second threshold; In step S323, if the feature difference is less than the first threshold, the environment is determined to be in a slightly stable stage. In step S324, if the feature difference is determined to be greater than or equal to the first threshold and less than the second threshold, it is determined that the environment is in a continuous gradual change phase. In step S325, if the feature difference is greater than or equal to the second threshold, it is determined that the environment is in the environmental mutation stage.

[0073] Specifically, after extracting the environmental feature vector of a single frame image, the system retrieves the baseline environmental feature vector persistently stored locally on the device and proceeds to step S321 to perform vector similarity calculation. First, the cosine similarity is calculated for the environmental feature vectors of the current frame and the baseline frame, both of the same dimension. Then, according to a preset conversion rule, the similarity value is converted into a unified standard feature difference value. This difference value directly quantifies the overall difference in environment between the two frames and is an important basis for subsequent classification. The feature difference conversion uses a fixed formula. , Calculate, where Representative feature difference degree The current frame's environmental feature vector Compared with the baseline environment feature vector The cosine similarity is converted to map the cosine similarity value [-1,1] to the standard interval [0,1], facilitating comparison between the two-level thresholds. This step uses cosine similarity as a vector measurement standard, which can uniformly quantify the comprehensive changes in multiple dimensions such as illumination, target, and background, without being affected by differences in the number of feature dimensions or feature units.

[0074] After completing the feature difference calculation, step S322 is executed. The system retrieves the pre-configured two-level threshold parameters, where the first threshold is the critical value for small changes and the second threshold is the critical value for drastic changes. The first threshold value is fixed to be less than the second threshold value. The calculated feature difference is compared with the two threshold values ​​in turn to divide the environment into three types of change intervals, which correspond to three scene states.

[0075] If step S323 determines that the feature difference is lower than the first threshold, it means that the overall difference between the current frame and the reference frame in terms of lighting, target distribution and background conditions is very small, and the scene environment is almost unfluctuated. At this time, the current scene is marked as a slightly stable stage. If step S324 determines that the feature difference is between the first threshold and the second threshold, it means that the scene environment is undergoing slow and small continuous changes, and the brightness, number of targets or background are gradually changing, without any instantaneous large changes, and is marked as a continuous gradual change stage. If step S325 determines that the feature difference reaches or exceeds the second threshold, it means that there are instantaneous and drastic changes in the lighting, target, and background of the image, and the environment has changed significantly, and it is directly determined to be in the environmental change stage.

[0076] The entire judgment process uses a unified quantized feature difference degree combined with two levels of fixed thresholds to complete the hierarchical division, distinguishing three types of video scenes: slightly stable, continuously gradual, and abrupt. This provides a clear judgment basis for the subsequent execution of the "maintain existing quantized grid configuration" and "update quantized grid configuration" branch logic. It can accurately distinguish between three working conditions: no obvious fluctuation in the picture, small gradual change, and drastic change in the environment. This avoids meaningless repeated calls to the bit controller to regenerate the quantized grid configuration and effectively reduces the redundant computing power overhead in the edge device inference stage.

[0077] For a complete dual-threshold loop inference process during the deployment phase, please refer to [link / reference]. Figure 15 .

[0078] This dual-threshold judgment mechanism is used to regulate the start frequency of the bit controller. For details on the complete linkage logic of the offline and deployment phases, please refer to [link / details]. Figure 12 .

[0079] Figure 9 This is a flowchart confirming that the determination result is to maintain the existing mass-produced mesh configuration. For example... Figure 9 As shown, according to an embodiment of the present invention, confirming that the determination result is to maintain the existing mass-produced grid configuration includes: In step S410, if it is confirmed that the environment is in a slightly stable phase, or if it is confirmed that the environment is in a continuous gradual change phase and the cumulative number of gradual change frames is less than a preset frame number threshold, it is determined to maintain the existing digital grid configuration. In step S420, after completing the target detection inference for the current frame, the cumulative frame number is incremented by one.

[0080] Specifically, this process undertakes Figure 8 The output of the environmental change determination will trigger branch processing, and this logic will only be triggered in two types of scenarios: the first type is... Figure 8 The first category is that the current environment is in a slightly stable phase; the second category is that it is in a continuous gradual change phase, but the cumulative number of frames with gradual change has not yet reached the system's preset frame rate threshold. If either condition is met, the system will determine that there is no need to regenerate the quantization grid and will directly use the quantization grid configuration currently stored in the device to carry out subsequent inference.

[0081] When entering step S410 of the decision logic, the system simultaneously retrieves two parameters for joint verification: one is... Figure 8The output includes two environmental scene classification results: one is the real-time value of the global variable cumulative frame count; if it is a slightly stable scene, the configuration is directly used without comparing the frame count; if it is a continuous gradual scene, the current cumulative frame count is compared with the preset frame count threshold, and the use branch is executed only when the frame count does not meet the threshold.

[0082] After the judgment is completed, the system jumps to step S420. Based on the currently used quantization grid configuration, the system completes the entire target detection inference process of layer-by-layer quantization, integer operation, and dequantization of the whole frame image. After the inference is completed and the image target information is parsed, the gradual cumulative variable is incremented by one.

[0083] If the current judgment is a slightly stable phase, the increment of the frame number will not change the main judgment meaning of the variable, and the scene will still be checked normally when the next frame is judged; if the current judgment is a continuous gradation phase, the frame number increment will continuously record the cumulative length of the gradation screen, providing a counting basis for whether to trigger the quantization grid update in the future.

[0084] The entire branch logic skips the bit controller regeneration process when the environment fluctuates slightly, saving the repetitive calculations of reallocating quantization bits at each layer and calculating quantization intervals. This significantly reduces redundant computing power consumption during the continuous video stream inference process of edge devices, and improves the real-time processing frame rate without sacrificing detection accuracy.

[0085] Figure 10 This is a flowchart confirming the judgment result as an update to the quantization grid configuration. For example... Figure 10 As shown, according to an embodiment of the present invention, confirming that the determination result is to update the quantization grid configuration includes: In step S510, if it is confirmed that the environment is in a sudden change phase, or if it is confirmed that the environment is in a continuous gradual change phase and the cumulative number of gradual change frames reaches a preset frame threshold, then it is determined to update the quantization grid configuration. In step S520, after generating a new quantized grid configuration, the reference environment feature vector is replaced with the current frame environment feature vector, and the gradient cumulative frame count is cleared to zero.

[0086] Specifically, this branch serves as Figure 8 Environmental assessment, Figure 9 The complementary processing logic of the stable branch triggers the quantization mesh regeneration operation only under two conditions that would cause significant changes in the visual environment. During the judgment and verification in step S510, the system synchronously reads... Figure 8The output environment stage judgment result and the globally stored gradient cumulative frame count variable are determined to need to be updated if either condition is met: the first condition is that the feature difference is greater than or equal to the second threshold, which is directly determined as an environmental mutation; the second condition is that in a long-term continuous gradient scene, the gradient cumulative frame count has reached the system preset frame count threshold, which means that the cumulative effect of the gradient is enough to reduce the accuracy of quantization inference. In both cases, the quantization strategy needs to be re-adapted.

[0087] After completing the update judgment, the system re-sends the current frame image to the pre-trained bit controller for reuse. Figure 3 The entire process regenerates a new quantized mesh configuration adapted to the current image. Step S520 executes a parameter update and reset operation. First, the environmental feature vector extracted from the current frame is used to overwrite the original baseline environmental feature vector in the cache, completing the synchronous replacement of the baseline reference standard. Then, the gradient cumulative frame count variable used to count the gradient image is cleared and reset.

[0088] After all parameters are updated, the device will perform quantization inference, environmental feature extraction, and judgment loops for all subsequent frames based on the new quantization grid configuration. Resetting the reference vector and frame counter ensures that all subsequent environmental difference comparisons use the latest image as the reference benchmark, avoiding the old environmental standard from continuously interfering with subsequent judgment logic, accurately matching the updated real-world scene environment, and ensuring that subsequent quantization bit width allocation always conforms to the real-time image lighting, target, and background conditions.

[0089] The entire update branch logic only triggers bit controller recalculation after drastic changes or long-term gradual changes in the environment, avoiding bit width allocation operations in every frame. This reduces redundant computing power overhead for continuous video inference of edge devices from the source. At the same time, it achieves environmental tracking self-adaptation by synchronously updating the baseline features, balancing detection accuracy and real-time computing performance of the device.

[0090] Figure 11 This is a schematic diagram of the hierarchical adaptive bit width allocation architecture of the bit controller of the present invention. Figure 11As shown, a single frame of the image to be detected is sequentially input to the bit controller. Based on the quantization sensitivity data of each network layer obtained during offline training, and combined with the image features extracted from the current input image, the bit controller outputs a dedicated quantization bit width configuration adapted to the weights and activation values ​​of each layer of the object detection network. The diagram shows multiple selectable quantization bit widths of 2-bit, 3-bit, 4-bit, and 5-bit. Solid boxes represent the quantization bit width level ultimately selected and used by the bit controller in the current scene, while dashed boxes represent unselected candidate bit width levels. The black dots in the diagram represent the uniquely determined quantization bit width output path for each layer. The object detection network performs mixed-precision quantization operations layer by layer from layer 1 to layer n using the corresponding allocated quantization bit width. Network layers with higher quantization sensitivity are matched with larger quantization bit widths, while low-sensitivity network layers are assigned lower bit widths. This reduces inference computational overhead while ensuring that the object detection accuracy after quantization of key network layers does not significantly decrease.

[0091] Figure 12 This is a schematic diagram of the overall architecture of the offline and deployment phases of this invention. Figure 12 As shown, this invention is divided into two independent operating modules: an offline phase and a deployment phase. The offline phase includes four sub-steps: initialization, quantization sensitivity evaluation, sensitivity weight coefficient calculation, and bit controller training. The initialization process outputs a baseline bit-width quantization model. The quantization sensitivity evaluation and sensitivity weight coefficient calculation obtain the quantization constraint parameters for each network layer, which are then input into the bit controller training process. After training, the bit controller is obtained. The deployment phase includes two sub-steps: environmental feature vector extraction and a dual-threshold judgment mechanism. During deployment, the current scene's environmental feature vector is continuously extracted. A control signal is output using the dual-threshold judgment mechanism to control the bit controller's activation frequency. The bit controller is only re-called to generate the quantization bit-width configuration when environmental changes reach the threshold conditions, thus avoiding repeated calculations frame-by-frame and reducing the computational overhead of edge device inference. The bit controller output from the offline phase serves as the main unit for bit-width allocation in the deployment phase, realizing a complete adaptive quantization closed loop of offline pre-training and online on-demand calling.

[0092] Figure 13 This is a schematic diagram of the baseline quantization model generation process during the offline initialization phase of this invention. Figure 13 As shown, the initialization process involves performing post-training quantization operations based on two types of input data: an n-layer pre-trained model and a calibration set. The calibration set is used to collect the distribution range of activation values ​​in each layer of the network, while the pre-trained model provides the original floating-point weight parameters. After both are input, the training quantization module uniformly solves the quantization mapping parameters and finally outputs a benchmark quantization model. This benchmark quantization model provides a unified quantization benchmark for subsequent quantization sensitivity evaluation, ensuring that the sensitivity evaluation results of each network layer have a unified standard for horizontal comparison.

[0093] Figure 14This is a schematic diagram of the layer-by-layer perturbation calculation process for quantization sensitivity loss assessment based on layer-by-layer perturbation, as described in this invention. Figure 14 As shown, a labeled validation set is used as unified input data. First, the validation set is fed into a baseline bit-width model with all layers configured as high bit-width, and the baseline result is output. Then, perturbation models 1 to n are constructed sequentially. In each perturbation model, only one layer is replaced with a low bit-width level, while the remaining layers maintain the high bit-width configuration. The corresponding perturbation results 1 to n are then calculated and output. The difference between all perturbation results and the baseline result is compared. Based on the output deviation caused by the perturbation, the quantization sensitivity of the network is calculated layer by layer. The higher the sensitivity value, the greater the impact of the decrease in quantization accuracy of that layer on the overall detection effect. In subsequent bit controller training, higher quantization bit widths will be allocated to high-sensitivity layers. In the figure, gray squares represent high bit-width levels, and white squares represent low bit-width levels.

[0094] Figure 15 This is a schematic diagram illustrating the complete process of dual-threshold adaptive quantization inference during the deployment phase of this invention. Figure 15 As shown, after the device enters the deployment and operation phase, it first processes the first frame image and extracts the initial environmental feature vector. The bit controller is started for the first time to generate the initial quantization scheme. The count variable `count` is initialized to 0; subsequently, images are read frame by frame to extract environmental features of the current frame. Calculate the current feature and the baseline feature. Difference First-level threshold Used to determine stable environmental conditions, if If the difference indicates no significant change in the image, the existing quantification scheme will be used directly for quantification inference; if the difference exceeds [a certain threshold], [the remaining text is incomplete and requires further context]. Then proceed to the second threshold. Judgment, when If the problem is determined to be a sudden environmental change, the bit controller is directly restarted to generate a completely new quantization scheme; when If the scene is determined to be a slow, gradual change, the counter variable `count` is incremented by 1. If the cumulative number of frames `count` is greater than a preset threshold `P`, it indicates a long-term, small environmental change, and the bit controller is restarted to update the quantization scheme. After updating the quantization scheme, the baseline feature and baseline quantization scheme are replaced synchronously, and the counter variable is cleared. All branches eventually perform quantization inference in a unified manner until there is no next frame image, at which point the process ends.

[0095] Figure 16 , Figure 17The graphs show a comparison of the model training loss convergence curves with and without the introduction of ODOL quantization sensitivity loss in this invention. In the two graphs, the solid red line represents the training curve with layer-by-layer perturbation quantization sensitivity loss, and the dashed blue line represents the control training curve without this loss. The horizontal axis represents the number of training iterations, and the vertical axis represents the overall model loss value. The curve trends show that, under the same number of training iterations, the scheme with added ODOL loss constraint exhibits a significantly faster loss reduction rate, and the model converges more quickly. After training to a stable stage, the scheme with ODOL loss has a lower final steady-state loss value. These experimental results demonstrate that constructing an auxiliary loss based on layer-by-layer perturbation calculation of quantization sensitivity can guide the network to balance detection accuracy and quantization bit width allocation during training, effectively alleviating the accuracy degradation problem caused by low-bit-width quantization, and verifying the beneficial technical effects of the offline sensitivity constraint mechanism of this invention.

[0096] This invention proposes an adaptive hybrid precision quantization method for target detection accommodating environmental changes. The method is divided into two main stages: offline bit controller training and online adaptive inference, forming a complete and feasible quantization deployment scheme. In the offline stage, the bit controller training is guided by solving the network quantization sensitivity layer by layer and constructing a weighted loss function with sensitivity weights. This addresses the shortcomings of traditional dynamic quantization training, such as slow convergence and over-compression of key detection layers. Under the same degree of quantization compression, it effectively preserves target detection accuracy and improves model training efficiency. In the online inference stage, a multi-dimensional environmental feature vector is innovatively introduced to represent the real-time scene. Environmental differences are calculated based on cosine similarity, and three environmental conditions are classified using two-level thresholds. The bit controller is only re-invoked to generate the quantization grid when the environment undergoes sudden changes or long-term gradual changes, significantly eliminating the redundant computational overhead caused by frame-by-frame quantization updates. Simultaneously, layered quantization, integer arithmetic, and dequantization are executed in a coordinated manner, balancing inference real-time performance and target recognition accuracy on edge devices with low computing power. The entire solution is compatible with various edge vision devices such as robots, surveillance equipment, and drones. It can adapt to diverse real-world scenarios, including changes in lighting, target density, and cluttered backgrounds. It achieves a balanced optimization among quantization compression rate, detection accuracy, and real-time frame rate, demonstrating high practical value for engineering deployment and promising prospects for widespread adoption. Furthermore, this invention offers several equivalent alternative implementations: the bit controller can replace the multi-layer CNN feature extraction backbone, not limited to a two-layer fully connected perceptron; the sensitivity weights can be replaced with a sigmoid piecewise function instead of negative exponential mapping; environmental differences can be replaced with Euclidean distance instead of cosine similarity calculation; environmental feature vectors can be modified by adding or removing weather and temporal dimension indicators based on the scene; and the environmental judgment logic can replace the LSTM temporal classification model. All these equivalent methods can achieve the main goal of adaptive quantization in this invention.

[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An adaptive hybrid precision quantization method for target detection oriented towards environmental changes, characterized in that, include: Perform initial processing, initialize the gradient cumulative frame number variable to zero, and generate a quantization grid configuration based on the first frame image using a pre-trained bit controller; Based on the quantization grid configuration, the first frame image is quantized and dequantized layer by layer to complete the target detection inference and extract the baseline environment feature vector of the first frame image; The next frame image is acquired, the current frame environment feature vector is extracted, the current frame environment feature vector is compared with the reference environment feature vector, and an environment change determination is performed. If the determination result is to maintain the existing quantized grid configuration, perform quantization and dequantization operations layer by layer on the current frame image using the current quantization grid configuration to complete the object detection inference; or, If the determination result is to update the quantization grid configuration, the bit controller is called again to generate a new quantization grid configuration, and the reference environment feature vector is updated to the current frame environment feature vector.

2. The method according to claim 1, characterized in that, Also includes: The step of performing pre-training on the bit controller further includes: The quantization sensitivity of each network layer of the target detection network is calculated layer by layer, and a weighted loss function is constructed based on the quantization sensitivity; The bit controller is trained using the weighted loss function, and the trained bit controller is stored in the device.

3. The method according to claim 1, characterized in that, The bit controller, which is pre-trained, generates a quantization grid configuration based on the first frame image, including: Input the first frame image into the pre-trained bit controller; The bit controller outputs the quantization bit parameters allocated to each network layer based on the quantization sensitivity of each network layer of the target detection network. The quantization upper and lower bound intervals of each layer are calculated by combining the quantization bit parameters of each network layer, and the quantization bit parameters and quantization upper and lower bound intervals of all network layers are integrated to generate the quantization grid configuration.

4. The method according to claim 1, characterized in that, The step of performing layer-by-layer quantization operations on the first frame image according to the quantization grid configuration includes: Read the quantization bit parameters allocated to each layer of the target detection network in the quantization grid configuration, and determine the upper and lower quantization limit ranges for each layer; Obtain the floating-point image data input to the current network layer, and map the floating-point data into integer discrete quantization values ​​by combining the upper and lower quantization limits of the corresponding layer.

5. The method according to claim 1, characterized in that, The step of performing dequantization operations layer by layer on the first frame image according to the quantization grid configuration includes: Read the quantization bit parameters and quantization upper and lower limit ranges of the corresponding network layer in the quantization grid configuration; Obtain the integer discrete quantized value obtained by quantization of the current layer, and then reverse map it with the upper and lower limits of the quantization of the current layer to obtain approximate floating-point data.

6. The method according to claim 1, characterized in that, The completion of target detection inference includes: The quantization operation, network integer feature operation, and dequantization operation are performed layer by layer in sequence, and the feature data is passed layer by layer. The network integer feature operation takes the integer discrete quantized value output by the quantization operation as input, performs convolution operation, pooling operation or fully connected operation, and generates the integer feature result of the current layer. Based on the feature data output after layer-by-layer computation, the category, coordinates, and confidence level of the target within the image are obtained through analysis.

7. The method according to claim 1, characterized in that, The extraction of the reference environment feature vector of the first frame image and the extraction of the environment feature vector of the current frame include: Perform global pixel statistics on the image to be processed to obtain the overall average brightness, global contrast, and average values ​​of each color channel. Perform object detection, filter valid targets with confidence scores higher than a preset confidence threshold, count the number of valid targets and the size of each valid target, and evaluate the complexity of the image background; The average brightness, global contrast, average values ​​of each color channel, number of effective targets, size of each effective target, and image background complexity are combined and stitched together to generate the environmental feature vector of the corresponding frame. For the first frame image, the generated environmental feature vector is stored as a baseline environmental feature vector.

8. The method according to claim 1, characterized in that, The current frame environment feature vector is compared with the reference environment feature vector to perform an environment change determination, including: Calculate the cosine similarity between the current frame environment feature vector and the reference environment feature vector, and obtain the feature difference based on the cosine similarity; The feature difference is compared with a first threshold and a second threshold, respectively, wherein the first threshold is less than the second threshold; If the feature difference is less than a first threshold, the environment is determined to be in a slightly stable phase. If the feature difference is determined to be greater than or equal to a first threshold and less than a second threshold, it is determined that the environment is in a continuous gradual change phase. If the feature difference is determined to be greater than or equal to the second threshold, the environment is determined to be in a sudden environmental change stage.

9. The method according to claim 1, characterized in that, The confirmation decision result is to maintain the existing mass-produced grid configuration, including: If the environment is confirmed to be in a slightly stable phase, or if the environment is confirmed to be in a continuous gradual change phase and the cumulative number of gradual changes is less than a preset frame number threshold, it is determined to maintain the existing quantitative grid configuration. After completing the target detection inference for the current frame, increment the gradual cumulative frame number by one.

10. The method according to claim 1, characterized in that, The confirmation and determination result is to update the quantization grid configuration, including: If the environment is confirmed to be in a sudden change phase, or if the environment is confirmed to be in a gradual change phase and the cumulative number of frames of the gradual change reaches a preset frame threshold, then the quantization grid configuration is updated. After generating a new quantized grid configuration, the reference environment feature vector is replaced with the current frame environment feature vector, and the gradient cumulative frame count is cleared to zero.