arXiv(opens in a new tab)Computer ScienceDec 2020Cited by 7 papers on PaperVantage

Manuscript Offprint

arXiv:2012.15840

Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers

Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, T. Xiang, Philip H. S. Torr, Li Zhang

Abstract

Most recent semantic segmentation methods adopt a fully-convolutional network (FCN) with an encoder-decoder architecture. The encoder progressively reduces the spatial resolution and learns more abstract/semantic visual concepts with larger receptive fields. Since context modeling is critical for segmentation, the latest efforts have been focused on increasing the receptive field, through either dilated/atrous convolutions or inserting attention modules. However, the encoder-decoder based FCN architecture remains unchanged. In this paper, we aim to provide an alternative perspective by treating semantic segmentation as a sequence-to-sequence prediction task. Specifically, we deploy a pure transformer (i.e., without convolution and resolution reduction) to encode an image as a sequence of patches. With the global context modeled in every layer of the transformer, this encoder can be combined with a simple decoder to provide a powerful segmentation model, termed SEgmentation TRansformer (SETR). Extensive experiments show that SETR achieves new state of the art on ADE20K (50.28% mIoU), Pascal Context (55.83% mIoU) and competitive results on Cityscapes. Particularly, we achieve the first position in the highly competitive ADE20K test server leaderboard on the day of submission.

1 Introduction

Since the seminal work of [36], existing semantic segmentation models have been dominated by those based on fully convolutional network (FCN). A standard FCN segmentation model has an encoder-decoder architecture: the encoder is for feature representation learning, while the decoder for pixel-level classification of the feature representations yielded by the encoder. Among the two, feature representation learning (i.e., the encoder) is arguably the most important model component [8, 60, 57, 28]. The encoder, like most other CNNs designed for image understanding, consists of stacked convolution layers. Due to concerns on computational cost, the resolution of feature maps is reduced progressively, and the encoder is hence able to learn more abstract/semantic visual concepts with a gradually increased receptive field. Such a design is popular due to two favorable merits, namely translation equivariance and locality. The former respects well the nature of imaging process [58] which underpins the model generalization ability to unseen image data. Whereas the latter controls the model complexity by sharing parameters across space. However, it also raises a fundamental limitation that learning long-range dependency information, critical for semantic segmentation in unconstrained scene images [2, 50], becomes challenging due to still limited receptive fields.

To overcome this aforementioned limitation, a number of approaches have been introduced recently. One approach is to directly manipulate the convolution operation. This includes large kernel sizes [40], atrous convolutions [22, 8], and image/feature pyramids [60]. The other approach is to integrate attention modules into the FCN architecture. Such a module aims to model global interactions of all pixels in the feature map [48]. When applied to semantic segmentation [25, 29], a common design is to combine the attention module to the FCN architecture with attention layers sitting on the top. Taking either approach, the standard encoder-decoder FCN model architecture remains unchanged. More recently, attempts have been made to get rid of convolutions altogether and deploy attention-alone models [47] instead. However, even without convolution, they do not change the nature of the FCN model structure: an encoder downsamples the spatial resolution of the input, developing lower-resolution feature mappings useful for discriminating semantic classes, and the decoder upsamples the feature representations into a full-resolution segmentation map.

In this paper, we aim to provide a rethinking to the semantic segmentation model design and contribute an alternative. In particular, we propose to replace the stacked convolution layers based encoder with gradually reduced spatial resolution with a pure transformer [45], resulting in a new segmentation model termed SEgmentation TRansformer (SETR). This transformer-alone encoder treats an input image as a sequence of image patches represented by learned patch embedding, and transforms the sequence with global self-attention modeling for discriminative feature representation learning. Concretely, we first decompose an image into a grid of fixed-sized patches, forming a sequence of patches. With a linear embedding layer applied to the flattened pixel vectors of every patch, we then obtain a sequence of feature embedding vectors as the input to a transformer. Given the learned features from the encoder transformer, a decoder is then used to recover the original image resolution. Crucially there is no downsampling in spatial resolution but global context modeling at every layer of the encoder transformer, thus offering a completely new perspective to the semantic segmentation problem.

