NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

HAFormer: Unleashing the Power of Hierarchy-Aware Features for Lightweight Semantic Segmentation

Guoan Xu, Wenjing Jia, Tao Wu, Ligeng Chen, Guangwei Gao · DOI

Introduction

Semantic segmentation—the task of assigning a category label to every pixel in an image—is a cornerstone of autonomous driving and medical imaging. However, the field faces a persistent "tug-of-war" between accuracy and efficiency. Large-scale models achieve high accuracy but are too computationally expensive for edge devices. Conversely, existing lightweight models often rely solely on Convolutional Neural Networks (CNNs), which struggle to capture long-range global dependencies, or Transformers, which suffer from quadratic computational complexity and a lack of local spatial detail.

HAFormer is a novel, lightweight semantic segmentation architecture that effectively marries the local feature-extraction prowess of CNNs with the global context modeling of Transformers. By introducing hierarchy-aware modules and an efficient attention mechanism, it achieves state-of-the-art performance while maintaining real-time speeds exceeding 100 FPS on standard hardware.

Architecture and Methods

The HAFormer architecture overview, showcasing the dual-branch structure and fusion mechanism.

HAFormer utilizes three primary innovations to balance the CNN-Transformer hybrid:

  1. Hierarchy-Aware Pixel-Excitation (HAPE): This module replaces standard residual blocks. It uses parallel convolutions with varying kernel sizes (3x3, 5x5, 7x7) and dilation rates to capture features at multiple scales simultaneously. It also includes a Pixel-Excitation Module (PEM), a content-aware spatial attention mechanism that helps the model focus on relevant pixels within those various receptive fields.
  2. Efficient Transformer (ET): To avoid the massive computational cost of traditional Transformers, the ET module employs a spatial reduction-linear projection and a feature-splitting strategy. This reduces self-attention complexity from $O(N^2)$ to $O(N^2/sr)$, where $sr$ is a reduction factor, making global modeling feasible for lightweight architectures.
  3. Correlation-weighted Fusion (cwF): Simply adding or concatenating CNN and Transformer features often leads to "feature mismatch." The cwF module calculates a correlation coefficient matrix to selectively merge these diverse representations, ensuring that the local details from the CNN and the global context from the Transformer complement each other effectively during decoding.

Key Insights and Results

The model was trained and evaluated on two industry-standard benchmarks: Cityscapes (5,000 high-quality urban street scenes) and CamVid (road scenes with 11 common categories).

HAFormer demonstrates an impressive trade-off between accuracy, size, and speed:

  • Accuracy: Achieved 74.2% mIoU on Cityscapes and 71.1% mIoU on CamVid.
  • Efficiency: The model is remarkably compact, with only 0.60 million parameters and 11.1 GFLOPs.
  • Speed: It reaches inference speeds of 105 FPS on Cityscapes (at 512x1024 resolution) and 118 FPS on CamVid using a single NVIDIA RTX 2080Ti GPU.
Qualitative comparison on Cityscapes, highlighting HAFormer's ability to segment small objects accurately.

A key takeaway is that hierarchy is vital for small objects. By using the HAPE module, the model is significantly better at identifying small, distant objects (like traffic signs or pedestrians) that are often lost in the aggressive downsampling of traditional lightweight networks. Furthermore, the cwF module proves that how you combine features is just as important as the features themselves; weighting fusion based on correlation prevents noise from one branch from degrading the signal of the other.

Conclusion

HAFormer demonstrates that for lightweight tasks, a hybrid approach is superior to pure CNN or Transformer architectures. While adding Efficient Transformer layers improves performance, the authors note that gains plateau if more than two ET layers are stacked in this specific configuration due to potential overfitting. Future work will focus on optimizing the architecture for even higher-resolution inputs and applying hierarchy-aware feature extraction to other dense prediction tasks like depth estimation.

Summary updated

BibTeX
@article{xu2024haformer,
  author = {Guoan Xu and Wenjing Jia and Tao Wu and Ligeng Chen and Guangwei Gao},
  title = {{HAFormer: Unleashing the Power of Hierarchy-Aware Features for Lightweight Semantic Segmentation}},
  journal = {IEEE Trans. Image Process.},
  year = {2024},
  doi = {10.1109/tip.2024.3425048},
}
Figure