Paper commentary
Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers
SETR replaces convolutional encoders with a transformer for segmentation
- Problem Convolutional encoders shrink feature maps with depth, so long-range context builds up only slowly through growing receptive fields. Attention added to them is usually limited to the smallest, highest layers.
- Method SETR uses a pure transformer encoder that reads an image as a sequence of 16×16 patches, with no convolution or resolution reduction. A simple decoder then upsamples the output to full resolution.
- Results SETR reaches 50.28% mIoU on ADE20K and 55.83 mIoU on PASCAL Context with multi-scale inference. Both are reported as state of the art.
Why stacked convolutions limit context
A standard FCN segmentation model has an encoder that learns features and a decoder that classifies pixels. The encoder lowers the resolution of its feature maps as it goes deeper, so it builds more abstract concepts, but its receptive fields grow only with depth. Each convolution sees a small neighbourhood, so long-range dependencies that scene images need are captured only in the highest layers, where the maps are smallest.
Two families of fixes have been tried. One enlarges the convolution itself with large kernels, atrous convolutions or pyramids, and the other adds attention modules on top of the convolutional backbone. Attention attached to an FCN is often limited to the higher layers with small feature maps, because its cost grows quadratically with the number of pixels, which leaves lower-level features without long-range dependency learning.
Attention-alone models that drop convolutions, such as Axial-Attention, still reduce spatial resolution layer by layer.
Turning an image into a token sequence
The image of size H×W×3 is split into a grid of 16×16 patches, each patch is flattened, and a linear projection maps it to a C-dimensional embedding.
Feeding single pixels as tokens is impractical. A 480×480×3 image flattened into one vector has 691,200 entries, and the quadratic complexity of the transformer makes that infeasible in both memory and time. Self-attention ignores order, so each patch location receives a learned position embedding that is added to its patch embedding before the first layer.
What each encoder layer computes
Each layer projects its input into queries, keys and values using learnable matrices \(W^Q\), \(W^K\) and \(W^V\) of size \(C\times d\). Self-attention then computes scaled dot-product weights over all positions, normalises them with a softmax, uses them to mix the values, and adds the input back through a residual connection: \( \mathrm{SA}(Z^{l-1}) = Z^{l-1} + \mathrm{softmax}\!\left(\frac{Z^{l-1}W^Q (Z^{l-1}W^K)^\top}{\sqrt{d}}\right)Z^{l-1}W^V \).
Multi-head self-attention runs m such operations, concatenates their outputs and projects them with \(W^O\) of size \(md\times C\), with d set to C/m.
The layer output adds an MLP block that acts on the MSA output, \( Z^l = \mathrm{MSA}(Z^{l-1}) + \mathrm{MLP}(\mathrm{MSA}(Z^{l-1})) \), with layer normalization applied before the attention and MLP blocks. Every layer keeps the sequence length L and width C, so each layer has a global receptive field and the features \(Z^1\) to \(Z^{L_e}\) are all available to the decoder.
T-Base uses 12 layers, hidden size 768 and 12 heads, while T-Large uses 24 layers, hidden size 1024 and 16 heads.
Three ways to reach full resolution
SETR-Naïve projects the final feature to the number of categories with a two-layer network of 1×1 convolution, synchronized batch normalization with ReLU, and another 1×1 convolution. It then bilinearly upsamples the output to full resolution in one step, which is a 16× jump.
PUP alternates convolutions with 2× upsampling, using four such steps to reach full resolution. The aim is to avoid the noisy predictions that a single large jump can produce.
MLA takes features from M layers spaced uniformly across the encoder, and each selected layer gets its own stream. Its features all share one resolution, so it differs from a feature pyramid network. Each stream is a 3-layer network with kernel sizes 1×1, 3×3 and 3×3, and its channels are halved at the first and third layers. Top-down element-wise addition after the first layer links the streams, a 3×3 conv follows, and the streams are concatenated and upsampled 4× to full resolution.
Pre-training, auxiliary heads and test protocol
The transformer layers and the input linear projection are initialized from ViT or DeiT weights, and every layer without pre-training is randomly initialized. Position embeddings are interpolated in 2D to match the location of each patch when the input size differs from pre-training.
Auxiliary heads attach to intermediate layers: SETR-Naïve uses Z10, Z15 and Z20, SETR-PUP uses Z10, Z15, Z20 and Z24, and SETR-MLA uses Z6, Z12, Z18 and Z24. They train alongside the main head. The ADE20K and PASCAL Context runs use batch size 16, and the Cityscapes runs use batch size 8. The initial learning rate is 0.001 on ADE20K and PASCAL Context and 0.01 on Cityscapes.
Multi-scale testing rescales the image by factors from 0.5 to 1.75, applies horizontal flips, and uses sliding-window inference. The dilated FCN uses output stride 8, while all SETR models use output stride 16 because of GPU memory limits, and the FCN and Semantic FPN baseline numbers are taken from the public codebase results.
ADE20K results
With ImageNet-21K pre-training for both, the dilated FCN reaches 42.17 mIoU and SETR-MLA reaches 48.64. The authors attribute most of this gap to the sequence-to-sequence modelling rather than to the larger pre-training data. The authors report that a single model trained on the train plus validation set ranked first on the ADE20K test server leaderboard.
PASCAL Context results at 80k iterations
The dilated FCN with ResNet-101 reaches 45.74 mIoU with multi-scale testing at 80k iterations on PASCAL Context. Under the same schedule, SETR-PUP reaches 54.40 and SETR-MLA reaches 54.87 with single-scale inference. With multi-scale inference SETR-PUP reaches 55.27 and SETR-MLA reaches 55.83.
The same table lists APCNet at 54.70 and Strip pooling at 54.50, both with ResNet-101. The single-scale SETR-MLA result is above APCNet, and the multi-scale result is further above it. The DeiT-pretrained Base variants score lower, 52.71 to 53.74 at 80k iterations, so the strongest PASCAL Context numbers come from the T-Large encoders.
Cityscapes ablations and comparisons
On the Cityscapes validation set SETR-PUP with ViT ImageNet-21K pre-training reaches 78.39 at 40k iterations and 79.34 at 80k iterations. The DeiT ImageNet-1K pre-trained SETR-PUP reaches 78.79 at 40k and 79.45 at 80k, which is the best Cityscapes entry in that table.
A randomly initialized SETR-PUP reaches only 42.27 mIoU on Cityscapes, so pre-training is critical for this model. SETR-PUP-Base scores 76.71 at 40k, slightly below Hybrid-Base at 76.76, and 78.02 at 80k. The authors read this as evidence that the FCN encoder can be replaced in semantic segmentation.
SETR-MLA scores 76.65 at 40k and 77.24 at 80k, below SETR-PUP. The authors suggest the cause may be that its layer features lack a resolution pyramid, though they present this as a possibility.
With multi-scale inference at 80k iterations, SETR-PUP reaches 82.15, above Axial-DeepLab-L at 81.50 in the same table. Axial-DeepLab ran at the full input resolution of 1024×2048 for 60k iterations at batch size 32, while SETR used 768×768 crops for 80k iterations at batch size 8.
On the Cityscapes test set, SETR-PUP trained for 100k iterations reaches 81.08, and with extra coarse annotations reaches 81.64, compared with 79.90 for Axial-DeepLab-XL.
Limits of the evidence
Experiments cover three benchmarks, ADE20K, PASCAL Context and Cityscapes, so the evidence does not extend to other segmentation datasets. The Cityscapes comparison with Axial-DeepLab is not matched in input size or training schedule.
Accuracy depends strongly on initialization. Random initialization drops SETR-PUP to 42.27 mIoU on Cityscapes, and the Base encoders trail the T-Large encoders. The Hybrid baseline uses only ResNet-50 and T-Base because of GPU memory limits, so it is not a like-for-like comparison with the T-Large models.
The patch size of 16×16 fixes the granularity of the token sequence in all experiments, and pixel-level tokens are ruled out by cost. The attention-map and feature visualizations are qualitative figures and give no separate quantitative measure.
Paper info
- Authors
- Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip H. S. Torr, Li Zhang
- Venue
- arXiv · Preprint
- First published
- 2020-12-31
- Added
- 2026-11-12
- Updated
- 2021-7-25
- Version
- v3
- arXiv
- 2012.15840
- Category
- cs.CV
- Original paper terms
- CC BY 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Sixiao Zheng, Jiachen Lu, Hengshuang Zhao, Xiatian Zhu, Zekun Luo, Yabiao Wang, Yanwei Fu, Jianfeng Feng, Tao Xiang, Philip H. S. Torr, Li Zhang (2020). Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers. arXiv:2012.15840v3. https://arxiv.org/abs/2012.15840v3
BibTeX
@misc{zheng2020rethinking,
title = {{Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformers}},
author = {Sixiao Zheng and Jiachen Lu and Hengshuang Zhao and Xiatian Zhu and Zekun Luo and Yabiao Wang and Yanwei Fu and Jianfeng Feng and Tao Xiang and Philip H. S. Torr and Li Zhang},
year = {2020},
eprint = {2012.15840},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2012.15840v3}
}