Bayesian SegNet: Model Uncertainty in Deep Convolutional Encoder-Decoder Architectures for Scene Understanding

Alex Kendall, Vijay Badrinarayanan, Roberto Cipolla

Introduction

Semantic segmentation requires an understanding of an image at a pixel level and is an important tool for scene understanding. It is a difficult problem as scenes often vary significantly in pose and appearance. However it is an important problem as it can be used to infer scene geometry and object support relationships. This has wide ranging applications from robotic interaction to autonomous driving.

Previous approaches to scene understanding used low level visual features . We are now seeing the emergence of machine learning techniques for this problem . In particular deep learning has set the benchmark on many popular datasets . However none of these deep learning methods produce a probabilistic segmentation with a measure of model uncertainty.

Uncertainty should be a natural part of any predictive system’s output. Knowing the confidence with which we can trust the semantic segmentation output is important for decision making. For instance, a system on an autonomous vehicle may segment an object as a pedestrian. But it is desirable to know the model uncertainty with respect to other classes such as street sign or cyclist as this can have a strong effect on behavioural decisions. Uncertainty is also immediately useful for other applications such as active learning , semi-supervised learning, or label propagation .

The main contribution of this paper is extending deep convolutional encoder-decoder neural network architectures to Bayesian convolutional neural networks which can produce a probabilistic segmentation output . In Section 4 we propose Bayesian SegNet, a probabilistic deep convolutional neural network framework for pixel-wise semantic segmentation. We use dropout at test time which allows us to approximate the posterior distribution by sampling from the Bernoulli distribution across the network’s weights. This is achieved with no additional parameterisation.

In Section 5, we demonstrate that Bayesian SegNet sets the best performing benchmark on prominent scene understanding datasets, CamVid Road Scenes and SUN RGB-D Indoor Scene Understanding . In particular, we find a larger performance improvement on smaller datasets such as CamVid where the Bayesian Neural Network is able to cope with the additional uncertainty from a smaller amount of data.

Moreover, we show in section 5.4 that this technique is broadly applicable across a number of state of the art architectures and achieves a 2-3% improvement in segmenation accuracy when applied to SegNet , FCN and Dilation Network .

Finally in Section 5.5 we demonstrate the effectiveness of model uncertainty. We show this measure can be used to understand with what confidence we can trust image segmentations. We also explore what factors contribute to Bayesian SegNet making an uncertain prediction.

Related Work

Semantic pixel labelling was initially approached with TextonBoost , TextonForest and Random Forest Based Classifiers . We are now seeing the emergence of deep learning architectures for pixel wise segmentation, following its success in object recognition for a whole image . Architectures such as SegNet Fully Convolutional Networks (FCN) and Dilation Network have been proposed, which we refer to as the core segmentation engine. FCN is trained using stochastic gradient descent with a stage-wise training scheme. SegNet was the first architecture proposed that can be trained end-to-end in one step, due to its lower parameterisation.

We have also seen methods which improve on these core segmentation engine architectures by adding post processing tools. HyperColumn and DeConvNet use region proposals to bootstrap their core segmentation engine. DeepLab post-processes with conditional random fields (CRFs) and CRF-RNN use recurrent neural networks. These methods improve performance by smoothing the output and ensuring label consistency. However none of these proposed segmentation methods generate a probabilistic output with a measure of model uncertainty.

Neural networks which model uncertainty are known as Bayesian neural networks . They offer a probabilistic interpretation of deep learning models by inferring distributions over the networks’ weights. They are often computationally very expensive, increasing the number of model parameters without increasing model capacity significantly. Performing inference in Bayesian neural networks is a difficult task, and approximations to the model posterior are often used, such as variational inference .

On the other hand, the already significant parameterization of convolutional network architectures leaves them particularly susceptible to over-fitting without large amounts of training data. A technique known as dropout is commonly used as a regularizer in convolutional neural networks to prevent overfitting and co-adaption of features . During training with stochastic gradient descent, dropout randomly removes units within a network. By doing this it samples from a number of thinned networks with reduced width. At test time, standard dropout approximates the effect of averaging the predictions of all these thinnned networks by using the weights of the unthinned network. This is referred to as weight averaging.

Gal and Ghahramani have cast dropout as approximate Bayesian inference over the network’s weights. shows that dropout can be used at test time to impose a Bernoulli distribution over the convolutional net filter’s weights, without requiring any additional model parameters. This is achieved by sampling the network with randomly dropped out units at test time. We can consider these as Monte Carlo samples obtained from the posterior distribution over models. This technique has seen success in modelling uncertainty for camera relocalisation . Here we apply it to pixel-wise semantic segmentation.

