Abstract
Semantic segmentation has long been dominated by Fully Convolutional Networks (FCNs) that rely on stacked convolutions to expand receptive fields. However, this approach inherently limits the capture of global context. This paper introduces the SEgmentation TRansformer (SETR), which reformulates semantic segmentation as a sequence-to-sequence task. By utilizing a pure Transformer encoder to process image patches, SETR maintains a global receptive field across all layers. Our experiments demonstrate that SETR achieves state-of-the-art performance on major benchmarks, including ADE20K and Pascal Context, highlighting the potential of Transformer-based architectures in computer vision.
Introduction
The standard paradigm for semantic segmentation involves an encoder-decoder structure where the encoder progressively reduces spatial resolution to increase the receptive field. While effective, the slow growth of the receptive field in traditional CNNs often necessitates auxiliary modules like dilated convolutions or attention mechanisms to capture long-range dependencies.
SETR challenges this convention by discarding the convolutional encoder entirely. Instead, it treats an image as a sequence of patches, leveraging the self-attention mechanism of Transformers to model global context from the very first layer. This shift from a grid-based to a sequence-based perspective allows for a more direct and powerful representation of global information.
Methodology
The SETR architecture consists of a pure Transformer encoder and a specialized decoder.
Transformer Encoder
The image is first divided into a grid of fixed-size patches (e.g., 16x16). These patches are flattened and projected into a 1D sequence of embeddings, augmented with positional information. A standard Transformer encoder then processes this sequence. Unlike CNNs, where the receptive field is constrained by kernel size, the self-attention mechanism in SETR allows every patch to interact with every other patch in every layer, providing a truly global context without downsampling.
Decoder Designs
To transform the sequence of embeddings back into a 2D segmentation mask, the authors propose three decoder variants:
- SETR-Naïve: A simple 2-layer network that performs a single-step upsampling to the original resolution.
- SETR-PUP (Progressive UPsampling): This variant uses four successive 2x upsampling steps to better recover spatial details and reduce noise.
- SETR-MLA (Multi-Level feature Aggregation): Inspired by Feature Pyramid Networks, MLA aggregates features from multiple layers of the Transformer (e.g., layers 6, 12, 18, and 24) to capture multi-scale information without changing the internal resolution.
Experimental Evaluation
SETR was evaluated on three prominent datasets: ADE20K, Pascal Context, and Cityscapes.
Key Results
- ADE20K: SETR achieved a mean Intersection over Union (mIoU) of 50.28%, setting a new benchmark at the time of publication.
- Pascal Context: The model reached 55.83% mIoU, significantly outperforming previous state-of-the-art models like APCNet.
- Cityscapes: SETR demonstrated strong performance with 82.15% mIoU, proving its efficacy on high-resolution urban imagery.
Qualitative analysis reveals that SETR is particularly adept at maintaining consistency for large objects and capturing long-range spatial dependencies, areas where traditional dilated FCNs often struggle.
Discussion and Key Insights
The success of SETR underscores several critical points:
- Global Context is Paramount: Having a "bird's eye view" from the start of the encoding process simplifies the task for the decoder.
- The Role of Pre-training: Large-scale pre-training (e.g., on ImageNet-21k) is vital for Transformers to overcome their lack of inductive biases compared to CNNs.
- Architecture Simplification: Strong global features allow for simpler decoder architectures to achieve high performance.
Despite its strengths, SETR faces challenges regarding computational complexity, as self-attention scales quadratically with the number of patches. Future work will likely focus on more efficient Transformer variants and finer-grained patch embeddings to improve performance on smaller objects and higher resolutions.
Conclusion
SETR represents a significant step forward in semantic segmentation, demonstrating that a pure Transformer architecture can outperform highly optimized convolutional networks. By rethinking the task as a sequence-to-sequence problem, SETR opens new avenues for research in vision-based Transformers.
Summary updated