SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation
- Publication
- IEEE Transactions on Pattern Analysis and Machine Intelligence 2017Journal
- First submitted to arXiv
- arXiv:1511.00561
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{segmentationsegnet2015,
title = {{SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation}},
author = {Vijay Badrinarayanan and Alex Kendall and Roberto Cipolla},
year = {2015},
eprint = {1511.00561},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1511.00561}
}
In 2015, FCN showed that once a classification network drops its fully connected layers, it can output a class for every pixel directly. The next problem was that the output was too coarse.
After five rounds of pooling, VGG16's feature map is only 1/32 of the input. FCN upsamples from this small map and adds shallow features back in to recover detail. It works, but at inference the shallow features have to sit in memory the whole time, waiting for the decoder to pick them up.
Vijay Badrinarayanan and Alex Kendall, from Roberto Cipolla's lab at the University of Cambridge, wanted to put segmentation networks into cars and AR devices. They cared about accuracy, and also about memory at inference. So they wanted to save a little. When upsampling, do you really need the whole shallow feature map? Would it be enough to remember just "where the maximum originally was"?
Defining the Problem
Max pooling in classification networks has its reasons. Each 2×2 window keeps only its maximum, so if an object shifts by a pixel or two, the output barely changes; after several rounds of pooling, every pixel in the deep layers sees a large patch of the input.
For segmentation, both benefits come at a price. Translation invariance means position information is thrown away, and downsampling means boundaries get blurred. And segmentation, of all tasks, most needs to know where the boundaries are.
The authors observed that the segmentation networks of the time almost all used the same encoder, VGG16's convolutional layers, and differed entirely in the decoder, that is, in how they restored the large map from the small one. Yet these networks also leaned on a pile of extra tricks at the same time:
- FCN's encoder has 134 million parameters, its decoder only 500,000. It couldn't be trained end to end, so decoders had to be added one stage at a time and trained in stages.
- DeconvNet kept VGG's fully connected layers (about 90% of the whole network's parameters), which made it hard to train, and at inference it also needed region proposals.
- DeepLab and CRF-RNN attach a CRF after the network to refine the boundaries.
Each paper reported results with different training pipelines, post-processing and extra data, so it was hard to tell which decoder design actually helped. The authors even believed that the gains CRFs brought came precisely from the decoder in front of them not being good enough.
So this paper sets out to do two things: design a decoder that saves memory at inference and can be trained end to end, and then compare several decoders side by side under the same training conditions.
Solving the Problem
Overall Architecture

