Scene Classification in Indoor Environments for Robots using Context Based Word Embeddings

Scene Classification has been addressed with numerous techniques in computer vision literature. However, with the increasing number of scene classes in datasets in the field, it has become difficult to achieve high accuracy in the context of robotics. In this paper, we implement an approach which combines traditional deep learning techniques with natural language processing methods to generate a word embedding based Scene Classification algorithm. We use the key idea that context (objects in the scene) of an image should be representative of the scene label meaning a group of objects could assist to predict the scene class. Objects present in the scene are represented by vectors and the images are re-classified based on the objects present in the scene to refine the initial classification by a Convolutional Neural Network (CNN). In our approach we address indoor Scene Classification task using a model trained with a reduced pre-processed version of the Places365 dataset and an empirical analysis is done on a real-world dataset that we built by capturing image sequences using a GoPro camera. We also report results obtained on a subset of the Places365 dataset using our approach and additionally show a deployment of our approach on a robot operating in a real-world environment.

I. INTRODUCTION Scene Classification has been extensively researched by the computer vision [1], [2], [3] community. Most datasets have millions of images which makes the task challenging and thereby encourages the vision community to come up with better algorithms to achieve higher accuracies. However, on some of these datasets, current state of the art algorithms have low accuracies which renders their usage in the real world impractical. For instance the top-1 accuracy on the Places365 dataset [1] is only around 56%. Such an accuracy is not of much use when deploying algorithms on a robot as nearly half of the time the robot would make erroneous predictions. In the past, there have been datasets with a limited number of different places, like [4], [5], which had only upto 17 places, however these datasets' usage has been rendered obsolete due to already achieved near human accuracy (≈95%).
In this paper, we propose an approach for Scene Classification in real time in the context of robotics. We primarily target indoor scenes in this paper. In indoor environments, GPS cannot be relied on for metric level precision. We can only get a rough estimate of the position of the robot from GPS in indoor scenes. We leverage this inaccuracy in the GPS to reduce the search space of the places. We propose a taxonomy based approach to perform Scene Classification by dividing the places according to the area type (e.g., school, shopping-mall, home, etc.). Once we know roughly which region the robot is in, we need to only search for a subset of places rather than searching all the classes. For example, from GPS we can know that the robot is in a school environment. This would reduce the search space to places like corridors, lecture hall, seminar room, washroom, etc. (see table I). We no longer need to consider the places that belong to any unrelated class like living room, pet shop, jewelry store, forest, waterfall, mountains, etc. After this step, many classes are pruned leaving a smaller set of candidate classes to select from. To classify the places, we propose to use different CNN models for each of the indoor areas present in the Places365 dataset [1].
After employing a CNN for Scene Classification, we obtain the top-5 predictions for a given image. To further refine the accuracy of the prediction, we make use of different objects present in the scene which are detected using a Scene Parsing Module (see Figure 2). Each object present in the image is represented using a word-embedding [6]. In most cases, these object embeddings are similar for objects belonging to a particular scene and the scene embedding itself, e.g., tray, coffee table, chairs in a dinning room (See Figure 1) should have similar embedding. Using these embeddings, we further refine the top-5 scores to improve the accuracy. Finally, we build our own test dataset to validate our approach as there are many inconsistencies in Fig. 2. Overview of our algorithm. Our approach takes an RGB image as input. Then passes it onto two CNN modules. The top module is for Scene Classification, which gives us an initial top-5 prediction. The bottom module is for Scene Parsing, which detects the scene contents including background (window pane, plant, etc.) and foreground (table, chair, sofa, etc.) objects. The Word Vectors Module computes a vector for the contents of the image, and a vector for each of the top-5 predicted labels. Then Word Vectors Module refines the ranking of these top-5 predicted labels by comparing the vector similarity. the Places365 dataset as described in section IV. We also report the performance on a subset of the Places365 dataset.
The major contributions of this work are: (i) A taxonomy based approach to make Scene Classification work in real time with high accuracy for robots using GPS information, (ii) An empirical evaluation showing performance of our proposed approach, (iii) A real world dataset for the task of indoor Scene Classification. The paper is structured as follows: we describe the relevant work in Section II. Section III describes our proposed approach. Section IV describes our test dataset. Experimental results of our approach are described in Section V and finally we conclude our work in Section VI.

