Pyramid Scene Parsing Network
- Publication
- CVPR 2017Conference
- First submitted to arXiv
- arXiv:1612.01105
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{segmentationpspnet2016,
title = {{Pyramid Scene Parsing Network}},
author = {Hengshuang Zhao and Jianping Shi and Xiaojuan Qi and Xiaogang Wang and Jiaya Jia},
year = {2016},
eprint = {1612.01105},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1612.01105}
}
The 2016 ImageNet Scene Parsing Challenge used ADE20K, which MIT had just released. The dataset has 150 classes, and walls, sky, trees, beds, pillows, street lights and signboards all have to be labeled; every image is packed with things.
Jiaya Jia's team at the Chinese University of Hong Kong and Jianping Shi of SenseTime won that year, and afterwards wrote the method up as this paper. Their starting point was a very concrete observation. Many of FCN's mistakes look obviously wrong to a person, because a person takes in the scene of the whole image.
Defining the Problem
The authors started by going through the results of the FCN baseline that ADE20K provides officially, and sorted the common errors into three kinds.

Mismatched relationship. Inside the yellow box in the first row is a boat, which FCN judged by its appearance to be a car. But cars rarely drive on rivers, and simply knowing this is a boathouse by a river would prevent the mistake.
Confusable categories. The second row is a skyscraper, and FCN labels half of it skyscraper and half building. ADE20K has many such pairs of classes, such as field and earth, mountain and hill, or wall, house and building. The paper cites ADE20K's statistics, by which even the expert who annotated the entire dataset gets 17.60% of pixels wrong. Still, a single object should at least be one class throughout, not half and half.
Inconspicuous categories. In the third row, the pillow and bedsheet have similar patterns, and FCN simply treats the pillow as part of the bed. Small things like street lights and signboards are easy to miss; conversely, very large things extend beyond the receptive field, and the predictions come out patchy.
All three kinds of error point the same way; FCN only looks at local regions.
That's a little strange. ResNet stacks over a hundred layers, and its theoretical receptive field is already larger than the whole image. Citing Zhou et al., the authors point out that a CNN's actual receptive field is much smaller than the theoretical one, and the gap grows in higher layers. Nominally the network can see the whole image, yet the range it actually uses is small.
Then just feed it global information directly. The simplest way is global average pooling, averaging the whole feature map into one vector, which ParseNet had already done. The authors find this insufficient for ADE20K. A bedroom photo has a bed, walls, curtains and a floor; average them all into one vector, and the spatial relations are gone.
Solving the Problem