SegNet's encoder is simply the first 13 convolutional layers of VGG16, untouched, so it can load ImageNet-pretrained weights directly. VGG16's three fully connected layers at the end are removed, which cuts the parameter count from 134 million to 14.7 million.
Each encoder block runs convolution, BatchNorm and ReLU, followed by a 2×2 max pooling with stride 2 that halves the feature map's height and width.
The decoders match the encoders one to one, also 13 layers. Each decoder first upsamples its input by 2×, then uses learnable convolutions to fill it into a dense feature map. The last decoder's output goes into a softmax that classifies each pixel independently, giving probabilities for classes.
The whole network has no fully connected layers and no connections that pass feature maps directly from encoder to decoder. The only link between encoder and decoder is those few "Pooling Indices" arrows in the figure.
How the Pooling Indices Are Used
When pooling, each 2×2 window keeps just one maximum. At this step SegNet also notes where in the window that maximum originally sat, and stores it for the corresponding decoder.
When the decoder upsamples, it puts each value back in its original position and fills the other three cells with 0.
PyTorch happens to have ready-made layers to demonstrate this. Take a 4×4 feature map through them:
import torch
import torch.nn as nn
x = torch.tensor([[[[1., 5., 2., 0.],
[3., 4., 8., 1.],
[0., 2., 6., 7.],
[9., 1., 3., 4.]]]])
pool = nn.MaxPool2d(2, stride=2, return_indices=True)
unpool = nn.MaxUnpool2d(2, stride=2)
y, idx = pool(x)
# y = [[5, 8],
# [9, 7]]
# idx = [[ 1, 6],
# [12, 11]] flattened positions of the maxima on the 4×4 map
up = unpool(y, idx)
# up = [[0, 5, 0, 0],
# [0, 0, 8, 0],
# [0, 0, 0, 7],
# [9, 0, 0, 0]]
The top-left window is [1, 5; 3, 4], and its maximum, 5, sits in the first row, second column; after upsampling, 5 goes back to that cell and the rest are filled with 0. The bottom-right window's maximum, 7, was originally in its top-right corner, and after upsampling it returns to the top-right corner as well.
This upsampling step involves no learning at all and has no parameters. But three quarters of the resulting map is 0, which is very sparse. So a few learnable convolution layers follow to spread these scattered values into dense features.
What does this buy? The authors list three points:
- More accurate boundaries. This is the authors' claim; intuitively, max pooling picks the strongest response in the window, so putting the value back in place keeps a bit of spatial detail.
- Fewer parameters. The upsampling needs no learning, and the network can be trained end to end.
- Easy to transplant. Any encoder–decoder architecture can switch to this kind of upsampling, as long as its encoder uses max pooling.
As for memory, a 2×2 window has only four positions, so in principle 2 bits are enough to remember where the maximum was; a feature map of the same size stored as 32-bit floats needs 32 bits per value, 16 times as much. The paper estimates that the 64 feature maps of 180×240 that FCN-Basic must keep for its first layer alone take 11MB.
How It Differs From the FCN and U-Net Decoders

