## Learning Densities in Feature Space for Reliable Segmentation of Indoor Scenes

Nicolas Marchal , Charlotte Moraldo , Hermann Blum, Roland Siegwart, Cesar Cadena, Abel Gawel ∗ ∗

Abstract -Deep learning has enabled remarkable advances in scene understanding, particularly in semantic segmentation tasks. Yet, current state of the art approaches are limited to a closed set of classes, and fail when facing novel elements, also known as out of distribution (OoD) data. This is a problem as autonomous agents will inevitably come across a wide range of objects, all of which cannot be included during training. We propose a novel method to distinguish any object ( foreground ) from empty building structure ( background ) in indoor environments. We use normalizing flow to estimate the probability distribution of highdimensional background descriptors. Foreground objects are therefore detected as areas in an image for which the descriptors are unlikely given the background distribution. As our method does not explicitly learn the representation of individual objects, its performance generalizes well outside of the training examples. Our model results in an innovative solution to reliably segment foreground from background in indoor scenes, which opens the way to a safer deployment of robots in human environments.

Index Terms -Deep Learning in Robotics and Automation, Semantic Scene Understanding, Visual Learning

## I. INTRODUCTION

D EEP learning methods have allowed significant improvements in computer vision and semantic segmentation tasks in robotic applications [1]. Yet, an important drawback of current Deep Neural Networks trained for classification or segmentation is that they are trained to recognize a fixed set of classes with a limited number of examples. Thus, they behave poorly and unpredictably when they are given out-ofdistribution (OoD) examples [2]-[4]. Moreover, in such cases, networks often give wrong predictions with high confidence. Although a majority of visual recognition systems are designed for a static closed world, these algorithms aim to be deployed in the dynamic and ever-changing real world [5]. The diversity and variability of our world makes algorithms designed to perform static closed set recognition unsafe and limits the deployment of robotic systems in our everyday tasks [6]. This is particularly important in indoor environments, where diverse objects are often added, moved, or altered. Most autonomous robots designed to operate in the presence of humans will be in such settings. In indoor scenes, background consists of the basic room structure (floor, walls, ceiling, windows),

* Authors contributed equally.

Manuscript received: September, 10, 2019; Revised December, 17, 2019; Accepted January, 9, 2020.

This paper was recommended for publication by Editor Eric Marchand upon evaluation of the Associate Editor and Reviewers' comments. This work was partially supported by the HILTI group.

Authors are with the Autonomous Systems Lab, ETH Zurich. { marchaln, moraldoc, rsiegwart, blumh, cesarc, gawela @ethz.ch }

Input image

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00448v4-figure-713c8bfc-591e-4b3b-8d8c-b642e30c9b29.jpg)

FCN probability (baseline)

Normalizing Flow (our approach)

Fig. 1. Example results of the proposed feature density-based segmentation method demonstrating its robustness against out-of-distribution (OoD) data (red dotted circles were added to highlight failures of the baseline FCN softmax method): (a) Advertisement image where part of the chair is missed by the FCN softmax. (b) Picture from Google Image where we add a human (people are not part of our training set). (c) Smartphone picture of a living room: several elements are missed by the FCN softmax.

which remains static. Foreground then contains all the dynamic elements (objects, furniture, people etc.), which are prone to much more variability and novelty. State-of-the-art systems rely on closed-set classification to find potentially dynamic objects [7]. For reliable applications of indoor robotics, it is critical to segment such dynamic or novel elements from the background rather than identifying their nature. Classical semantic segmentation is not well suited for this task as it relies on the strong assumption that all objects in the foreground are known a priori [5]. A good way of separating all dynamic objects from the static background would be to use a reliable binary background-foreground segmentation.

We introduce a novel method to segment foreground from background, without limiting foreground objects to a fixed set. We extract feature descriptors of the background in images with a convolutional neural network (CNN). The descriptors, which are the outputs of some deep layer in the CNN, characterise the background appearance in a high dimensional space with a complex unknown distribution. Leveraging recent advances in flow-based generative models [8]-[10], we use normalizing flow to model this distribution, as done in [11]. Foreground objects are then recognized as having descriptors unlikely to come from the estimated background distribution. The novelty of our method is that the training of the segmentation relies solely on background, which has a low variability.

Its performance is therefore less affected by the high variability of foreground. Moreover our method can segment an unlimited set of objects, as long as their appearance differ from the background. To assess the reliability of our method, we create a dataset containing novel objects, which we coined generalization dataset . The performance drop between the test and generalization datasets on all evaluated metrics is 1.5 to 10 times larger for a classic FCN softmax segmentation compared to our method.

We benchmark our results by comparing them with a kNearest-Neighbours (kNN) kernel density approach and the softmax score of a classical Fully Convolutional Network (FCN) segmentation. Using normalizing flows proved to i) be a completely novel approach to binary semantic segmentation, ii) be more reliable than a classical encoder decoder network with softmax segmentation, iii) be computationally more efficient than kNN and iv) yield better estimates of high dimensional density distributions than kNN.