II. RELATED WORK
In this section, we give a brief overview of the existing approaches used for Scene Classification. Li et al. [7] used object detectors as features to form an Object Bank Representation to assist Scene Classification. Our proposed approach is similar to [7], instead of using an Object Bank representaion, we employed a word vector [6] based feature representation to find similarities between objects in the image and the scene category. Yang et al. [8] used key point detection to create feature vectors. Bosch et al. [9] used visual vocabulary as features to train a Support Vector Machine (SVM) classifier. Furthermore, different types of CNN architectures (AlexNet [10], VGG [11], GoogleNet [12]) were used in Scene Classification recently. These CNNs achieved decent state-of-the-art performance (≈56%) on Places365 [1] dataset. As well as, Khan et al. [13] integrated Places-VGG with Spectral Features to improve Scene Classification. However, the datasets they used are not appropriate for real world application.
The CNN generally learns a feature representation of an image but the network can not tell us the object relations in the image. However, a special CNN architecture (Seg-Net [14]) can be used to perform pixel level segmenta-tion (Scene Parsing). A newly released pre-trained CNN model [15] based on a cascade segmentation module can find 150 types of contents in an image, which includes background (wall, doors, windows, floor, etc.) and foreground (person, television, table, chair, etc.) information. There are several approaches which can detect objects in an image; YOLO [16] detects most of the foreground objects. But their approach does not yield anything about the background of the image. Background information also plays an important role when a human is classifying a scene.
Word vectors [17] are very popular in Natural Language Processing (NLP). This is also known as word embedding. It improves the performance of LSTM-CRF [18] significantly on the named entity recognition systems without any language-specific knowledge [19]. Word vectors were trained to learn the vector representation of a given vocabulary. Word vectors have been used in many domains like sentiment analysis [6], detecting magnitude of events [20], named entity recognition [21], etc.
Scene Classification can also be useful for Place Recognition as it reduces the search space. Alternatively Place recognition can also be used to tackle scene classification (in case where all test images come from a set of predefined paces and each place is associated with a scene type). Some of the existing Place recognition works include [3], [22], [4], [23].
Data sets: Many well-known data sets and benchmarks exist. For instance, Places88 [24] is the very first version of MIT Places benchmark 3 . It has 88 scene categories. The latest Scene Classification data set is MIT Place365 [1], which has 365 scene categories. In this paper we use Place365 as our training and evaluation data-set, as it is the largest scene classification data-set, and it contains broad categories. Some other old datasets also exist for Scene Classification. The Pascal VOC [25] data set has scene context annotations which are used for object detection and object segmentation tasks. Another data set is MS-COCO [26]. COCO is mainly used for instance detection and scene segmentation. The pre-trained CNN Scene Parsing model [15] used in this paper is trained on COCO.

III. APPROACH
Our aim is to provide a Scene Classification approach which can perform well in a known real world environment (e.g., school, home, shopping mall). We build a taxonomy of different environments each containing separate scenes as shown in Table I. We pre-process the Places365 dataset to clean and reduce it to have only sensible indoor places for our use. Places365 has many inconsistencies as described in section IV.
We use two existing CNN models, one for Scene Classification [1] and the other for Scene Parsing [15]. Figure 2 shows the overview of our approach. The input is an RGB image for the two CNN modules. We call them CNN Scene Classification Module and CNN Scene Parsing Module (Figure 2). The Classification Module computes the initial raw top-5 predictions. The Scene Parsing module computes the scene contents from foreground and background. The Word Vector module computes the vector similarity between the contents present in the input image and the top-5 predicted labels. Using the computed similarity score, we output a refined re-ranked top-5 labels for the input image. We describe the details about each module in following subsections.

A. CNN Scene Classification Module
In this module, we train the ResNet models (one for each environment) on a reduced version of the Places365 dataset (based on our taxonomy, see table I). The code and model parameters can be downloaded from this link 4 . CNN Scene Classification Module computes the top-5 prediction labels which is further used by the Word Vectors Module to refine these prediction scores.

B. CNN Scene Parsing Module
In this module, we use a pre-trained CNN Scene Parsing model 5 . The CNN model was trained on ADE20K dataset [15]. It is trained to detect 150 different object categories from the given input image. The Scene Parsing module tells us the different objects/contents present in a given input image. For a kitchen input image, the parser would output the presence of kettle, stove, oven, glasses, plates, etc. We convert these object labels as English words and pass that onto Word Vectors module, described in the section below.