The core of PSPNet (Pyramid Scene Parsing Network) is a ResNet with atrous convolution and an output stride of 8. After the backbone it attaches a pyramid pooling module (PPM), which gathers context over different ranges and sends it, together with the original features, to the classifier.
Let's walk through it with the settings used in official training.
A Stride-8 Backbone
During training, images are cropped to . ResNet originally downsamples five times, for an output stride of 32; following DeepLab, PSPNet removes the stride of the last two stages and uses dilation 2 and 4 to make up the receptive field.
The backbone outputs a feature map. Each cell corresponds to roughly pixels of the original image; this is (b) in the figure.
Pyramid Pooling
Next, this feature map is average-pooled to four sizes:
- : the whole map averaged into one cell, the same as global average pooling.
- : each cell covers feature positions, about a quarter of the image.
- : each cell covers .
- : each cell covers , about an -pixel region of the original image.
The coarsest level answers "what scene is this?" and the finest answers "what's around here?" The two middle levels sit in between, telling the model that the top left is sky and the bottom half is ground. This is what the authors mean by "context from different sub-regions," and it is what PPM adds over a single global vector.
Each pooled level is followed by a convolution that reduces 2048 channels to 512, and is then enlarged back to with bilinear interpolation. Finally the original feature map and the four levels are concatenated, giving channels.
Why keep only 512 per level? The paper says it is to "maintain the weight of global feature." The four levels add up to 2048, exactly as many as the original local features, so each side gets half.
The official PyTorch implementation writes this module very compactly:
class PPM(nn.Module):
def __init__(self, in_dim, reduction_dim, bins):
super(PPM, self).__init__()
self.features = []
for bin in bins:
self.features.append(nn.Sequential(
nn.AdaptiveAvgPool2d(bin),
nn.Conv2d(in_dim, reduction_dim, kernel_size=1, bias=False),
nn.BatchNorm2d(reduction_dim),
nn.ReLU(inplace=True)
))
self.features = nn.ModuleList(self.features)
def forward(self, x):
x_size = x.size()
out = [x]
for f in self.features:
out.append(F.interpolate(f(x), x_size[2:], mode='bilinear', align_corners=True))
return torch.cat(out, 1)
PSPNet builds the module with bins=(1, 2, 3, 6) and reduction_dim=2048/4. AdaptiveAvgPool2d works out the pooling window from the input size, so the same module can take feature maps of different resolutions.
The 4096 concatenated channels then go through a convolution down to 512, BatchNorm, ReLU and dropout 0.1, and finally a convolution outputs scores for the 150 classes, which are bilinearly enlarged 8× back to the original image.
Auxiliary Loss
The ResNet in PSPNet is very deep; the deepest they tried has 269 layers. After the last residual block of the fourth stage (res4b22 in ResNet101), the authors attach an extra classifier that computes a second loss.

