Abstract
Real-time object detection plays a vital role in various computer vision applications. However, deploying real-time object detectors on resource-constrained platforms poses challenges due to high computational and memory requirements. This paper describes a low-bit quantization method to build a highly efficient one-stage detector, dubbed as Q-YOLO, which can effectively address the performance degradation problem caused by activation distribution imbalance in traditional quantized YOLO models. Q-YOLO introduces a fully end-to-end Post-Training Quantization (PTQ) pipeline with a well-designed Unilateral Histogram-based (UH) activation quantization scheme, which determines the maximum truncation values through histogram analysis by minimizing the Mean Squared Error (MSE) quantization errors. Extensive experiments on the COCO dataset demonstrate the effectiveness of Q-YOLO, outperforming other PTQ methods while achieving a more favorable balance between accuracy and computational cost. This research contributes to advancing the efficient deployment of object detection models on resource-limited edge devices, enabling real-time detection with reduced computational and memory overhead.
The Challenge: Activation Distribution Imbalance
Deploying state-of-the-art object detectors like YOLOv7 on edge devices—such as mobile phones, drones, or embedded GPUs—is challenging due to their high computational and memory intensity. Quantization, the process of converting high-precision 32-bit floating-point numbers into low-precision integers (8-bit or 4-bit), is a common solution. However, traditional Post-Training Quantization (PTQ) often leads to significant accuracy drops in YOLO models.
The primary cause is the SiLU (Swish) activation function used in modern YOLO architectures. SiLU produces an imbalanced distribution where most values cluster near a lower bound of approximately -0.2785, while a few outliers extend far into the positive range. Standard symmetric quantization methods struggle to map this "lopsided" data into limited integer bins without losing critical information.
Methodology: Q-YOLO and UH Quantization
Q-YOLO addresses this imbalance through a fully end-to-end PTQ pipeline. The core innovation is the Unilateral Histogram-based (UH) activation quantization scheme. Unlike symmetric quantization, which forces the range to be centered at zero, Q-YOLO utilizes asymmetric ranges to better fit the actual distribution of activations.
The UH scheme operates as follows:
- Fixed Lower Bound: It recognizes the empirical floor of the SiLU function at -0.2785 and fixes this as the minimum truncation value.
- Iterative Histogram Analysis: Instead of a simple "MinMax" approach sensitive to outliers, Q-YOLO performs a histogram-based search. It analyzes the activation distribution and iteratively identifies the optimal maximum truncation value ($u_x$) that minimizes the Mean Squared Error (MSE) between the original and quantized data.
- Weight Quantization: While activations use the novel UH scheme, weights are quantized using the standard MinMax method to maintain overall efficiency.
Experimental Results
The researchers evaluated Q-YOLO on the COCO 2017 dataset using 1,500 images for calibration and the 5,000-image validation set for testing across YOLOv5 and YOLOv7 variants.
Performance and Accuracy
The results demonstrate that Q-YOLO maintains high accuracy even at low bit-widths. In 8-bit quantization, Q-YOLO achieves parity with full-precision (FP32) models. For instance, YOLOv5s experiences only a 0.1% drop in Mean Average Precision (mAP).
In the more challenging 4-bit quantization category, Q-YOLO significantly outperforms existing PTQ methods. On YOLOv5s, Q-YOLO achieved 14.0% mAP, doubling the performance of the standard "Percentile" method (7.0%). Similar improvements were observed across larger models like YOLOv7 and YOLOv7x.
Hardware Acceleration
Beyond accuracy, Q-YOLO delivers substantial speedups. When deployed using NVIDIA's TensorRT on a Tesla T4 GPU, the 8-bit YOLOv7 model achieved a 3× speedup compared to the FP32 model, reducing inference time from 16.8ms to 5.4ms.
Conclusion and Future Work
Q-YOLO provides a practical, high-performance solution for deploying YOLO models on edge devices without the need for expensive retraining. By specifically addressing the SiLU-induced activation imbalance through the UH scheme, it bridges the gap between efficiency and accuracy.
While Q-YOLO represents a major step forward, challenges remain in 4-bit PTQ, where a significant accuracy gap still exists compared to 8-bit models. Future work may involve adapting these unilateral insights to other architectures, such as Vision Transformers, and optimizing hardware/software stacks to better support asymmetric integer arithmetic.
Summary updated