## II. RELATED WORK

## A. Supervised Semantic Segmentation and Object Detection

Leveraging recent advances in deep learning, state-of-theart methods in semantic segmentation are comprised of fullyconvolutional networks trained with pixelwise supervision [12]. These methods use an encoder-decoder architecture [13], where the role of the decoder network is to map the low resolution encoder features to full input resolution pixelwise classification. In our work, we estimate the probability that the encoder's features were generated by background to create a background likelihood map, which we can then segment to obtain a binary pixelwise semantic segmentation.

Semantic segmentation techniques are commonly used for object detection. For example, Mask R-CNN [14] uses faster R-CNN [15] to generate Regions of Interest (ROIs) likely to contain objects and then predicts per-pixel semantically annotated masks inside all ROIs. [16] uses depth information to refine the predictions of Mask R-CNN and build 3D maps of indoor environments. Our method does not rely on any object detector like faster R-CNN and does not use depth information. [17] remap the 894 labels of NYU into 14 classes (objects, furniture, wall, ceiling etc.) to perform semantic segmentation. This illustrates one of the big drawbacks of classical object detectors: they are limited to a fixed set of classes. In contrast, our method is designed to work with an unlimited number of different foreground objects. Another drawback of classical segmentation methods is that they need a large amount of labeled data, which is expensive and difficult to obtain. Large amounts of labeled data are required for segmentation to capture the variability and complexity in foreground objects. However, since our approach relies solely on background, we need fewer data and we can use images of fully empty rooms which do not need to be labeled.

While a lot of research aims to improve the efficiency of object detection [15] and semantic segmentation, few of them focus on their reliability to OoD data. Moreover, despite the amount of work in object detection and scene understanding, the related problem of detecting all foreground objects has not yet been fully addressed. Our results show that our solution provides a way to increase reliability of binary segmentation networks, allowing better generalization on OoD data.

Background modeling methods have been used in videos, for background removal [18] or object localization [19]. These methods however make use of the movement in videos and are not applicable for object segmentation in single images.

## B. Novelty and Out-of-Distribution (OoD) Detection

Although Bayesian deep learning allows uncertainty representation in settings such as regression or classification [20], [21], non-Bayesian approaches for novelty detection have recently become more popular. [22] for instance combines the k-nearest neighbors algorithm with representations of the data learned by each layer of a neural network to identify Ood data. Computationally more efficient alternatives include density estimation and generative probabilistic modelling methods [4], [9], [10], which allow one to estimate the likelihood of samples with respect to the true data distribution and learn meaningful features while requiring little supervision or labeling. [11] shows great potential in using flow-based approaches [9] to approximate the probability distribution of deep convolutional features to identify OoD data inside images, generating a binary segmentation between known and unknown data. Inspired by these works, we propose a novel application of normalizing flow for reliable segmentation of foreground and background.

## C. Normalizing Flow

The data of interest in deep learning frameworks is generally high-dimensional and highly structured. The challenge in modelling high-dimensional densities for this data is that we need models powerful enough to capture its complexity but yet still be trainable and efficient. Flow-based models, first described in [8] and later improved in [9] and [10] are known for their generative properties but can also be used for efficient and exact computation of high dimensional density functions, using the change of variable formula. We use this tool to estimate the probability distribution of background features.

## III. METHOD

Our work introduces a new way of segmenting background from foreground in indoor scenes. Prior approaches use labeled datasets to learn pixelwise classifications given foreground objects and background scenes in a training set. Although these approaches work well when scenes contain the objects they were trained for, their behavior is unpredictable if we introduce new elements. To tackle this issue, we suggest a different method that learns only the background appearance of indoor rooms. This is done in two steps:

- · We use a CNN, coined expert network , to generate features from images (Section III-A). Our descriptors (or features) are simply the output of a convolution layer in the expert network, and are thus points in a high-dimensional space.
- · We then learn what the background in our training set 'looks like'. To do so, we use normalizing flow [9] to estimate the probability distribution of the background features extracted by the expert network (Section III-B).

(a) Feature extraction: generate background features from indoor images by extracting the output of a convolution layer in the expert network. The 6 th layer is a combination of the 4 th and the (upsampled) 5 th layer.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00448v4-figure-33c4db37-264f-4868-be39-a8c5b4c20766.jpg)

(b) Density estimation: estimate the probability distribution of the background features using normalizing flow

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00448v4-figure-a596d0bf-c877-4dc4-9128-79a6ef4f161c.jpg)

Fig. 2. Illustration of our method where (a) shows how to extract features and (b) shows how to estimate the background likelihood from features.