C. Word Vectors Module
Now we know the objects present in each of the images in the dataset. Knowing the top-5 predictions of each image and the objects present in each of the images, we need to make use of this information to refine the top-5 scores. 4 http://places2.csail.mit.edu/ 5 https://github.com/CSAILVision/sceneparsing This section is the main contribution of this work. First, we define some of the notations being used and then describe our approach using these notations.
Notations used: let V be the dictionary/vocabulary containing the objects, O and the scenes, S present in the dataset. RT k = W ordV ectorM odule (IO k , T k , ACC k ) 5. return RT IV ector k (j) = < 0 > vector 4. for oi ∈ IO k do 5.
Similarity[j] = cosine(IV ector k (J), sj) 7. Similarity = N ormalize(Similarity) 8. RT k = descendingOrder(ACC k * Similarity) 9. return RT k Now we have the initial top-5 predicted classes T k for each image, I k obtained from the Scene Classification module and the set of objects, IO k present in each image obtained from the scene parser module. Our approach can be summarized in Algorithm 1. To compute the refined top-5 scene classes predictions, RT k : first we compute a vector representation for the image with respect to each of the top-5 predicted classes. We compute a weighted vector sum of the detected objects in the image to represent the image vector. The vector representation for a given input image, I with respect to a scene s j is computed as follows: Here o i ∈ IO k . The weights, w i,j and vectors, o i are learned by the word vector module (see Figure 3). IV ector k (j) is the vector representation of the input image, I k in terms of the objects present w.r.t. to scene label j. Refer to line 4,5 in Algorithm 1, Procedure 2.
Learning the object and scene vectors, V , and the weight matrix, W : Vectors in V are initialized by the pre-trained word2vector 6 , and W are initialized by tf-idf 7 . When computing tf-idf, we considered each scene class is a document, and the objects in the image are the words. The object representing the scene has a higher weight and the object occurring less frequently in the scene would have a lower weight. We pre-compute the training predictions, T , ACC and objects in images, IO. We feed this information into our cosine similarity training model (see Figure 3) to learn the weights, W and Vocabualry, V . The loss function used in our model was a hinge loss with margin equal to 0.1.
There are some objects, o i ∈ O which might exist in most of the scenes. Such objects contribute less in determining the class of the scene. So a lesser weight should be assigned to such objects while computing the weighted sum representation of the image vector, IV ector k (j). On the other hand, if an object exists only in some particular scenes, we need to increase the weight of this object. This is intuitive, for instance: the chances of finding a "sofa" is more likely in a "living-room" scene than any other place. Now we describe the dataset we built to validate our approach and provide empirical results obtained on our dataset and the Places365 dataset.

IV. THE DATASET
One of the current widely used datasets for Scene Classification is the Places365 dataset [1]. This dataset is the latest and largest Scene Classification dataset with more than 1 million images. Places365 has 365 scene categories with 3000 to 5000 images per class. However in this dataset there are many confusing places that are practically the same but have been labelled distinctly. For example, the places {bedroom, dorm room}, {lecture room, classroom}, {pharmacy, drug-store}, etc. are some sets of places that are referring to the same but labelled differently. Moreover, after a close inspection of this dataset, it was found that many images in the dataset are incorrectly labelled. Due to these mentioned issues with the Places365 dataset, we decided to merge certain classes into one before training our models (see taxonomy file on the project page 8 ). Additionally since in our work, we are only concerned about indoor places, we remove all outdoor places in the Places365 dataset. After this pre-processing step of removal and merging of places, we get a total of 156 different scenes for 8 different environments. We train our model using this pre-processed dataset.
For testing our proposed approach, we built a dataset in the real world of 69 different places (see table I), which we arranged in a hierarchical manner with 2 levels. First level (environment-type) lists out the major areas like school, home, shopping mall, etc. Each of the categories in the first level has sub-class scenes associated with them. For e.g., a shopping mall would have a set of places like gift-shop, food-court, salon, drug-store, etc. A detailed list of places in our testing dataset can be found in table I and at our project page 8 . We have a total of 10,000 testing images in our dataset. Out of these approximately 1000 images were extracted from videos on youtube as some places were not easily available in the real world and others were captured from a GoPro camera.

V. EVALUATION
In our taxonomy, we described 8 different environment types (School, Shopping Mall, Home, Condo Buildings, Airport, Public Transit, Hospital, and Hotel) using 156 indoor scenes. In this work, we select 3 environments to evaluate our approach, which are School, Home, and Shopping Mall (see Table I).
In our experiments, we trained a ResNet model for each environment with the selected scenes. The performance is listed in Table II. As one would expect, the ResNet model performs well on the reduced Places365 validation set. The performance on our test set is even higher, since our dataset is labeled with fewer human errors. Furthermore, we used a GoPro camera with wide-angle view mode, so the images perfectly represent the scenes. Overall, our method is better than a CNN model (ResNet50) in terms of accuracy. Our results proved that the "image context (objects)" plays a vital role in Scene Classification. Although, the refinement on Shopping Mall scenes is not noticeable, this is because the CNN Scene Parsing model we used could not find objects that can distinguish the scenes well enough. For instance, the model could not detect shoes, watches, hats, etc., which are commonly found in shopping malls. Figure 4 discusses the results of some images in our dataset. Finally, we also demonstrate our approach by deploying our algorithm on a Pioneer3AT robot in a university environment. The robot was configured with a ZED camera from which monocular images were used by our algorithm. The robot was equipped with a Razer Blade laptop with a GTX 1060 GPU. The demo video of the deployment is available on our project web-page 8 .

VI. CONCLUSION
In this paper, we introduced a new method for Scene Classification using a taxonomy for different indoor environments. Using our approach, robots can recognize different indoor places with high confidence/accuracy. A hierarchical taxonomy of places allowed us to prune out many irrelevant classes, thereby reducing the complexity/training time of our approach. A word embedding based approach was implemented to refine the top-5 scores for the scenes. It was shown that context has the potential to improve the Scene Classification results to some extent. We additionally tested our approach with a real world dataset that we built to show the practical applicability of our approach. We also deployed our algorithm on a robot in a university environment. On our dataset we could get promising results for doing Scene Classification for robots.