TL;DR
This paper introduces P2HCT, a novel "plug-and-play" module for efficient multi-scale feature fusion in vision models. By combining a coarse-to-fine attention mechanism with parameter sharing, P2HCT significantly reduces computational complexity and memory overhead while boosting accuracy on object detection and image classification tasks, making it ideal for resource-constrained environments.
What Problem Does This Paper Address?
Modern computer vision models, especially those based on Transformers, rely heavily on feature fusion to combine information from different layers or branches. While attention mechanisms have proven effective at capturing rich content-adaptive features, they often come with a hefty price tag: high computational cost (FLOPs), irregular memory access, and complex implementation. This is particularly problematic for real-time applications and devices with limited computational power. Existing methods to mitigate this, like sparse approximations, can break hardware-friendly dataflows or require complex training procedures. The authors aim to bridge this gap by developing a feature fusion module that is both lightweight and highly effective, offering a simple, plug-and-play solution.
Methods
The core innovation is the PnP Hierarchical C2F Transformer (P2HCT). It's designed as a hierarchical fusion architecture that replaces standard feature pyramid network (FPN) modules. Here's how it works:
- Coarse-to-Fine Attention: P2HCT uses a two-stage attention mechanism. First, a "coarse" attention stage uses semantically rich, high-level features to guide queries from lower-level feature maps. This stage is computationally cheaper. Second, a "fine" attention stage focuses on a sparse selection of important local details identified by the coarse stage. This selective focus drastically reduces the computational burden compared to dense attention.
- Parameter Sharing: A key to P2HCT's efficiency is its parameter sharing scheme. The module is designed to be trainable using only the computationally cheaper coarse attention branch. This simplifies training significantly. Crucially, the full fine attention can be activated during inference, allowing for a flexible trade-off between accuracy and efficiency without requiring additional training.
- Lightweight Design: P2HCT replaces standard layers like Linear and LayerNorm with 1x1 convolutions and BatchNorm, making it hardware-friendly. The overall module is designed to be extremely lightweight, comparable in parameter footprint to a single 4x4 convolution.
Datasets
- MS COCO 2017: Used for evaluating object detection performance.
- ImageNet: Used for evaluating image classification performance.
Key Insights and Ideas
- Coarse context guides fine details efficiently: The hierarchical approach, where high-level features inform the selection of low-level features, is a powerful way to reduce computation while retaining important information.
- Train coarse, infer fine: The ability to train the module using only the coarse branch and then enable the fine branch at inference time is a clever way to achieve accuracy gains without retraining, offering dynamic efficiency.
- Parameter sharing is a win-win: It simplifies training and reduces model size without sacrificing performance, making the module more practical.
- Simplicity is key: Replacing complex layers with efficient convolutional equivalents and adopting a streamlined attention mechanism makes P2HCT highly compatible with existing hardware and frameworks.
Key Results
P2HCT demonstrates significant improvements across various tasks and model architectures:
- Object Detection (MS COCO):
- When integrated into ResNet backbones (P2HCT-DET), it achieved mAP gains of 0.9%, 0.5%, and 0.4% for ResNet-18, ResNet-50, and ResNet-101, respectively, with minimal latency increase.
- When replacing the detection head in real-time YOLOv11 variants (N/S/M), P2HCT-enhanced models showed improved mAP (e.g., YOLOv11-P2HCT-N achieved 40.3% mAP vs. 39.4% for baseline) while maintaining or even reducing latency.
- Image Classification (ImageNet):
- Embedding P2HCT into ResNet backbones (P2HCT-CLS) boosted top-1 accuracy by 6.5% (ResNet-18), 1.7% (ResNet-50), and 1.0% (ResNet-101).
- Lightweight YOLOv11-cls variants also saw accuracy improvements of approximately 1%.
- Qualitative Results: Attention heatmaps show that P2HCT-enhanced models produce cleaner and more focused feature activations, indicating better localization of salient regions.
Limitations and Future Work
- Top-k Selection: The paper notes that enabling fine attention during training with top-k selection did not yield better results and even caused training difficulties. This suggests that the underlying mechanisms for optimal top-k selection during training warrant further investigation. The default top-k value of 8 is also noted as largely empirical.
- Hardware Dependency: P2HCT benefits from optimized libraries like FlashAttention or SageAttention, which require modern GPUs, potentially limiting its accessibility on older hardware.
- Future Work: The authors suggest exploring more universally optimal solutions for joint training of fine-grained attention and investigating the empirical nature of the top-k selection.
Summary updated