TL;DR
Most segmentation systems before this paper labelled each pixel by cutting the image into patches, running a network on each patch, and adding post-processing. The authors show that a classification network with its fully connected layers rewritten as convolutions can take an image of any size and output a map of predictions, and that it can be trained end to end on whole images. They then fuse predictions from earlier, finer layers into the last, coarse one. On PASCAL VOC 2012 the resulting FCN-8s reaches 62.2 mean intersection over union on the test set, and the paper reports a 20% relative gain over the previous best system.
Builds on: Fully Convolutional Network, Image Segmentation, Fine-Tuning, Very Deep Convolutional Networks for Large-Scale Image Recognition (VGG) · Leads to: U-Net and later encoder-decoder segmentation networks
Why it mattered
The paper made dense prediction with a convolutional network the default approach for semantic segmentation. The architecture is an encoder that reduces resolution, followed by an upsampling decoder with skip connections, and this pattern reappears in later segmentation models such as U-Net. Because the network runs on a whole image at once, inference on a typical image took about 175 ms on the authors' GPU, against about 50 seconds for the previous best system, SDS, which relied on region proposals. That speed made dense labelling practical for images at full size.
The problem
Semantic segmentation asks for a class at every pixel. A classifier that reads a whole image answers "what is here"; segmentation also needs "where". The paper states the tension directly: global information resolves what, local information resolves where.
Before this work, convolutional segmentation systems had three costs. They were usually trained patch by patch, which repeats computation over overlapping patches. They relied on pre- and post-processing such as superpixels, object proposals or random fields. And many used small networks trained without the large-scale supervised pretraining that had made classification work. Classification networks such as AlexNet and VGG were available, but their fixed-size input and their final fully connected layers seemed to rule out dense outputs.
The authors' question is therefore: can an ordinary classification network, adapted with minimal machinery, be trained end to end for pixel prediction and still beat systems that use proposals and refinement?
How it works
The pipeline has three stages: convert the classifier, upsample its coarse output, and fuse coarse and fine layers.
flowchart LR I[Image of any size] --> C[Convolutional layers and pooling] C -->|stride 32| P5[Coarse scores] C -->|stride 16| P4[pool4 scores] C -->|stride 8| P3[pool3 scores] P5 -->|2x upsample and sum| F1[Fused stride 16] P4 --> F1 F1 -->|2x upsample and sum| F2[Fused stride 8] P3 --> F2 F2 -->|upsample to input size| O[Per-pixel classes]
- Input. A whole image, for example a 320 by 320 pixel photograph. Nothing forces it to a fixed size.
- Convolutionalise the classifier. Take a classification network such as VGG-16. Replace each fully connected layer with a convolution whose kernel covers the whole region the layer used to see. The network now slides over the image and produces a grid of class scores instead of one vector. With a stride of 32 in the pooling layers, a 320 by 320 image gives a 10 by 10 grid, since .
- Predict classes at the coarse grid. Add a 1 by 1 convolution with 21 output channels: 20 PASCAL classes plus background. Each of the 10 by 10 cells now holds 21 scores.
- Upsample to pixels. A learned upsampling layer, initialised to bilinear interpolation, stretches the coarse grid back to 320 by 320. This is the in-network upsampling that makes the whole system trainable by backpropagation.
- Fuse finer layers (FCN-16s and FCN-8s). Predict classes also from the stride-16 pool4 layer and add them to the upsampled stride-32 prediction. The grid is now 20 by 20. Repeat with pool3 at stride 8 to get FCN-8s.
- Train. The loss is a per-pixel multinomial logistic loss summed over the spatial grid. Training runs on whole images with stochastic gradient descent, fine-tuning all layers from ImageNet weights.
A two-line check. After step 2 the grid is smaller than the image by the stride. After step 5 the fused grid is twice as fine as the coarse one, so the final upsampling factor drops from 32 to 8.
The math
Each layer computes a local function of a neighbourhood. For location in one layer, the output depends only on inputs near , where is the stride:
Here is the kernel size, is the stride, and is the layer type: a matrix product for convolution, a maximum for max pooling, or an elementwise nonlinearity. Because each layer is built this way, a whole network of such layers is also a local function, and it accepts any input size. The paper gives the rule for stacking two layers:
Read it as: the composed kernel covers input positions, and the composed stride is .
Step 2 in symbols: the grid size
If the total stride of the network is and the input has rows, the coarse grid has about rows. For a 320-pixel input and , . The fused FCN-16s grid uses , so it has rows, and FCN-8s uses , so it has rows.
Step 4 in symbols: upsampling as backwards convolution
Upsampling by a factor is treated as a convolution with output stride . Bilinear interpolation is one choice of weights, and the paper learns them during training. Only the initialisation is fixed to bilinear.
Step 6 in symbols: the training loss and metric
The loss sums a per-pixel loss over the spatial grid, so the gradient of the whole-image loss equals the sum of the gradients for every output location. The evaluation metric is mean intersection over union. Let be the number of pixels of true class predicted as class , and the number of pixels of true class . Then
where is the number of classes. The denominator is the size of the union of the true region and the predicted region for class .
Worked examples
- Four pixels, two classes: background (B) and cat (C). Ground truth: B, B, C, C. Prediction: B, C, C, C.
- Count the confusion entries. (true B predicted B), (true B predicted C), , .
- Pixel accuracy: .
- Class B: , . IU is .
- Class C: , . IU is .
- Mean IU: .
- Interpretation: pixel accuracy is 0.75, but mean IU is lower because each class is judged by its union, and the one wrong pixel costs the background class more than pixel accuracy suggests.
- From Table 2 on the PASCAL VOC 2011 validation subset, FCN-32s (the coarse, stride 32 network) scores 59.4 mean IU.
- Adding the stride-16 pool4 predictions gives FCN-16s at 62.4. The gain is points.
- Adding the stride-8 pool3 predictions gives FCN-8s at 62.7. The further gain is points.
- Compare the gains: the first fusion adds 3.0 points and the second adds 0.3. The paper says the second step has reached diminishing returns on this metric.
- Interpretation: fusing a finer layer helps most when the coarse output is too blurry; after that, the metric changes little, though the outlines in Figure 4 still improve.
- The paper reports FCN-8s at 62.2 mean IU on VOC 2012 test, against 51.6 for SDS, the previous best system.
- Absolute difference: points.
- Relative gain: , so about 20%, which matches the paper's claim.
- Inference time: about 175 ms for FCN-8s against about 50 s for SDS. The ratio is , so FCN-8s is roughly 280 times faster by these two figures.
- Interpretation: end-to-end training matters. The paper's ablation shows that training only the last layer is far weaker: FCN-32s-fixed scores 45.4, against 59.4 for end-to-end training.
- Try it: on the 4-pixel toy image, if the model predicts C, C, C, C, what is the mean IU? Answer: class B has IU because . Class C has , , , so IU is . Mean IU is .
Results
All numbers below are taken from the paper's text and tables.
- PASCAL VOC 2011 test (Table 3): FCN-8s reaches 62.7 mean IU, against 52.6 for SDS and 47.9 for R-CNN. Inference takes about 175 ms against about 50 s for SDS.
- PASCAL VOC 2012 test: FCN-8s reaches 62.2 mean IU, against 51.6 for SDS.
- Validation ablation (Table 2): FCN-32s with only the last layer fine-tuned scores 45.4, and FCN-32s with end-to-end training scores 59.4. FCN-16s scores 62.4 and FCN-8s 62.7.
- Backbones (Table 1): on the validation set, FCN-VGG16 gets 56.0 mean IU, FCN-GoogLeNet 42.5 and FCN-AlexNet 39.8, before the skip fusion. The VGG version has 134M parameters and 210 ms forward time on the authors' GPU.
- NYUDv2 (Table 4): the RGB-HHA two-stream FCN-16s reaches 34.0 mean IU, against 28.6 for Gupta et al.
- SIFT Flow (Table 5): FCN-16s reaches 39.5 mean IU and 85.2 pixel accuracy on the class task, with a two-headed network that also predicts geometry.
- PASCAL-Context (Appendix B): FCN-8s reaches 35.1 mean IU on the 59-class task, the paper's 11% relative gain over the previous best.
- Ceiling (Appendix A): downsampling ground truth by 32 and upsampling it back gives an approximate upper bound of 86.1 mean IU. The paper uses such bounds to show the limits of the metric at coarse scales.
Limits. The best FCN-8s numbers use the VGG-16 backbone, which is slow to train: the paper says fine-tuning FCN-32s took three days on one GPU. Fine-tuning only the classifier reaches 70% of the full fine-tuning performance. Shift-and-stitch gave a worse cost-to-improvement ratio than fusion, and reducing the pooling stride needed a 14 by 14 kernel that was hard to learn. Mean IU emphasises large regions, so thin structures can score little while the metric barely moves. Augmentation by mirroring and jitter gave no noticeable gain in the paper's experiments.
Reading guide
- Section 1 (Introduction): the what-versus-where tension and the three costs of earlier methods. Needs Image Segmentation.
- Section 2 (Related work): earlier convolutional segmentation and transfer. Needs Convolutional Neural Network.
- Section 3 (Fully convolutional networks): receptive fields, the layer rule, and the composition formula. Needs Receptive Field and Fully Convolutional Network.
- Section 3.1 to 3.3: converting classifiers, shift-and-stitch, and upsampling by backwards convolution. Needs Bilinear Interpolation and Max Pooling.
- Section 3.4 (Patchwise training): why whole-image training is equivalent to sampling a loss. Needs Backpropagation.
- Section 4 (Segmentation architecture): the VGG, AlexNet and GoogLeNet adaptations, the skip fusion and the training framework. Needs Very Deep Convolutional Networks for Large-Scale Image Recognition (VGG), Fine-Tuning and Cross-Entropy Loss.
- Section 5 (Results) and Appendices: the metrics, the benchmarks and the upper-bound study. The metric formulas are the ones in The math above.
Check yourself
QuestionWhy can a network built only from convolution, pooling and activation layers accept an image of any size?Show answer
Each layer computes the same local function at every location, depending only on a neighbourhood of relative positions. Nothing in the layer fixes the input's height or width, so the output simply has a grid whose size follows the input's size divided by the total stride.
QuestionA 480 by 640 image goes through a network with total stride 32. What is the size of the coarse output grid?Show answer
Height and width , so the grid is 15 by 20. This assumes the sizes divide evenly; the paper's timing experiments in Table 1 use a 500 by 500 input.
QuestionIn the 4-pixel toy image, the truth is B, B, C, C and the prediction is B, C, C, C. What is pixel accuracy?Show answer
Three of four pixels are correct, so pixel accuracy is .
QuestionWhy did the authors fuse the pool4 layer into the prediction rather than only decreasing the pooling stride?Show answer
Decreasing the pooling stride in VGG-16 required a very large 14 by 14 kernel in fc6 to keep the receptive field, which was costly and hard to learn. Fusing a stride-16 layer gave a finer prediction at lower cost and raised validation mean IU from 59.4 to 62.4.
QuestionThe paper reports 62.2 mean IU for FCN-8s on VOC 2012 and 51.6 for SDS. Is the 20% relative gain consistent with those numbers?Show answer
Yes. The gain is , so the paper's claim of about 20% holds for this comparison.
Sources
- Long, J., Shelhamer, E., and Darrell, T. (2014). Fully Convolutional Networks for Semantic Segmentation. arXiv:1411.4038. https://arxiv.org/abs/1411.4038
- Caffe model zoo entry for the FCN models: https://github.com/BVLC/caffe/wiki/Model-Zoo#fcn