When feeding an image of dimension H × W × C ( H the height, W the width and C the number of channels) to our network, the expert model transforms it to a feature map of size h × w × f (where, for 2x2 pooling filters, h = H / 2 (# pooling layers) , w = W / 2 (# pooling layers) and f is the feature dimension, which depends on the architecture of the expert model). Using our approximated background feature distribution, we can transform the feature map into a likelihood map of dimension h × w × 1 . We furthermore use bilinear interpolation to upscale the likelihood map back to the original image dimensions ( H × W × 1 ). Foreground objects are detected as areas of low probability in the image and a binary segmentation is obtained by thresholding the density map.

The strength of our method is that it detects foreground objects without ever explicitly learning their appearance. It therefore does not require a training set of foreground elements and does not limit us to recognizing a fixed set of objects. Our complete pipeline is illustrated in Fig. 2.

## A. Feature extraction

1) Collecting background data: Ideally, we would train our network on fully empty rooms, but such a dataset does not exist. Instead, we use a dataset of labeled indoor images (NYU Depth v2 [23]) and generate binary masks to differentiate the background from the foreground. The dataset contains a large number of specific labels, which we map to background or foreground. We define background to be what an empty room would contain (ceiling, floor, wall, window). Any other object is then considered as foreground. With this label mapping, we create a binary mask for each image of the dataset.

2) Expert Network: Our expert network is a fullyconvolutional network (FCN) [12], which consists of a VGG16 encoder [24] followed by a deconvolution. This is a classical architecture for segmentation tasks, which we use in three ways: (i) given the NYU dataset with binary masks as described above, we train this network to perform backgroundforeground segmentation; (ii) we also show that training of the expert model is not necessary by using weights from a standard VGG-16 trained on ImageNet (note that we use the weights from ImageNet for the encoder but we still train the decoder); iii) similarly, we also use weights from an encoder trained for scene parsing on the ADE20K dataset [25]. In this work, we refer to these three approaches as using (i) NYU segmentation, (ii) ImageNet and (iii) ADE20K. Note that these encoders have been trained for different tasks and with different datasets. We discuss their results in sections IV-C and IV-D.

3) Feature Mapping: We extract features from a chosen layer of the expert network. After convolutions and pooling, features from deep layers will have a large receptive field and are thus likely to have been affected by both background and foreground. To determine which label has most influenced the features, we give them a score between 0 and 1: a high score represents a large proportion of background pixels in the receptive field. We then use a threshold to assign the labels 'foreground', 'background' or 'mixed' to all features, as shown on Fig. 2(a). Finally, we discard features with foreground and mixed labels to create a dataset of background features, on which we perform density estimation.

## B. Density Estimation

Given a dataset of background features X , we estimate the probability p X ( x ) of given image features x to belong to the background class. To estimate the probability density, we compare kNN and normalizing flow. From the probability for each feature vector, that encodes a patch in the input image, we linearly interpolate the probability to pixel-resolution.

1) kNN Density Estimation: Different works [22], [26] use the distance between a test feature x and its k nearest training features to estimate uncertainty in neural networks. They show that distance in feature space is an informative metric to identify OoD data. Similarly, we use kNN kernel density to approximate p X ( x ) . We compute a likelihood using the distances to the k nearest background representations:

$$p _ { X } ( x ) \in \frac { 1 } { k } \sum _ { k } \exp \left ( - d i s t _ { k } ( x, { \mathbf X } \right ) )$$

Following [11], [22], we use the cosine similarity as distance metric. Intuitively, if a feature lies in a part of the space far from any background feature, it is very unlikely to correspond to background. Unfortunately, this method requires kNN lookups for every image patch, which is computationally inefficient.

2) Flow-Based Density Estimation: Flow-based approaches have proven useful for estimating complex high dimensional densities [9]. The method aims to find a bijective transformation f that maps feature vectors x to a latent space z , where p Z is the prior probability distribution of the latent

variable. p Z is chosen to be a simple and tractable density such as a multivariate Gaussian. f is constructed as a chain of bijective transformations: f = f 1 ◦ f 2 ◦ ... ◦ f n which is called a (normalizing) flow. As explained in [9], the scale and translation operations in the bijective transformations f i are arbitrarily complex functions, thus modeled as deep neural networks with a set of weights θ . We call p θ the approximation of p X . θ is learned by minimizing the negative log likelihood (NLL) of all background features.

$$\sum _ { \theta } \, \text{or some more} \,. \\ \min _ { \theta } \, - \frac { 1 } { | X | } \sum _ { i } \log p _ { \theta } ( x ^ { ( i ) } ) \quad \text{ where} \colon \\ \log ( p _ { \theta } ( x ) ) = \log \left ( p _ { Z } ( f ( x ) ) \right ) + \log \left ( \left | \frac { \partial f ( x ) } { \partial x ^ { T } } \right | \right ) \\ \text{the} \, \text{$m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$} \, $m$,}$$

$$\left ( \left | \frac { \partial f ( x ) } { \partial x ^ { T } } \right | \right ) _ { \dots } \right ) ^ { ( 1 ) }$$

The NLL is obtained by using the change of variable formula (eq. 1), and requires efficient computation of the determinant of ∂f x ( ) ∂x T (Jacobian of f ). NICE [8] introduces a family of bijective transformations called coupling layers for which the Jacobian is a triangular matrix: its determinant is therefore tractable and can be efficiently computed. Real NVP [9] and GLOW [10] further improve the work of NICE [8], allowing efficient and exact log density estimation of data points x . In this work, we use Real NVP [9] with a chain length of 32 to obtain an efficient density estimation of our background features.