We note that the probability distribution from Monte Carlo sampling is significantly different to the ‘probabilities’ obtained from a softmax classifier. The softmax function approximates relative probabilities between the class labels, but not an overall measure of the model’s uncertainty . Figure 3 illustrates these differences.

SegNet Architecture

We briefly review the SegNet architecture which we modify to produce Bayesian SegNet. SegNet is a deep convolutional encoder decoder architecture which consists of a sequence of non-linear processing layers (encoders) and a corresponding set of decoders followed by a pixel-wise classifier. Typically, each encoder consists of one or more convolutional layers with batch normalisation and a ReLU non-linearity, followed by non-overlapping max-pooling and sub-sampling. The sparse encoding due to the pooling process is upsampled in the decoder using the max-pooling indices in the encoding sequence. This has the important advantage of retaining class boundary details in the segmented images and also reducing the total number of model parameters. The model is trained end to end using stochastic gradient descent.

We take both SegNet and a smaller variant termed SegNet-Basic as our base models. SegNet’s encoder is based on the 13 convolutional layers of the VGG-16 network followed by 13 corresponding decoders. SegNet-Basic is a much smaller network with only four layers each for the encoder and decoder with a constant feature size of 64. We use SegNet-Basic as a smaller model for our analysis since it conceptually mimics the larger architecture.

Bayesian SegNet

The technique we use to form a probabilistic encoder-decoder architecture is dropout , which we use as approximate inference in a Bayesian neural network . We can therefore consider using dropout as a way of getting samples from the posterior distribution of models. Gal and Ghahramani link this technique to variational inference in Bayesian convolutional neural networks with Bernoulli distributions over the network’s weights. We leverage this method to perform probabilistic inference over our segmentation model, giving rise to Bayesian SegNet.

For Bayesian SegNet we are interested in finding the posterior distribution over the convolutional weights, W\mathbf{W}, given our observed training data X\mathbf{X} and labels Y\mathbf{Y}.

In general, this posterior distribution is not tractable, therefore we need to approximate the distribution of these weights . Here we use variational inference to approximate it . This technique allows us to learn the distribution over the network’s weights, q(W)q(\mathbf{W}), by minimising the Kullback-Leibler (KL) divergence between this approximating distribution and the full posterior;

Here, the approximating variational distribution q(Wi)q(\mathbf{W_{i}}) for every K×KK\times K dimensional convolutional layer ii, with units jj, is defined as:

with bib_{i} vectors of Bernoulli distributed random variables and variational parameters Mi\mathbf{M_{i}} we obtain the approximate model of the Gaussian process in . The dropout probabilities, pip_{i}, could be optimised. However we fix them to the standard probability of dropping a connection as 50%, i.e. pi=0.5p_{i}=0.5 .

In it was shown that minimising the cross entropy loss objective function has the effect of minimising the Kullback-Leibler divergence term. Therefore training the network with stochastic gradient descent will encourage the model to learn a distribution of weights which explains the data well while preventing over-fitting.

We train the model with dropout and sample the posterior distribution over the weights at test time using dropout to obtain the posterior distribution of softmax class probabilities. We take the mean of these samples for our segmentation prediction and use the variance to output model uncertainty for each class. We take the mean of the per class variance measurements as an overall measure of model uncertainty. We also explored using the variation ratio as a measure of uncertainty (i.e. the percentage of samples which agree with the class prediction) however we found this to qualitatively produce a more binary measure of model uncertainty. Fig. 2 shows a schematic of the segmentation prediction and model uncertainty estimate process.

A fully Bayesian network should be trained with dropout after every convolutional layer. However we found in practice that this was too strong a regulariser, causing the network to learn very slowly. We therefore explored a number of variants that have different configurations of Bayesian or deterministic encoder and decoder units. We note that an encoder unit contains one or more convolutional layers followed by a max pooling layer. A decoder unit contains one or more convolutional layers followed by an upsampling layer. The variants are as follows:

Bayesian Encoder. In this variant we insert dropout after each encoder unit.

Bayesian Decoder. In this variant we insert dropout after each decoder unit.

Bayesian Encoder-Decoder. In this variant we insert dropout after each encoder and decoder unit.

Bayesian Center. In this variant we insert dropout after the deepest encoder, between the encoder and decoder stage.

Bayesian Central Four Encoder-Decoder. In this variant we insert dropout after the central four encoder and decoder units.

Bayesian Classifier. In this variant we insert dropout after the last decoder unit, before the classifier.

For analysis we use the smaller eight layer SegNet-Basic architecture and test these Bayesian variants on the CamVid dataset . We observe qualitatively that all four variants produce similar looking model uncertainty output. That is, they are uncertain near the border of segmentations and with visually ambiguous objects, such as cyclist and pedestrian classes. However, Table 1 shows a difference in quantitative segmentation performance.

