Abstract
Image segmentation is often ambiguous at the level of individual image patches and requires contextual information to reach label consensus. In this paper we introduce Segmenter, a transformer model for semantic segmentation. In contrast to convolution-based methods, our approach allows to model global context already at the first layer and throughout the network. We build on the recent Vision Transformer (ViT) and extend it to semantic segmentation. To do so, we rely on the output embeddings corresponding to image patches and obtain class labels from these embeddings with a point-wise linear decoder or a mask transformer decoder. We leverage models pre-trained for image classification and show that we can fine-tune them on moderate sized datasets available for semantic segmentation. The linear decoder allows to obtain excellent results already, but the performance can be further improved by a mask transformer generating class masks. We conduct an extensive ablation study to show the impact of the different parameters, in particular the performance is better for large models and small patch sizes. Segmenter attains excellent results for semantic segmentation. It outperforms the state of the art on both ADE20K and Pascal Context datasets and is competitive on Cityscapes.
Introduction
Semantic segmentation—the task of assigning a category label to every pixel in an image—is notoriously difficult because local patches of an image are often ambiguous. For example, a small patch of "grey" could be a sidewalk, a road, or a building wall. To resolve this, models need global context.
Traditionally, researchers have used Convolutional Neural Networks (CNNs). However, CNNs have a "local" bias; they only see a small neighborhood of pixels at a time. To capture global information, CNNs require many layers, dilated convolutions, or specialized "pooling" modules. Segmenter moves away from these hybrid designs, opting for a pure transformer architecture that captures global context from the very first layer.
Methods
Segmenter extends the Vision Transformer (ViT) architecture to the task of dense prediction. The model consists of two primary components:
- The Encoder: Using a standard ViT, the image is split into patches (e.g., 16x16 pixels), which are flattened and projected into "tokens." These tokens, along with positional encodings, pass through a series of transformer layers where every token can attend to every other token via self-attention.
- The Decoder: The authors propose a novel Mask Transformer decoder. It introduces a set of learnable class embeddings (one for each category, like "sky" or "person"). These embeddings are processed jointly with the image tokens. The final segmentation masks are generated by computing the scalar product between the image tokens and these class embeddings, effectively creating "dynamic filters" that adapt to the specific content of the image.
Key Insights and Results
Segmenter was evaluated on challenging benchmarks including ADE20K, Pascal Context, and Cityscapes. Several key findings emerged from the study:
- Global from the Start: Unlike CNNs, which build up a global view slowly, Segmenter’s attention maps show that even the very first layer can group patches into semantically meaningful categories across the entire image.
- The Power of Resolution: A significant finding is the impact of patch size. Moving from 32x32 or 16x16 patches to 8x8 patches provides a massive performance boost (nearly 5% mIoU on ADE20K) because it allows the model to capture much finer structural details.
- State-of-the-Art Performance: On ADE20K, Segmenter (Seg-L-Mask/16) achieved 53.63% mIoU, outperforming previous leaders like Swin-L. On Pascal Context, it reached 59.0% mIoU, a 2.8% improvement over the previous best.
Conclusion
Segmenter demonstrates that a pure transformer approach can achieve state-of-the-art results in semantic segmentation by prioritizing global context. While the computational cost of smaller patch sizes remains a challenge—with 8x8 patches being significantly slower than 16x16—the model's ability to maintain global consistency and handle complex scenes marks a significant step forward in unified vision architectures.
Summary updated