The benefits of normalizing flow over kNN are: (i) it can learn more complex distributions, and (ii) the memory footprint of the flow weights is lower than a kNN database.

3) Multiple Feature Layers: To perform density estimation at multiple layers of our expert network's encoder, we need to combine the likelihoods from an ensemble of density estimators, similar to [3]. However, the individual negative log-likelihood (NLL) estimates cannot be aggregated because the different background features distributions have varying dispersion and dimensions. Similar problems arise for the cosine distance of kNN density. Densities at different layers thus have different scales. Similar to [11], we first center the NLL at layer l around the average NLL of the training features for that layer: ¯ ( N z l ) = N z ( l ) - L ( Z l ) . In the ideal case of a multivariate Gaussian, ¯ N corresponds to the Mahalanobis distance used in [3]. Using a small validation set, we estimate the mean and standard deviation to normalize ¯ N such that the NLL of individual layers can be compared. Following [11], we experiment with three strategies: (i) A pixel is detected as foreground only if all layers agree that it has low log likelihood (high NLL), thus having a high minimum NLL. (ii) A pixel is detected as foreground if it has a low log likelihood on at least one layer, thus having a high maximum NLL. (iii) Using a small set of new labeled images, we fit a logistic regression to capture the interaction between the layers and use it to improve the individual predictions. The results and discussion will be centered around iii) since it outperformed significantly i) and ii) in our experiments.

## IV. EXPERIMENTS AND RESULTS

## A. Datasets

We use the NYU Depth v2 dataset, which contains 1449 densely labeled images of indoor scenes. We sort the dataset to select images containing roughly as much background as foreground, retaining 580 images (493 for training, 87 for testing) with a balanced number of foreground and background pixels. We augment the data with flipping, rescaling, brightness and contrast changes. This dataset however only contains 464 different indoor scenes: a scene thus appears several times from different viewpoints, and could therefore be found in both our train and test set since they are randomly split. We therefore also created a dataset of 70 self-labeled indoor images, which also aims to better capture the high variability encountered in real life scenes. It includes: pictures taken with a smartphone, images downloaded online, blackand-white fish-eye images from construction sites, synthetic images, as well as collages (empty room images that we edited to add objects). It contains approximately 80% background pixels. We use 45 images to create the generalization set on which we will evaluate the performance. The 25 others are used as fitting dataset to fit the logistic regression of the flow ensemble and kNN regresion.

## B. Evaluation Metrics

Evringham et al. [27] suggest that measures such as accuracy are not well suited to evaluate classification and segmentation tasks as they are dependent on the prior distribution over the classes. In our binary segmentation problem, each pixel can be classified by comparing a score for background (coming from our FCN softmax or our density estimation) with a threshold. To choose this threshold, it has to be fit based on a prior assumption of the class-distribution, which is e.g. implicitly done with the cross-entropy loss on the training set. In an open-world setting, this prior distribution learned from the training data can be significantly different to the data used for evaluation. We therefore did not use precision or IoU to evaluate our method, but instead relied on Average Precision (AP) and Average Recall (AR) which allow for a fair comparison of the FCN softmax baseline and our density metric, evaluating over all possible thresholds and compensating for biases due to class distribution mismatches. AR score shows our ability to detect foreground objects, while the AP score shows the overall segmentation quality. The popular VOC Challenge [27] for example uses AP as their ranking metric for detection, classification, and segmentation.

We also report the Area Under the Receiver Operating Characteristic Curve (AUROC) and the False Positive Rate (FPR) at 95% True Positive Rate (TPR), both standard metrics for outlier detection [2], [3], [26]. The FPR at 95% TPR is a particular informative metric for safety-critical applications. The TPR (or recall) is the fraction of foreground pixels correctly labeled. For safety reasons, we value having a low number of misclassified foreground pixels. We thus ensure having a high TPR (95%) and then report the corresponding FPR value. The AUROC can be interpreted as the probability that a positive example has a greater detector score/value than a negative example. A random segmentation thus has an AUROC of 0 5 . while a perfect segmentation will equal 1 [2].

Fig. 3. (a) Example of results on the NYU test set obtained by extracting features from the FCN at different layers (using the encoder trained on the NYU dataset). Results on deeper layers appear more blurry as the density has to be upsampled back to the input image size. The weighted average of layers 3 to 6 yields the best results, which is also reflected in Table I. Additionally (b) presents the results using ADE20K and ImageNet weights (at the fourth layer).

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00448v4-figure-dcb7cc41-15b1-446f-a5c6-6acec42b3184.jpg)

TABLE I

EVALUATION ON THE NYU TEST SET. BOLD INDICATES THE BEST PERFORMANCE FOR EACH APPROACH AND BLUE IS THE BEST OVERALL.