We observe using dropout after all the encoder and decoder units results in a lower training fit and poorer test performance as it is too strong a regulariser on the model. We find that dropping out half of the encoder or decoder units is the optimal configuration. The best configuration is dropping out the deepest half of the encoder and decoder units. We therefore benchmark our Bayesian SegNet results on the Central Enc-Dec variant. For the full 26 layer Bayesian SegNet, we add dropout to the central six encoders and decoders. This is illustrated in Fig. 2.

In the lower layers of convolutional networks basic features are extracted, such as edges and corners . These results show that applying Bayesian weights to these layers does not result in a better performance. We believe this is because these low level features are consistent across the distribution of models because they are better modelled with deterministic weights. However, the higher level features that are formed in the deeper layers, such as shape and contextual relationships, are more effectively modelled with Bayesian weights.

2 Comparing Weight Averaging and Monte Carlo Dropout Sampling

Monte Carlo dropout sampling qualitatively allows us to understand the model uncertainty of the result. However, for segmentation, we also want to understand the quantitative difference between sampling with dropout and using the weight averaging technique proposed by . Weight averaging proposes to remove dropout at test time and scale the weights proportionally to the dropout percentage. Fig. 4 shows that Monte Carlo sampling with dropout performs better than weight averaging after approximately 6 samples. We also observe no additional performance improvement beyond approximately 40 samples. Therefore the weight averaging technique produces poorer segmentation results, in terms of global accuracy, in addition to being unable to provide a measure of model uncertainty. However, sampling comes at the expense of inference time, but when computed in parallel on a GPU this cost can be reduced for practical applications.

3 Training and Inference

Following we train SegNet with median frequency class balancing using the formula proposed by Eigen and Fergus . We use batch normalisation layers after every convolutional layer . We compute batch normalisation statistics across the training dataset and use these at test time. We experimented with computing these statistics while using dropout sampling. However we experimentally found that computing them with weight averaging produced better results.

We implement Bayesian SegNet using the Caffe library and release the source code and trained models for public evaluation An online demo and source code can be found on our project webpage mi.eng.cam.ac.uk/projects/segnet/. We train the whole system end-to-end using stochastic gradient descent with a base learning rate of 0.001 and weight decay parameter equal to 0.0005. We train the network until convergence when we observe no further reduction in training loss.

Experiments

We quantify the performance of Bayesian SegNet on three different benchmarks using our Caffe implementation. Through this process we demonstrate the efficacy of Bayesian SegNet for a wide variety of scene segmentation tasks which have practical applications. CamVid is a road scene understanding dataset which has applications for autonomous driving. SUN RGB-D is a very challenging and large dataset of indoor scenes which is important for domestic robotics. Finally, Pascal VOC 2012 is a RGB dataset for object segmentation.

CamVid is a road scene understanding dataset with 367 training images and 233 testing images of day and dusk scenes . The challenge is to segment 1111 classes such as road, building, cars, pedestrians, signs, poles, side-walk etc. We resize images to 360x480 pixels for training and testing of our system.

Table 2 shows our results and compares them to previous benchmarks. We compare to methods which utilise depth and motion cues. Additionally we compare to other prominent deep learning architectures. Bayesian SegNet obtains the highest overall class average and mean intersection over union score by a significant margin. We set a new benchmark on 7 out of the 11 classes. Qualitative results can be viewed in Fig. 6.

2 Scene Understanding (SUN)

SUN RGB-D is a very challenging and large dataset of indoor scenes with 52855285 training and 50505050 testing images. The images are captured by different sensors and hence come in various resolutions. The task is to segment 3737 indoor scene classes including wall, floor, ceiling, table, chair, sofa etc. This task is difficult because object classes come in various shapes, sizes and in different poses with frequent partial occlusions. These factors make this one of the hardest segmentation challenges. For our model, we resize the input images for training and testing to 224x224 pixels. Note that we only use RGB input to our system. Using the depth modality would necessitate architectural modifications and careful post-processing to fill-in missing depth measurements. This is beyond the scope of this paper.

Table 3 shows our results on this dataset compared to other methods. Bayesian SegNet outperforms all previous benchmarks, including those which use depth modality. We also note that an earlier benchmark dataset, NYUv2 , is included as part of this dataset, and Table 4 shows our evaluation on this subset. Qualitative results can be viewed in Fig. 6.

3 Pascal VOC