On the left, SegNet puts a, b, c and d back in place according to the indices, and learning happens only in the convolutions after upsampling. On the right, in FCN the upsampling itself is learned (an 8×8 deconvolution initialized with bilinear interpolation), and the learned is then added to the encoder-side feature map , reduced to channels by a 1×1 convolution. FCN's decoder has no other learnable filters.
The difference lies in what has to be kept at inference. FCN has to hold the whole encoder feature map (even after dimension reduction, that's still channels of floats) until the decoder is done with it; SegNet keeps only the indices.
U-Net sides with FCN, and goes further. It passes the encoder's entire feature map to the decoder untouched and concatenates it with the upsampled result. The price is memory; the benefit is that the decoder gets the most information. U-Net also lacks VGG's fifth convolutional block and fifth pooling, while SegNet uses all 13 layers of VGG's pretrained weights.
DeconvNet's upsampling actually uses pooling indices just like SegNet's, an idea the two groups came up with independently. The difference is that DeconvNet kept VGG's fully connected layers, which add a huge chunk of parameters.
Discussion
Comparing Decoders on a Small Network First
Training the full SegNet takes a long time, so the authors first built a scaled-down SegNet-Basic to compare decoders: only 4 encoders and 4 decoders, 7×7 convolutions in every layer, and a receptive field of about 106×106 pixels at the deepest layer. The decoders have no ReLU, and the convolutions have no bias. As a control, they also built FCN-Basic, which uses the same encoder but swaps in an FCN decoder.
The dataset is CamVid road scenes: 367 training and 233 test images at 360×480 resolution, with 11 classes.
Road, sky and buildings take up most of CamVid's pixels, so training uses median frequency balancing: each class's loss weight is "the median of all class frequencies ÷ that class's frequency." Large classes get weights below 1, and the rarest class gets the highest weight.
For evaluation, besides global accuracy (G, the accuracy over all pixels), class average accuracy (C, the mean of the per-class accuracies) and mIoU, the authors added BF (boundary F1). mIoU favors large smooth regions and ignores how accurate the boundaries are; BF compares the class boundaries of the prediction and the annotation, counts a boundary point as correct within 0.75% of the image diagonal, and then computes F1.
Here are the key variants from the paper's Table 1 (median frequency balancing, test set; "Stored" is what has to be kept at inference, in units of first-layer feature maps):
| Variant | Params | Stored | Inference | mIoU | BF |
|---|---|---|---|---|---|
| Bilinear interpolation | 0.63M | 0 | 24.2ms | 43.3 | 20.8 |
| SegNet-Basic | 1.43M | 1 | 52.6ms | 47.7 | 35.8 |
| FCN-Basic | 0.65M | 11 | 24.2ms | 47.3 | 38.1 |
| FCN-Basic, no encoder features | 0.65M | — | 23.8ms | 44.1 | 32.0 |
| FCN-Basic, no dim. reduction | 1.63M | 64 | 44.8ms | 50.1 | 37.4 |
| SegNet-Basic + encoder features | 1.43M | 64 | 53.0ms | 48.5 | 35.9 |
(Times measured on an NVIDIA Titan; SegNet's upsampling layer has no cuDNN acceleration.)
Reading from the top:
- The decoder has to learn. The version that only upsamples with bilinear interpolation comes last on G, mIoU and BF, with a BF of just 20.8.
- SegNet-Basic and FCN-Basic come out even. mIoU is 47.7 against 47.3, BF 35.8 against 38.1. SegNet keeps only indices at inference, while FCN has to keep 11 channels of feature maps; but SegNet's decoder has 64 channels per layer, more than FCN's 11, so its inference is actually more than twice as slow.
- Encoder information matters. Drop the "add encoder features" step from FCN-Basic and mIoU falls by 3.2, BF by 6. SegNet holds on to part of this information through its indices.
- The more you store, the better. The best performers are FCN-Basic without dimension reduction (storing all 64 channels directly) and SegNet-Basic with encoder features added, and both have to store full feature maps.
The authors' own conclusion here is honest. The best results come from storing the full encoder feature maps, most visibly on the boundary metric BF; only when memory is limited do you settle for second best, storing reduced features or pooling indices paired with a large enough decoder. SegNet positions itself at exactly that compromise.
The authors validated every 1000 iterations and picked the checkpoint with the highest global accuracy rather than the highest class average. Their reason is that road, buildings, sky and sidewalk take up most of the frame and matter most for self-driving; they observed that when class average peaked, the output was often full of noise.
The Same Starting Line
Next comes the comparison of the full SegNet with other architectures. The authors stress that this is a controlled experiment: every model gets BatchNorm after each convolution layer and is trained end to end with the same SGD (learning rate , momentum 0.9) on 360×480 inputs, with no post-processing other than CRF. So that everyone could fit the same batch, DeconvNet's fully connected layers were cut to 1024 dimensions, and DeepLab-LargeFOV's third pooling stride was changed to 1, for a 45×60 output.
The road-scene training data merges four datasets, including CamVid and KITTI, for 3,433 images in total, and this set of experiments uses no class balancing. The authors tested at 40,000 iterations, at 80,000 iterations and at the final iteration, to see how each model changes with training time.
CamVid results at the last test point:
| Model | G | C | mIoU | BF |
|---|---|---|---|---|
| SegNet | 90.4 | 71.2 | 60.1 | 46.8 |
| DeconvNet | 89.6 | 70.2 | 59.8 | 52.2 |
| DeepLab-LargeFOV + CRF | 89.7 | 60.7 | 54.7 | 40.8 |
| DeepLab-LargeFOV | 88.2 | 62.5 | 53.9 | 32.8 |
| FCN (learned deconv) | 83.1 | 64.2 | 52.0 | 33.2 |
(From the paper's Table 3; each model was trained until it stopped improving, 140,000 iterations for SegNet and 260,000 for DeconvNet.)
SegNet and DeconvNet take the top two places. DeconvNet has the best boundaries (BF 52.2), but it needs nearly twice as many iterations to catch up. At the 40,000-iteration point the gap is even clearer, with SegNet's mIoU already at 50.0 and DeconvNet's at only 39.7.
DeepLab-LargeFOV is the smallest and fastest-training model, with decent mIoU but the worst boundaries. With a dense CRF attached, G, mIoU and BF all go up, but class average goes down. The authors mention that the CRF's hyperparameters could only be grid-searched on a subset of the training set, because CamVid has no validation set.

The authors' reading in the caption is that SegNet separates small classes better while staying smooth overall; DeepLab-LargeFOV with a CRF isn't bad, but the small classes get smeared away along with it; and DeconvNet, the largest model and the one trained longest, loses the small classes just the same.
Indoors, Everyone Fails
Indoors, the dataset is SUN RGB-D: 5,285 training and 5,050 test images, 37 classes, RGB only. The authors consider this the hardest setting, with large viewpoint changes, very different object sizes and frequent occlusion.
Every model ends up with an mIoU of only 22 to 32. SegNet is best on G, C and BF, with an mIoU of 31.8, slightly below the smallest model, DeepLab-LargeFOV (32.1). DeepLab with a CRF gets worse on every metric except BF.
The per-class numbers show where the problem lies. Floor is at 93.4% and wall at 83.4%, but desk is at only 11.9%, floor mat at 0% and shower curtain at 0.03%. The large classes are passable; the small, rare ones are almost wiped out.
The authors also offered a guess: the smallest model has the best mIoU, and the larger DeconvNet and FCN gain nothing from longer training, which may point to a bottleneck shared by these VGG-style architectures. They didn't test this guess, only saying that a more controlled dataset is needed.
Saves Memory, Not Time
Last come resources. The authors measured forward and backward time, training and inference memory, and model size with a 360×480 input and batch size 1 (the paper's Table 6):
| Model | Forward | Inference memory | Model size |
|---|---|---|---|
| SegNet | 422.5ms | 1,052MB | 117MB |
| DeepLab-LargeFOV | 110.1ms | 1,993MB | 83MB |
| FCN (learned deconv) | 317.1ms | 1,806MB | 539MB |
| DeconvNet | 474.7ms | 1,872MB | 877MB |
SegNet's inference memory is indeed the lowest, and its model is far smaller than FCN's or DeconvNet's. But its forward time of 422ms is nearly four times DeepLab-LargeFOV's, and slower than FCN's too.
The abstract says SegNet is competitive in inference time (that "competitive" was presumably measured against the even slower DeconvNet) and the most efficient in memory. Read the two claims against this table, and the first one is the looser of the two; the second is where this paper really stands firm.
In the discussion, the authors also admit that even with unified training conditions, there's still no way to fully separate two explanations, "the model is better" and "this optimization setup happens to suit it."
What Stayed Behind
SegNet left one legacy that rarely gets mentioned. The SegNet-Tutorial the authors released along with their code splits CamVid into 367 training, 101 validation and 233 test images, downsampled to 360×480 and merged into 11 classes. This split later became the most common version of CamVid, and quite a few real-time segmentation papers, BiSeNet among them, use the same 367/101/233 split.
Conclusion
SegNet answers a very concrete engineering question. When upsampling feature maps, remembering where each maximum originally was is enough to keep part of the spatial detail with very little memory; under the authors' unified training conditions, it ties with FCN, trains faster than DeconvNet, and has the lowest inference memory of the four models.
But the paper's own experiments also point to the ceiling. Passing the encoder's full feature maps to the decoder gives the best results, especially at the boundaries. Most later segmentation networks took that road; the U-Net family concatenates full features, and DeepLab v3+'s decoder also brings shallow features back in. Pooling indices became the option you reach for only "when memory is really tight."
Reproducing SegNet in PyTorch is easy; MaxPool2d(return_indices=True) plus MaxUnpool2d is all it takes. Just don't expect it to save you memory automatically. Those int64 indices are anything but lean.