|               |         | FPR@95%TPR (%)   | FPR@95%TPR (%)   | FPR@95%TPR (%)   | Average Recall (%)   | Average Recall (%)   | Average Recall (%)   | Average Precision (%)   | Average Precision (%)   | Average Precision (%)   | Area under ROC   | Area under ROC   | Area under ROC   |
|---------------|---------|------------------|------------------|------------------|----------------------|----------------------|----------------------|-------------------------|-------------------------|-------------------------|------------------|------------------|------------------|
|               |         | Processed NYU    | ADE 20K          | Image Net        | Processed NYU        | ADE 20K              | Image Net            | Processed NYU           | ADE 20K                 | Image Net               | Processed NYU    | ADE 20K          | Image Net        |
| FCN Softmax   | -       | 45.20            | 54.9             | 52.3             | 37.4                 | 37.0                 | 37.0                 | 81.7                    | 83.0                    | 83.0                    | 0.87             | 0.86             | 0.86             |
| kNN           | layer 3 | 69.5             | 79.3             | 86.5             | 27.3                 | 16.2                 | 13.1                 | 75.3                    | 64.2                    | 61.1                    | 0.79             | 0.69             | 0.65             |
|               | layer 4 | 67.3             | 66.2             | 71.5             | 28.6                 | 22.0                 | 19.8                 | 76.1                    | 70.1                    | 67.8                    | 0.77             | 0.75             | 0.73             |
|               | layer 5 | 71.2             | 64.6             | 71.6             | 24.6                 | 21.7                 | 19.8                 | 72.6                    | 70.0                    | 67.8                    | 0.76             | 0.76             | 0.73             |
|               | layer 6 | 72.0             | 66.0             | 73.8             | 23.9                 | 21.8                 | 18.3                 | 71.9                    | 69.9                    | 66.4                    | 0.76             | 0.75             | 0.71             |
| kNN Ensemble  | 3+4+5+6 | 66.8             | 59.7             | 67.9             | 28.7                 | 25.8                 | 23.9                 | 76.7                    | 73.9                    | 71.9                    | 0.80             | 0.79             | 0.76             |
| Normalizing   | layer 3 | 64.2             | 80.4             | 87.7             | 22.2                 | 20.2                 | 17.1                 | 70.3                    | 68.2                    | 65.2                    | 0.76             | 0.73             | 0.69             |
|               | layer 4 | 63.8             | 77.9             | 68.2             | 20.8                 | 20.0                 | 23.6                 | 68.8                    | 68.0                    | 71.6                    | 0.74             | 0.74             | 0.76             |
| Flow          | layer 5 | 53.4             | 68.9             | 73.3             | 37.3                 | 15.5                 | 23.5                 | 85.4                    | 63.6                    | 71.5                    | 0.87             | 0.71             | 0.73             |
|               | layer 6 | 52.6             | 75.6             | 74.4             | 37.6                 | 14.2                 | 18.4                 | 85.7                    | 62.2                    | 66.4                    | 0.86             | 0.68             | 0.71             |
| Flow Ensemble | 3+4+5+6 | 44.2             | 70.9             | 70.6             | 39.1                 | 16.0                 | 24.7                 | 88.9                    | 65.7                    | 74.4                    | 0.89             | 0.72             | 0.76             |

TABLE II EVALUATION ON THE GENERALIZATION SET. BOLD INDICATES THE BEST PERFORMANCE FOR EACH APPROACH AND BLUE IS THE BEST OVERALL.

|               |         | FPR@95%TPR (%)   | FPR@95%TPR (%)   | FPR@95%TPR (%)   | Average Recall (%)   | Average Recall (%)   | Average Recall (%)   | Average Precision (%)   | Average Precision (%)   | Average Precision (%)   | Area under ROC   | Area under ROC   | Area under ROC   |
|---------------|---------|------------------|------------------|------------------|----------------------|----------------------|----------------------|-------------------------|-------------------------|-------------------------|------------------|------------------|------------------|
|               |         | Processed NYU    | ADE 20K          | Image Net        | Processed NYU        | ADE 20K              | Image Net            | Processed NYU           | ADE 20K                 | Image Net               | Processed NYU    | ADE 20K          | Image Net        |
| FCN Softmax   | -       | 80.6             | 74.7             | 65.0             | 27.0                 | 41.7                 | 47.6                 | 40.8                    | 60.5                    | 63.4                    | 0.77             | 0.81             | 0.86             |
| kNN Ensemble  | 3+4+5+6 | 61.9             | 49.0             | 53.9             | 26.1                 | 33.0                 | 34.7                 | 47.2                    | 56.6                    | 57.3                    | 0.81             | 0.85             | 0.84             |
| Flow Ensemble | 3+4+5+6 | 56.4             | 49.4             | 46.2             | 38.0                 | 27.0                 | 40.3                 | 61.6                    | 51.8                    | 65.0                    | 0.84             | 0.83             | 0.88             |

## C. Results on the NYU Test Set

In this section, we have a closer look at how our results on the NYU test set are influenced by two main factors: the layers of the FCN from which the background features are extracted and the weights used for the FCN's encoder (NYU segmentation, ImageNet or ADE20K). We qualitatively show these results in Fig. 3, and quantitatively in Table I.