The Pascal VOC12 segmentation challenge consists of segmenting a 20 salient object classes from a widely varying background class. For our model, we resize the input images for training and testing to 224x224 pixels. We train on the 12031 training images and 1456 testing images, with scores computed remotely on a test server. Table 5 shows our results compared to other methods, with qualitative results in Fig. 9.

This dataset is unlike the segmentation for scene understanding benchmarks described earlier which require learning both classes and their spatial context. A number of techniques have been proposed based on this challenge which are increasingly more accurate and complex See the full leader board at http://host.robots.ox.ac.uk:8080/leaderboard. Our efforts in this benchmarking experiment have not been diverted towards attaining the top rank by either using multi-stage training , other datasets for pre-training such as MS-COCO , training and inference aids such as object proposals or post-processing using CRF based methods . Although these supporting techniques clearly have value towards increasing the performance it unfortunately does not reveal the true performance of the deep architecture which is the core segmentation engine. It however does indicate that some of the large deep networks are difficult to train end-to-end on this task even with pre-trained encoder weights. Therefore, to encourage more controlled benchmarking, we trained Bayesian SegNet end-to-end without other aids and report this performance.

4 General Applicability

To demonstrate the general applicability of this method, we also apply it to other deep learning architectures trained with dropout; FCN and Dilation Network . We select these state-of-the-art methods as they are already trained by their respective authors using dropout. We take their trained open source models off the shelf, and evaluate them using 50 Monte Carlo dropout samples. Table 5 shows the mean IoU result of these methods evaluated as Bayesian Neural Networks, as computed by the online evaluation server.

This shows the general applicability of our method. By leveraging this underlying Bayesian framework our method obtains 2-3% improvement across this range of architectures.

5 Understanding Model Uncertainty

Qualitative observations. Fig. 6 shows segmentations and model uncertainty results from Bayesian SegNet on CamVid Road Scenes . Fig. 6 shows SUN RGB-D Indoor Scene Understanding results and Fig. 9 has Pascal VOC results. These figures show the qualitative performance of Bayesian SegNet. We observe that segmentation predictions are smooth, with a sharp segmentation around object boundaries. These results also show that when the model predicts an incorrect label, the model uncertainty is generally very high. More generally, we observe that a high model uncertainty is predominantly caused by three situations.

Firstly, at class boundaries the model often displays a high level of uncertainty. This reflects the ambiguity surrounding the definition of defining where these labels transition. The Pascal results clearly illustrated this in Fig. 9.

Secondly, objects which are visually difficult to identify often appear uncertain to the model. This is often the case when objects are occluded or at a distance from the camera.

The third situation causing model uncertainty is when the object appears visually ambiguous to the model. As an example, cyclists in the CamVid results (Fig. 6) are visually similar to pedestrians, and the model often displays uncertainty around them. We observe similar results with visually similar classes in SUN (Fig. 6) such as chair and sofa, or bench and table. In Pascal this is often observed between cat and dog, or train and bus classes.

Quantitative observations. To understand what causes the model to be uncertain, we have plotted the relationship between uncertainty and accuracy in Fig. 7 and between uncertainty and the frequency of each class in the dataset in Fig. 8. Uncertainty is calculated as the mean uncertainty value for each pixel of that class in a test dataset. We observe an inverse relationship between uncertainty and class accuracy or class frequency. This shows that the model is more confident about classes which are easier or occur more often, and less certain about rare and challenging classes.

Additionally, Table 6 shows segmentation accuracies for varying levels of confidence. We observe very high levels of accuracy for values of model uncertainty above the 90th percentile across each dataset. This demonstrates that the model’s uncertainty is an effective measure of confidence in prediction.

6 Real Time Performance

Table 5 shows that SegNet and Bayesian SegNet maintains a far lower parameterisation than its competitors. Monte Carlo sampling requires additional inference time, however if model uncertainty is not required, then the weight averaging technique can be used to remove the need for sampling (Fig. 4 shows the performance drop is modest). Our implementation can run SegNet at 35ms per frame and Bayesian SegNet with 10 Monte Carlo samples at 90ms per frame on Titan X GPU. However inference time will depend on the implementation.

Conclusions

We have presented Bayesian SegNet, the first probabilistic framework for semantic segmentation using deep learning, which outputs a measure of model uncertainty for each class. We show that the model is uncertain at object boundaries and with difficult and visually ambiguous objects. We quantitatively show Bayesian SegNet produces a reliable measure of model uncertainty and is very effective when modelling smaller datasets. Bayesian SegNet outperforms shallow architectures which use motion and depth cues, and other deep architectures. We obtain the highest performing result on CamVid road scenes and SUN RGB-D indoor scene understanding datasets. We show that the segmentation model can be run in real time on a GPU. For future work we intend to explore how video data can improve our model’s scene understanding performance.

References