This pure transformer design is inspired by its tremendous success in natural language processing (NLP) [45, 15]. More recently, a pure vision transformer or ViT [17] has shown to be effective for image classification tasks. It thus provides direct evidence that the traditional stacked convolution layer (i.e., CNN) design can be challenged and image features do not necessarily need to be learned progressively from local to global context by reducing spatial resolution. However, extending a pure transformer from image classification to a spatial location sensitive task of semantic segmentation is non-trivial. We show empirically that SETR not only offers a new perspective in model design, but also achieves new state of the art on a number of benchmarks.

The following contributions are made in this paper: (1) We reformulate the image semantic segmentation problem from a sequence-to-sequence learning perspective, offering an alternative to the dominating encoder-decoder FCN model design. (2) As an instantiation, we exploit the transformer framework to implement our fully attentive feature representation encoder by sequentializing images. (3) To extensively examine the self-attentive feature presentations, we further introduce three different decoder designs with varying complexities. Extensive experiments show that our SETR models can learn superior feature representations as compared to different FCNs with and without attention modules, yielding new state of the art on ADE20K (50.28%), Pascal Context (55.83%) and competitive results on Cityscapes. Particularly, our entry is ranked the 1st1^{st} place in the highly competitive ADE20K test server leaderboard.

References (58)

  • Quantifying attention flow in transformers
  • Segnet: A deep convolutional encoder-decoder architecture for image segmentation
  • Attention augmented convolutional networks
  • Gcnet: Non-local networks meet squeeze-excitation networks and beyond
  • End-to-end object detection with transformers
  • Semantic image segmentation with deep convolutional nets and fully connected CRFs
  • Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs
  • Rethinking atrous convolution for semantic image segmentation
  • Encoder-decoder with atrous separable convolution for semantic image segmentation
  • Panoptic-deeplab: A simple, strong, and fast baseline for bottom-up panoptic segmentation
  • The cityscapes dataset for semantic urban scene understanding
  • Transformer-XL: Attentive language models beyond a fixed-length context
  • BERT: Pre-training of deep bidirectional transformers for language understanding
  • Semantic correlation promoted shape-variant context for segmentation
  • Transformers for image recognition at scale
  • Dual attention network for scene segmentation
  • Adaptive pyramid context network for semantic segmentation
  • Deep residual learning for image recognition
  • Axial attention in multidimensional transformers
  • A real-time algorithm for signal analysis with the help of the wavelet transform
  • Strip pooling: Rethinking spatial pooling for scene parsing
  • Local relation networks for image recognition
  • Ccnet: Criss-cross attention for semantic segmentation
  • Panoptic feature pyramid networks
  • Improving semantic segmentation via decoupled body and edge supervision
  • Global aggregation then local distribution in fully convolutional networks
  • Gff: Gated fully fusion for semantic segmentation
  • Expectation-maximization attention networks for semantic segmentation
  • Revisiting stereo depth estimation from a sequence-to-sequence perspective with transformers
  • Feature pyramid networks for object detection
  • End-to-end lane shape prediction with transformers
  • Semantic image segmentation via deep parsing network
  • Fully convolutional networks for semantic segmentation
  • The role of context for object detection and semantic segmentation in the wild
  • Learning deconvolution network for semantic segmentation
  • Large kernel matters — improve semantic segmentation by global convolutional network
  • Stand-alone self-attention in vision models
  • U-net: Convolutional networks for biomedical image segmentation
  • Very deep convolutional networks for large-scale image recognition
  • Training data-efficient image transformers & distillation through attention
  • Attention is all you need
  • Graph attention networks
  • Axial-deeplab: Stand-alone axial-attention for panoptic segmentation
  • Non-local neural networks
  • Unified perceptual parsing for scene understanding
  • Denseaspp for semantic segmentation in street scenes
  • XLNet: Generalized autoregressive pretraining for language understanding
  • Bisenet: Bilateral segmentation network for real-time semantic segmentation
  • Multi-scale context aggregation by dilated convolutions
  • Object-contextual representations for semantic segmentation
  • Ocnet: Object context network for scene parsing
  • Dual graph convolutional network for semantic segmentation
  • Dynamic graph message passing networks
  • Exploring self-attention for image recognition
  • Pyramid scene parsing network
  • Psanet: Point-wise spatial attention network for scene parsing
  • Conditional random fields as recurrent neural networks
  • Semantic understanding of scenes through the ade20k dataset