Using the encoder trained on the NYU training dataset yields, as expected, the best results on the NYU test set. When comparing ImageNet and ADE20K, the former is slightly superior for normalizing flow while the latter has a small advantage for kNN. Overall, ImageNet and ADE20K perform similarly on the NYU test set.

Table I clearly shows a superior performance of normalizing flow with respect to kNN. It also suggest that by using deeper layers in the encoder, the features become more distinctive and objects can be better identified. Finally, using a combination of all the layers further improves the results and makes normalizing flows superior to the classical softmax segmentation on all evaluated metrics. Without ever seeing the objects in the NYU dataset during training, our method surpasses the softmax segmentation (which included the objects in training).

The important point from the experiment on the NYU test set is that our method does not come with a performance tradeoff when the testing data is similar to the training (it is even better). The superiority of our method is further demonstrated using the novel generalization set (see table II, section IV-D).

## D. Results on the Generalization Set

We use the generalization set to show how well our method generalizes to novel objects. Fig. 4 shows a few examples from this set where the FCN fails to segment objects outside of the training set, while our method does not suffer from this. Table II quantitatively shows that our method outperforms FCN softmax and kNN on the generalization set.

As expected, when using an encoder trained on the small NYU dataset the softmax segmentation has extremely poor results on novel data. Using normalizing flow with features from the same encoder however yields far better segmentation results. Those can be seen on Table II, the average recall is improved from 27% to 38% and the average precision is improved from 41% to 62%. This is the key element of our contribution, showing the benefit of learning the background feature distribution using normalizing flow.

Fig. 4. Example results on the generalization set (red dotted circles were added to highlight FCN softmax failures). (a) Empty room image from Google where we added a fridge: it was not found by the FCN softmax. (b) Greyscale fish-eye image from a construction site. The NYU dataset contains neither greyscale nor fish-eye images, which explains the FCN softmax's failure. Despite the difficulty, the density estimation works remarkably well. (c) Advertisement image where part of the textile roll is missed by the FCN softmax. This is challenging since the NYU dataset does not contain close views of objects. Note that these images are more difficult than the ones in figure 1, which explains the slightly poorer results.