The gradient of this auxiliary loss flows all the way back to every earlier layer. The authors explain it as splitting the optimization in two; the auxiliary branch first learns a preliminary result, and the main branch learns the remaining residual. The total loss is the main loss plus times the auxiliary loss, with . At test time the auxiliary branch is simply discarded, so it adds no inference cost.
The Devil Is in the Details
The paper spends a whole paragraph on implementation details, and the authors themselves wrote "devil is always in the details." The learning rate follows the poly schedule; at every step it is the base rate of 0.01 multiplied by . Data augmentation uses random mirroring and scaling between 0.5× and 2×, plus ±10-degree rotation and Gaussian blur for ADE20K and VOC.
BatchNorm's batch size is another trap. The authors found it affects results a lot, but a single GPU can't hold enough large crops. So they modified Caffe to synchronize BN statistics across GPUs with OpenMPI, so that BN sees a batch of 16. PyTorch later built in SyncBatchNorm, and cross-GPU synchronized BN became a common fixture in training segmentation models.
Discussion
Every Choice in PPM
Table 1 of the paper dissects the PPM design on the ADE20K validation set with ResNet50:
| Setting | mIoU (%) | Pixel acc. (%) |
|---|---|---|
| Baseline (dilated FCN) | 37.23 | 78.01 |
| 1×1 only, max | 39.94 | 79.46 |
| 1×1 only, avg | 40.07 | 79.52 |
| Four levels, max | 40.18 | 79.45 |
| Four levels, avg | 41.07 | 79.97 |
| Four levels, max, dim. reduction | 40.87 | 79.61 |
| Four levels, avg, dim. reduction | 41.68 | 80.04 |
A single global average pooling already adds nearly 3 points of mIoU, confirming the diagnosis that global information was missing. The four-level pyramid adds another point, and dimension reduction another 0.6. Average pooling beats max pooling in every pairing.
Against ParseNet-style single global pooling, the full PPM is 1.61 points of mIoU higher.
The Auxiliary Loss and Other Parts
Table 4 of the paper stacks on each part in turn:
| Setting | mIoU (%) | Pixel acc. (%) |
|---|---|---|
| FCN | 29.39 | 71.32 |
| DilatedNet | 32.31 | 73.55 |
| CascadeNet | 34.90 | 74.52 |
| ResNet50 baseline | 34.28 | 76.35 |
| + data augmentation | 35.82 | 77.07 |
| + auxiliary loss | 37.23 | 78.01 |
| + PPM | 41.68 | 80.04 |
| Switch to ResNet269 | 43.81 | 80.88 |
| + multi-scale testing | 44.94 | 81.69 |
The FCN, DilatedNet and CascadeNet numbers come from the ADE20K paper. The ResNet50 baseline already has higher pixel accuracy than all three, though its mIoU still trails CascadeNet by 0.62 points; data augmentation puts it ahead. PPM is the largest single contributor, adding 4.45 points.
This table also explains the previous one. Table 1's baseline of 37.23 already includes data augmentation and the auxiliary loss.
Backbone depth matters too (Table 3 of the paper). With the same settings, ResNet50, 101, 152 and 269 give mIoU of 41.68, 41.96, 42.62 and 43.81, and multi-scale testing takes the best to 44.94. Going from 50 to 269 layers adds a little over 2 points, less than PPM itself contributes but not negligible either.
The auxiliary loss weight was tested as well (Table 2 of the paper). Without it the score is 35.82; of 0.3, 0.4, 0.6 and 0.9 gives 37.01, 37.23, 37.09 and 36.99, all four better than none, with 0.4 the best. The differences are small, so any moderate value will do.
The Challenge and the Benchmarks
The ImageNet Scene Parsing Challenge scores entries by the average of mIoU and pixel accuracy. PSPNet's ensemble scored 57.21% on the test set, taking first place; the single model scored 55.38%, already above some other teams' ensemble results.
On the PASCAL VOC 2012 test set (Table 6 of the paper), the authors use ResNet101 with no CRF, only multi-scale averaging:
- Trained on VOC only: 82.6%, first in all 20 classes. DeepLab v1 from the previous note scored 71.6%, and CRF-RNN 72.0%.
- Pretrained on COCO first: 85.4%, first in 19 classes. DeepLab v2, also with ResNet101, scored 79.7%, and that was with a CRF attached.
PSPNet trained on VOC alone already beats every older method pretrained on COCO.
On the Cityscapes test set (Table 7 of the paper), training on the fine annotations only gives 78.4%, and adding the twenty thousand coarsely annotated images gives 80.2%; DeepLab v2, also trained on fine annotations only, scores 70.4%.
Unanswered Questions
The paper says PPM "does not much increase" the computation relative to dilated FCN, yet gives no speed or memory numbers at all. The real cost actually sits in the backbone. With the last two downsamplings removed, ResNet's fourth stage goes from stride 16 to 8, quadrupling the feature map area, and the fifth stage goes from stride 32 to 8, a 16-fold increase in area, with computation growing roughly in step. This is a cost every dilated backbone shares rather than one PPM causes, but you have to factor it in when deploying PSPNet.
Also, the bin counts in PPM (1, 2, 3, 6) were found by trial; the paper only says that the number of levels and their sizes "are related to the size of the input feature map" and should keep a reasonable gap. Later work such as ACE also pointed out that both PPM and DeepLab's ASPP sample within fixed rectangular regions, which often mix pixels of different classes.
The ADE20K test-set scores are also noticeably lower than the validation scores; the authors guess the two sets have different data distributions and leave it at that.
Conclusion
A car on a river, half a skyscraper, a pillow swallowed by a bed; PSPNet traces all these mistakes to one cause, which is that FCN can't see the whole image. Its fix is four levels of average pooling plus dimension reduction, handing the classifier both "what the whole image is about" and "what's nearby" with very few parameters, for 4.45 points over the baseline on ADE20K.
PPM is only twenty lines of code and works with any backbone; to give your own model global context, attach it after the backbone and you're done. The auxiliary loss works the same way, with one extra head during training that you remove at test time.
Before you transplant it, take a look at BN first. The paper tucks "BN's batch size matters a lot" into the middle of its implementation details, where it's easy to skip; MMSegmentation later simply put SyncBN on the first line of its PSPNet config files.