Abstract
Semantic segmentation—the task of assigning a category to every pixel in an image—is a cornerstone of computer vision. While Vision Transformers (ViTs) have significantly improved performance, they often struggle with precise object boundaries. As networks deepen, they capture rich semantics but lose fine-grained spatial details, resulting in "blurry" edges. We introduce MacFormer, a novel architecture designed to sharpen these boundaries. MacFormer utilizes a Mutual Agent Cross-Attention (MACA) mechanism for bidirectional feature exchange and a Frequency Enhancement Module (FEM) to integrate edge information from the Fourier domain. Our model achieves state-of-the-art results on the ADE20K and Cityscapes benchmarks, offering a robust balance between accuracy and efficiency.
Introduction
The evolution of semantic segmentation has moved from convolutional neural networks to Vision Transformers, which excel at capturing long-range dependencies. However, a persistent challenge remains: the "blurry boundary" problem. Deep layers in a transformer backbone are effective at identifying what an object is but often lose the precise spatial information of where it ends. Traditional decoders frequently fail to recover these details from the encoder's early layers, leading to imprecise segmentation masks. Furthermore, standard transformer cross-attention is computationally expensive for high-resolution feature maps.
Methodology
MacFormer addresses these challenges through a U-shaped architecture that integrates two primary innovations: MACA and FEM.
Overall Architecture
MacFormer is designed to be "backbone-generic," allowing it to be integrated with various transformer backbones such as SegFormer or SegNeXt. The architecture follows a multi-stage encoder-decoder structure where features are fused across different scales.
Mutual Agent Cross-Attention (MACA)
Standard cross-attention typically involves a unidirectional flow where the decoder queries the encoder. MACA transforms this into a bidirectional exchange using learnable agent tokens. These tokens act as intermediaries, allowing the encoder and decoder to share complementary information. This process ensures that low-level edge features from early encoder stages are effectively integrated with high-level semantic context from the decoder.
Frequency Enhancement Module (FEM)
The FEM operates in the frequency domain using Discrete Fast Fourier Transforms (DFFT). It explicitly targets the components of an image that define boundaries:
- High-frequency components: Represent edges and fine details.
- Low-frequency components: Represent global shapes and textures.
FEM extracts high-frequency details from shallow encoder layers to "fill in" missing edge information in deep layers. Simultaneously, it uses low-frequency semantic information from deep layers to refine the representations in shallow layers. This cross-frequency enhancement allows the model to maintain sharp outlines without the heavy computational cost of complex spatial convolutions.
Experimental Results
MacFormer was evaluated on the ADE20K and Cityscapes datasets, two standard benchmarks for general and urban scene segmentation.
Quantitative Performance
MacFormer consistently outperformed existing state-of-the-art (SOTA) models. For instance, on ADE20K, MacFormer with a MiT-B0 backbone achieved a 42.6% mIoU, a significant improvement over SegFormer (37.4%) and U-MixFormer (41.2%). The model's efficiency was also notable, maintaining competitive FLOPs while delivering higher accuracy.
Qualitative Analysis
The impact of the Frequency Enhancement Module is most visible in the segmentation of thin or complex structures. As shown in the comparative analysis, the inclusion of FEM allows the model to resolve fine details—such as chair legs, picture frames, and distant poles—that are otherwise lost or merged into the background.
Conclusion
MacFormer represents a significant step forward in addressing the boundary precision problem in semantic segmentation. By combining bidirectional agent-based attention with frequency-domain feature enhancement, it achieves superior results on challenging benchmarks. Future work will explore the use of knowledge distillation to further optimize these components for real-time deployment on edge devices and investigate emerging architectures like State Space Models (Mamba) for further efficiency gains.
Summary updated