![image](https://ac.marcodsn.me/arxiv-markdown-images/1908.00448v4-figure-dbbd58ba-2854-4c5e-a2e6-dfd62576132d.jpg)

Additionally, we notice that the encoder trained on ImageNet unquestionably yields the best generalization results. While intuitively one could think that features from ADE20K would be more relevant for our task since ADE20K is a segmentation dataset, our experiments show the opposite. Although ADE20K contains approx. 20K images, it does not capture the same variability of scenes as ImageNet (14 millions images). This explains the superior behaviour of ImageNet weights on our more diverse generalization dataset. Therefore that size and diversity of the encoder training set directly influence the generalization results

## E. Computational Aspects

Normalizing flow also has the advantage of being computationally less expensive than kNN. Table III shows results using an NVIDIA GeForce GTX 1080 Ti GPU. It is important to note that neither normalizing flow nor kNN were optimized for fast computation. Our experiments show that using 16 bijectors instead of 32 significantly would reduce the flow computation, with minimal effect on segmentation quality. Moreover kNN could be optimized to make better use of GPU resources [28].

For kNN, we stored a different amount of features depending on the layer, which explains the differences in time and memory. Even with the smallest amount of stored features (layer 5), kNN requires more than 5X more time and memory.

The time needed by our flow based method decreases as we use deeper layers, since the feature map is reduced after each pooling layer. Note that the 6 th layer has the same feature map size as the 4 th layer but the dimension is reduced from 512 to 128. Using a normalizing flow at this layer is thus faster and cheaper in memory than using the 4 th layer. It is even faster than using the FCN decoder.

## V. DISCUSSION

Using kNN as a density estimation method has given poor results (see tables I and II) since it is a poor high-dimensional

TABLE III EVALUATION OFF INFERENCE TIME AND MODEL SIZE

|             |   FCN Softmax | Flow Density      | kNN Density          |
|-------------|---------------|-------------------|----------------------|
| Time [ms]   |            35 | 100-50-30-40      | 1950-770-250-370     |
| Memory [MB] |           160 | 160-230-230-130 * | 11000-5100-1360-2000 |

Note : Flow and kNN density results are presented as layers 3-4-5-6 *These corresponds to the memory of the flow ensemble weights (without the encoder).

density estimation method compared to normalizing flow. kNN can indeed not model the complex high dimensional probability distribution of background features so we will focus the rest of this discussion on our flow-based approach.

We have successfully proven that, given the same encoder features, our normalizing flow approach is superior to a classical deconvolution with softmax. To further improve the segmentation, more advanced experts network could be used (e.g. DeepLab) since we expect the normalizing flow method to improve as features from the expert network also improve.

Our experiments with ImageNet and ADE20K weights revealed that specialized training of the expert network is not necessary. However, we observed training instabilities of the normalizing flow when using ImageNet or ADE20K weights. The main difference of those to the NYU weights is that they do not use batch normalization. This spreads out features in the high-dimensional space and makes training of the density estimation much harder. To train the flow, we therefore used early stopping when the log-likelihood of the NYU validation started to decrease. That limited the modeling capacities of the normalizing flow and can explain the relatively poor results of ImageNet and ADE20K on the training set (Table I).

Deeper layers of the encoder have a smaller feature size which allows faster inference. Table III shows that flow-based segmentation on the features of the 5 th layer is even faster than using the FCN decoder presented in Figure 2(a). Using an embedding layer for dimensionality reduction would further reduces the runtime and memory of our flow approach and would make training of normlizing flow more stable. However, since dimensionality reduction compresses the information, extensive experiments are needed to assess whether using an embedding layer before the normalizing flow would make the separation of classes in the lower dimensional space harder, leading to poorer segmentation results. We encourage future works to evaluate the benefits of using embedding layers.

A limitation of our method is that similarly to the FCN softmax, planar and texture-less surfaces are often mistakenly labeled as background with high certainty. Another limitation is that background not found in the training set will be labeled as foreground. For example, some types of floor (e.g. parquet) are often thought to be less likely to be background than walls. This limitation however emphasizes a strength of our method: given data that has no support in the training set, we recognise it as unlikely. As we motivated our work with the detection of potentially dynamic objects for autonomous robots, this is a desirable behavior. While a conventional segmentation network produces random classifications for unknown objects, density based segmentation assigns a low likelihood given the support of known static elements. Any mapping or planning algorithm using this information therefore will not assume

unknown structure to be static. Labelling OoD background as (potential) foreground may limit segmentation quality but improves safety and reliability for the robotic system.

To further improve the performance on OoD background, we suggest using data augmentation. Since background varies in textures rather than shapes, the same images with changing textures of the walls/floors/ceiling etc. can be used. Such augmentation can be simulated, thus reducing the need for more annotated data.

Conventional segmentation methods have weaknesses on both OoD foreground and background since they behave randomly when encountering unknown data. Density based segmentation successfully finds OoD foreground and it's failure on OoD background is predictable for downstream applications. These are important improvements over classical methods towards safer and more reliable autonomous mobile robots.

## VI. CONCLUSION

We presented a novel approach to segment foreground from background in indoor environments, with high reliability against the variability of indoor scenes. Unlike any existing works, we learn the distribution of background features with flow-based methods in order to distinguish foreground objects. The combination of several layers further increases the performance of our approach and yields the best results. We demonstrated that our method outperforms classical softmaxbased segmentation on diverse and novel images without any performance trade-offs on the NYU test set. This is a critical advantage for the deployment in real life applications.

Our reliable segmentation of static background has potential impact on a variety of robotic tasks, e.g. novelty detection in indoor scenes, obstacle avoidance by recognizing arbitrary objects, or long-term SLAM localization by reliably segmenting static structure from dynamic objects. We see all of these as exciting directions for future research.

## REFERENCES

- [1] P. R. Florence, L. Manuelli, and R. Tedrake, 'Dense object nets: Learning dense visual object descriptors by and for robotic manipulation,' in Conference on Robot Learning (CoRL) , 2018.
- [2] D. Hendrycks and K. Gimpel, 'A baseline for detecting misclassified and out-of-distribution examples in neural networks,' in International Conference on Learning Representations (ICLR) , 2017.
- [3] K. Lee, K. Lee, H. Lee, and J. Shin, 'A simple unified framework for detecting out-of-distribution samples and adversarial attacks,' in Advances in Neural Information Processing Systems , 2018, pp. 71677177.
- [4] H. Choi and E. Jang, 'Generative ensembles for robust anomaly detection,' CoRR , vol. vol. abs/1810.01392v1, 2018.
- [5] A. Bendale and T. E. Boult, 'Towards open set deep networks,' in IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , 2016, pp. 1563-1572.
- [6] D. Bozhinoski, D. Di Ruscio, I. Malavolta, P. Pelliccione, and I. Crnkovic, 'Safety for mobile robotic systems: A systematic mapping study from a software engineering perspective,' Journal of Systems and Software , vol. 151, pp. 150-179, 2019.
- [7] B. Xu, W. Li, D. Tzoumanikas, M. Bloesch, A. Davison, and S. Leutenegger, 'Mid-fusion: Octree-based object-level multi-instance dynamic slam,' in 2019 International Conference on Robotics and Automation (ICRA) . IEEE, 2019, pp. 5231-5237.
- [8] L. Dinh, D. Krueger, and Y. Bengio, 'Nice: Non-linear independent components estimation,' in International Conference on Learning Representations (ICLR) , 2015.
- [9] L. Dinh, J. Sohl-Dickstein, and S. Bengio, 'Density estimation using real nvp,' in International Conference on Learning Representations (ICLR) , 2017.
- [10] D. P. Kingma and P. Dhariwal, 'Glow: Generative flow with invertible 1x1 convolutions,' in Advances in Neural Information Processing Systems , 2018, pp. 10 236-10 245.
- [11] H. Blum, P.-E. Sarlin, J. Nieto, R. Siegwart, and C. Cadena, 'The fishyscapes benchmark: Measuring blind spots in semantic segmentation,' arXiv preprint arXiv:1904.03215 , 2019.
- [12] J. Long, E. Shelhamer, and T. Darrell, 'Fully convolutional networks for semantic segmentation,' in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , 2015, pp. 34313440.
- [13] H. Noh, S. Hong, and B. Han, 'Learning deconvolution network for semantic segmentation,' in Proceedings of the IEEE international conference on computer vision , 2015, pp. 1520-1528.
- [14] K. He, G. Gkioxari, P. Doll´ ar, and R. Girshick, 'Mask r-cnn,' in Proceedings of the IEEE international conference on computer vision , 2017, pp. 2961-2969.
- [15] S. Ren, K. He, R. Girshick, and J. Sun, 'Faster r-cnn: Towards real-time object detection with region proposal networks,' in Advances in Neural Information Processing systems , 2015, pp. 91-99.
- [16] M. Grinvald, F. Furrer, T. Novkovic, J. J. Chung, C. Cadena, R. Siegwart, and J. Nieto, 'Volumetric instance-aware semantic mapping and 3d object discovery,' IEEE Robotics and Automation Letters , vol. 4, no. 3, pp. 3037-3044, 2019.
- [17] V. Badrinarayanan, A. Handa, and R. Cipolla, 'Segnet: A deep convolutional encoder-decoder architecture for robust semantic pixel-wise labelling,' arXiv preprint arXiv:1505.07293 , 2015.
- [18] K. Kim, T. H. Chalidabhongse, D. Harwood, and L. Davis, 'Real-time foreground-background segmentation using codebook model,' Real-time imaging , vol. 11, no. 3, pp. 172-185, 2005.
- [19] K. R. Jerripothula, J. Cai, and J. Yuan, 'Efficient video object colocalization with co-saliency activated tracklets,' IEEE Transactions on Circuits and Systems for Video Technology , vol. 29, no. 3, pp. 744-755, 2018.
- [20] Y. Gal, 'Uncertainty in deep learning,' Ph.D. dissertation, University of Cambridge, 2016.
- [21] A. Kendall and Y. Gal, 'What uncertainties do we need in bayesian deep learning for computer vision?' in Advances in neural information processing systems , 2017, pp. 5574-5584.
- [22] N. Papernot and P. McDaniel, 'Deep k-nearest neighbors: Towards confident, interpretable and robust deep learning,' arXiv preprint arXiv:1803.04765 , 2018.
- [23] N. Silberman, D. Hoiem, P. Kohli, and R. Fergus, 'Indoor segmentation and support inference from rgbd images,' in European Conference on Computer Vision (ECCV) . Springer, 2012, pp. 746-760.
- [24] K. Simonyan and A. Zisserman, 'Very deep convolutional networks for large-scale image recognition,' in International Conference on Learning Representations (ICLR) , 2015.
- [25] B. Zhou, H. Zhao, X. Puig, S. Fidler, A. Barriuso, and A. Torralba, 'Scene parsing through ade20k dataset,' in Proceedings of the IEEE conference on computer vision and pattern recognition , 2017, pp. 633641.
- [26] A. Mandelbaum and D. Weinshall, 'Distance-based confidence score for neural network classifiers,' arXiv preprint arXiv:1709.09844 , 2017.
- [27] M. Everingham, L. Van Gool, C. K. Williams, J. Winn, and A. Zisserman, 'The pascal visual object classes (voc) challenge,' International journal of computer vision , vol. 88, no. 2, pp. 303-338, 2010.
- [28] V. Garcia, E. Debreuve, and M. Barlaud, 'Fast k nearest neighbor search using gpu,' in 2008 IEEE Computer Society Conference on Computer Vision and Pattern Recognition Workshops . IEEE, 2008, pp. 1-6.
Nicolas Marchal Charlotte Moraldo Roland Siegwart Hermann Blum Cesar Cadena Abel Gawel
Learning Densities in Feature Space for Reliable Segmentation of Indoor Scenes
Deep learning has enabled remarkable advances in scene understanding,
particularly in semantic segmentation tasks. Yet, current state of the art
approaches are limited to a closed set of classes, and fail when facing novel
elements, also known as out of distribution (OoD) data. This is a problem as
autonomous agents will inevitably come across a wide range of objects, all of
which cannot be included during training. We propose a novel method to
distinguish any object (foreground) from empty building structure (background)
in indoor environments. We use normalizing flow to estimate the probability
distribution of high-dimensional background descriptors. Foreground objects are
therefore detected as areas in an image for which the descriptors are unlikely
given the background distribution. As our method does not explicitly learn the
representation of individual objects, its performance generalizes well outside
of the training examples. Our model results in an innovative solution to
reliably segment foreground from background in indoor scenes, which opens the
way to a safer deployment of robots in human environments.