Embedding-Free Transformer with Inference Spatial Reduction for Efficient Semantic Segmentation

Hyunwoo Yu, Yubin Cho, Beoungwoo Kang, Seunghun Moon, Kyeongbo Kong, Suk-Ju Kang

Abstract

Semantic segmentation requires capturing global context, a task where Transformers excel but at a high computational cost. This paper presents EDAFormer, an efficient Transformer-based model that streamlines global modeling. By introducing Embedding-Free Attention (EFA), the model eliminates redundant learned linear projections, focusing instead on the inherent non-linearity of the attention mechanism. Furthermore, the authors propose Inference Spatial Reduction (ISR), a runtime technique that enables a single pretrained model to dynamically adjust its spatial reduction ratio, offering a flexible trade-off between speed and accuracy. Evaluations on ADE20K, Cityscapes, and COCO-Stuff show that EDAFormer achieves state-of-the-art efficiency, with ISR providing up to 61% computational savings with negligible mIoU drops.

Introduction

Assigning a semantic category to every pixel in an image is computationally demanding. While Transformers have revolutionized this field by capturing long-range dependencies, their complexity often limits real-time application. Existing efficient variants typically use Spatial Reduction Attention (SRA) to downsample Key and Value tensors. However, these models are often rigid, requiring separate training for different efficiency targets. Moreover, the standard use of learned Query, Key, and Value (QKV) embeddings may be redundant for capturing global relationships.

The EDAFormer Architecture

The proposed EDAFormer utilizes a hierarchical encoder-decoder structure. The encoder consists of four stages, each utilizing Embedding-Free Transformer (EFT) blocks. The decoder is designed as an "all-attention" structure, prioritizing global context for high-level features to better capture semantic information.

Overall architecture of EDAFormer and the EFT block.

Embedding-Free Attention (EFA)

A core innovation of EDAFormer is the EFA mechanism. In traditional self-attention, input features are projected via learned matrices to create $Q, K,$ and $V$. EFA simplifies this by using the input feature directly as the Query and a spatially reduced version of the input as both the Key and Value. This approach reduces parameter count and computational overhead while maintaining the model's ability to model global interactions through the softmax operation.

Comparison between standard Embedding-based SRA and the proposed Embedding-Free Attention (EFA).

Inference Spatial Reduction (ISR)

ISR is a "plug-and-play" strategy that allows the spatial reduction ratio of the attention mechanism to be increased during inference without retraining. By training the model with a "rich" set of Keys (higher resolution), the model learns robust relationships that persist even when Keys are aggressively downsampled at runtime. This allows users to select the desired speed-accuracy trade-off on the fly.

Experimental Results

The model was rigorously tested on three major benchmarks: ADE20K, Cityscapes, and COCO-Stuff.

  • Efficiency: EDAFormer-T (Tiny) reached 78.7% mIoU on Cityscapes, outperforming competitors like SegFormer in both accuracy and speed.
  • Dynamic Scaling: Applying ISR during inference reduced GFLOPs by 37.4% to 61% across datasets. Remarkably, these savings came with minimal performance degradation, often less than 0.2% mIoU.
  • Generalization: The ISR technique proved effective when applied to other architectures, including Swin Transformer and SegFormer, highlighting its potential as a universal efficiency booster.

Conclusion and Future Work

EDAFormer demonstrates that learned embeddings are not strictly necessary for effective global context modeling in segmentation tasks. While ISR provides unprecedented flexibility, extreme reduction ratios eventually lead to information loss. Future research could investigate the performance of embedding-free structures on specialized hardware and their scalability to larger foundation models.

Summary updated

BibTeX
@inproceedings{yu2024embedding,
  author = {Hyunwoo Yu and Yubin Cho and Beoungwoo Kang and Seunghun Moon and Kyeongbo Kong and Suk-Ju Kang},
  title = {{Embedding-Free Transformer with Inference Spatial Reduction for Efficient Semantic Segmentation}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72946-1\_6},
}
Figure