observer localization using convnets - stanford universitykipnisal/papers/cs231n_project.pdf ·...

6
Observer Localization using ConvNets (Stanford CS231n Winter 2016 class project; submitted Sunday 13 th March, 2016) Alon Kipnis Department of Electrical Engineering Stanford University 350 Serra Mall, Stanford, CA [email protected] 1. Introduction The retrieval of the accurate location of an object in a 3D environment, known as Geolocalization, is a major chal- lenge in many situations such as navigation and orientation in indoor environments. Radio based techniques to this task, such as Global Positioning Systems (GPS) and cellular net- works, have limited accuracy due to the relatively large ra- dio wavelength. In this project, we explore the possibility of detecting the location of an object in a scene, or alternately, the location of the observer, based on visual information. Indeed, the default way humans orient themselves in an indoor envi- ronment is by visual data. In addition to localization, we consider a novel approach for obtaining training data using 3D models of real objects. Below are a few examples where localization based on visual information combined with 3D models to obtain training data can apply: Drone or autonomous navigation – the flying or trav- eling path can be learned offline based on a 3D model. The vehicle then loads a pre-trained ConvNet corre- sponding to the particular path it chooses. Localizing an object in a 3D environment may assist in 3D printing tasks and other indoor location tasks where precision required is smaller than radio wavelength. Since the 3D model emphasizes the outline of an ob- ject rather than its textures, it is suggested that train- ing based on 3D models experience less over-fitting in classifying objects that have different textures (e.g. houses, cars, airplanes, trucks, cups, bananas). Fine-tuning of navigation and motoric tasks such as 3D printing, manufacturing and hovering [1]. 1.1. Related Works Geolocalization using visual data has been considered in many different settings. Works on geo-localization can be roughly divided into two according to the resolution of the localization: (1) large scale – accuracy required is of the order of several kilometers, such as in recognizing cities and street [2, 3, 4]. (2) small scale – accuracy required is within a few meters or even less. The problem considered in this project related to the second class, i.e., small scale and high-resolution geo-localization. Works that consider a similar setting to ours can be found in [5] and the references therein. Localization in scenes based on their 3D models was considered in [6] but with an approach that is not based on ConvNets. We note that a ge- olocalization problem is significantly different from the ob- ject localization problem [7], since the former has a ground truth that is based on spatial data measured from real-world scenes while the ground truth of the latter only depends on a single sample image. 1.2. Contribution In this project, we consider the task of localizing an ob- server in a scene from a single real-time picture in a super- vised learning setting using ConveNets. The scene is first learned by a ConvNet trained to classify the angle into 12 uniform sections over the circle. The testing is performed by examining the classification result on a previously un- seen sample of the same scene. In order to get a large amount of labeled data, we use 3D modeling software. We render a given scene multiple times from different locations of the camera. For each image, we record the angle of the camera with respect to the center of the scene. Finally, we explore the possibility of predicting the camera location of real work scenes based on their 3D model. 1.3. Organization The rest of this report is organized as follows: In Sec- tion 2 we formalize the problem of camera/viewer localiza- tion and explain the fidelity criterion used for evaluation. In 1

Upload: others

Post on 07-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

Observer Localization using ConvNets(Stanford CS231n Winter 2016 class project; submitted Sunday 13th March, 2016)

Alon KipnisDepartment of Electrical Engineering

Stanford University350 Serra Mall, Stanford, CA

[email protected]

1. IntroductionThe retrieval of the accurate location of an object in a

3D environment, known as Geolocalization, is a major chal-lenge in many situations such as navigation and orientationin indoor environments. Radio based techniques to this task,such as Global Positioning Systems (GPS) and cellular net-works, have limited accuracy due to the relatively large ra-dio wavelength.

In this project, we explore the possibility of detecting thelocation of an object in a scene, or alternately, the locationof the observer, based on visual information. Indeed, thedefault way humans orient themselves in an indoor envi-ronment is by visual data. In addition to localization, weconsider a novel approach for obtaining training data using3D models of real objects. Below are a few examples wherelocalization based on visual information combined with 3Dmodels to obtain training data can apply:

• Drone or autonomous navigation – the flying or trav-eling path can be learned offline based on a 3D model.The vehicle then loads a pre-trained ConvNet corre-sponding to the particular path it chooses.

• Localizing an object in a 3D environment may assist in3D printing tasks and other indoor location tasks whereprecision required is smaller than radio wavelength.

• Since the 3D model emphasizes the outline of an ob-ject rather than its textures, it is suggested that train-ing based on 3D models experience less over-fittingin classifying objects that have different textures (e.g.houses, cars, airplanes, trucks, cups, bananas).

• Fine-tuning of navigation and motoric tasks such as 3Dprinting, manufacturing and hovering [1].

1.1. Related Works

Geolocalization using visual data has been considered inmany different settings. Works on geo-localization can be

roughly divided into two according to the resolution of thelocalization: (1) large scale – accuracy required is of theorder of several kilometers, such as in recognizing citiesand street [2, 3, 4]. (2) small scale – accuracy required iswithin a few meters or even less. The problem consideredin this project related to the second class, i.e., small scaleand high-resolution geo-localization.

Works that consider a similar setting to ours can be foundin [5] and the references therein. Localization in scenesbased on their 3D models was considered in [6] but with anapproach that is not based on ConvNets. We note that a ge-olocalization problem is significantly different from the ob-ject localization problem [7], since the former has a groundtruth that is based on spatial data measured from real-worldscenes while the ground truth of the latter only depends ona single sample image.

1.2. Contribution

In this project, we consider the task of localizing an ob-server in a scene from a single real-time picture in a super-vised learning setting using ConveNets. The scene is firstlearned by a ConvNet trained to classify the angle into 12uniform sections over the circle. The testing is performedby examining the classification result on a previously un-seen sample of the same scene.

In order to get a large amount of labeled data, we use 3Dmodeling software. We render a given scene multiple timesfrom different locations of the camera. For each image, werecord the angle of the camera with respect to the center ofthe scene. Finally, we explore the possibility of predictingthe camera location of real work scenes based on their 3Dmodel.

1.3. Organization

The rest of this report is organized as follows: In Sec-tion 2 we formalize the problem of camera/viewer localiza-tion and explain the fidelity criterion used for evaluation. In

1

Page 2: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

θ

ConveNet

trainingimages

θ

Figure 1. Camera/observer relative angle detection problem set-ting.

Figure 2. GUI for the 3D modeling python package Blender. Thedata is generated by rendering multiple images of the model fromdifferent camera locations.

Section 3 we explain the technical approach taken as wellas the structure of the ConvNet. The results are presentedand discussed in Section 4. Concluding remarks are givenin Section 5.

2. Problem StatementWe consider a geolocation problem as depicted in Fig-

ure 1. In this problem, the network is required to retrievethe relative angle θ of the camera given an input image. Weformulate the problem as a classification problem by divid-ing the circle into 12 identical sections. The goal of thenetwork is to produce an estimate of the particular class ofthe viewer/camera angle. The loss in this case is the indi-cator loss (also known as the Hamming loss or Kroneckerdelta):

`I = 1(ctrue=c).

The classification accuracy is defined as the average of `Iloss over the data set. Namely, the number of correct clas-sifications divided by the number of input images.

3. Technical Approach3.1. Data

The data is obtained using a 3D modeling software(Blender package for Python, Figure 2). For a particular

Figure 3. Example dataset1: manor house

Figure 4. Example dataset2: Statue of Liberty

scene or object, multiple images are generated that corre-sponds to different angles of the camera with respect tothe object located at the center of the scene. These anglesare stored as the labels of the training data. Examples forimages from the training data generated by this procedureare given in Figures 3 and 4.

The manor house example includes 9000 labeled imagessplit into training, validation and testing data according tothe ratio 8 : 1 : 1. The Statue of Liberty example includes5000 labeled images split according to the same ratio.

3.2. Network Architecture

We use the ConvNet architecture provided in Figure 5that is based on the AlexNet [8]. The network consistsof three convolution-ReLU-maxpool-batchnorm-dropoutsblocks, followed by 2 fully connected layers of 1024 neu-rons. The number of outputs at the last fully connected layeris 12, which corresponds to different intervals of the circle.

We realized the ConvNet illustrated in Figure 5 usingthe scientific computing framework TensorFlowTM. TheTensorFlow computational graph that realizes data reading,training and validation parts is illustrated in Figure 6.

3.3. Loss Function

The loss function is taken to be the log-loss or cross en-tropy loss between the distribution that gives 1 to the trueangle class and zero otherwise. For a single sample this

Page 3: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

64× 64 image

3× 3× 64 Conv

ReLU

2 : 1 maxpool

batchnorms

dropout

3× 3× 128 Conv

ReLU

2 : 1 maxpool

batchnorms

dropout

3× 3× 256 Conv

ReLU

2 : 1 maxpool

batchnorms

dropout

1024 FC1

ReLU

1024 FC2

softmax

Figure 5. ConvNet architecture

Figure 6. Tensorboard realization of the training and evaluationmodel. Note that this graph also includes data reading interfacesfor training and evaluation.

Figure 7. TensorBoard statistics for the Statue of Liberty dataset.

loss is defined by

`i = − log(pi), (1)

where pi is the probability that the network assigns to thetrue class. The actual loss is the mean of `i over a batchof samples. In addition, we added a regularization term to(1) which is the L2 norm of the weights in the last two fullyconnected layers (FC1 and FC2 in Figure 5).

3.4. Learning Process

The result of the learning process for the manor houseexample and the Statue of Liberty example is given in Fig-ure 7.

With the manor house data, the network achieved 100%accuracy on the training and about 99% on the validationset. With the Statue of Liberty data, the network achieved66% on the training set and 64% on the validation set.

Page 4: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

Figure 8. Three examples for angle-class predictions with respectto test data for the manor house example. The probability assignedby the network to each direction is given by the different colors(small probabilities are given cold colors) The class that containsthe true angle is painted in gray. The absolute error between thetrue angle and the predicted angle (the class center) is also pro-vided.

Training statistics of the Statue of Liberty example fromTensorBoard are provided in Figure 7.

4. ResultsTraining, validation and testing scores with respect to the

two models are given in the table below.

train validation testManor 100% 99% 96%Liberty 66% 64% 56%

Examples of the output probabilities predicted by themodel on the test set and the corresponding ground truthare illustrated in Figures 8 and 9.

4.1. Discussion

The very high classification accuracy obtained in themanor house example suggests that our angle detection taskis not too challenging for a ConvNet considered with sucha high number of training samples. Nevertheless, these re-sults show that viewer angle detection from visual data ispossible and motivate us to explore harder geolocalizationtasks in the future.

The difference in training and testing performances be-tween the two models may be due to the size of the data(9000 vs 5000 samples) and other properties of the object.For example, excluding her hand, low-resolution images ofLady Liberty seem to have more radial symmetry, a prop-erty that is likely to make angle detection harder.

Another way to evaluate the classification performanceis by considering the absolute error between the true direc-tion and the direction predicted by the network. The ra-

Figure 9. Three examples for angle-class predictions with respectto test data for the Statue of Liberty example. The probability as-signed by the network to each direction is given by the differentcolors (small probabilities are given cold colors) The class thatcontains the true angle is painted in gray. The absolute error be-tween the true angle and the predicted angle (the class center) isalso provided.

tional behind this metric is that even when a classificationerror occurs, the actual angle may still be close to the anglepredicted by the network (the center of the interval of thepredicted class). The absolute error between the true an-gle and the angle predicted by the network are also given inFigures 8 and 9 for individual examples.

4.2. Real data Classification Based on 3D Model

Once the network is trained on the 3D model of theStatue of Liberty, we examined its performance with respectto estimating the camera angle of real images of the Statueof Liberty taken from the internet. An example of the resultsis given in Figure 10.

One can appreciate that in most cases the system pro-vides a high probability of what seems to be the true anglefrom which the picture was taken. We can speculate that in-accuracies in classification real camera images compared tothe test data of the trained 3D model is due to lighting, tex-ture or background conditions since these are significantlydifferent from the rendered 3D model. Adding different skyand lighting conditions in the 3D model would likely im-prove the accuracy of prediction on real images.

4.3. Convolution-Layer Activations

Illustrating the activation from different layers in thetrained network would help understand the features learnedby the network to predict the camera angle [9]. Examplesfor these activations are given in Figures 11 and 12 for themanor house model and the Statue of Liberty model, respec-tively. Note that the two networks were trained separately,so comparing both Figures feature-by-feature is meaning-less.

Page 5: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

Figure 10. Camera angle prediction result on real images of theStatue of Liberty.

inputs

Figure 11. Activation maps for five input images from second con-volution layer in the manor house example.

inputs

Figure 12. Activation maps for five input images from second con-volution layer in the Statue of Liberty example.

It can be observed that areas of bright light and edges areemphasized by this convolution layer.

5. Conclusions

We have considered a geolocation task of estimating theangle of the viewer/camera with respect to an object. Wetrained a ConvNet with architecture similar to AlexNet topredict the angle in a classification model of 12 differentangles. The data is obtained from a 3D model of the ob-

ject using a 3D modeling program (Blender). The com-putation graph was built and trained using TensorFlowTM

framework. We trained and tested the network over twodatasets of 9000 samples and 5000 samples, respectively.

The trained network achieves very high classification ac-curacy on the test data (97%) for the model with 9000 sam-ples and relatively high accuracy (56%) for the dataset with5000 images. These results suggest that ConveNets can besuccessfully trained to retrieve angle and possibly other lo-cation parameters from visual data. This fact motivates thestudy of more complicated geolocation setting. For exam-ple, it suggests that ConvNets can be trained to localize anobserver/camera inside a closed room or building.

Another important question raised in this project is theaccuracy in the classification of real-word images trainedon synthetic data taken from a 3D model of the realscene/object. While we did not test our model against real-world labeled data, it appears that our network providesqualitatively reasonable predictions.

References[1] T. Wu, F. Huang, J. L. Yao, and B. Yang, “Geo-

localization based scene recognition,” in MultimediaBig Data (BigMM), 2015 IEEE International Confer-ence on, April 2015, pp. 244–247.

[2] G. Baatz, O. Saurer, K. Koser, and M. Pollefeys, “Largescale visual geo-localization of images in mountainousterrain,” in Computer Vision–ECCV 2012. Springer,2012, pp. 517–530.

[3] T.-Y. Lin, Y. Cui, S. Belongie, and J. Hays, “Learn-ing deep representations for ground-to-aerial geolocal-ization,” in Computer Vision and Pattern Recognition(CVPR), 2015 IEEE Conference on. IEEE, 2015, pp.5007–5015.

[4] A. V. Peddada and J. Hong, “Geo-location estimationwith convolutional neural networks,” 2016. [Online].Available: http://cs231n.stanford.edu/reports/CS231NFinal Report amanivp jamesh93.pdf

[5] M. Aubry, B. C. Russell, and J. Sivic, “Visual geo-localization of non-photographic depictions via 2d-3d alignment,” Visual Analysis and Geolocalization ofLarge-Scale Imagery, 2015.

[6] A. R. Zamir and M. Shah, “Image geo-localizationbased on multiplenearest neighbor feature matching us-inggeneralized graphs,” IEEE Transactions on PatternAnalysis and Machine Intelligence, vol. 36, no. 8, pp.1546–1558, Aug 2014.

[7] J. Tompson, R. Goroshin, A. Jain, Y. LeCun, andC. Bregler, “Efficient object localization using convo-

Page 6: Observer Localization using ConvNets - Stanford Universitykipnisal/Papers/CS231n_project.pdf · approach that is not based on ConvNets. We note that a ge-olocalization problem is

lutional networks,” in Proceedings of the IEEE Con-ference on Computer Vision and Pattern Recognition,2015, pp. 648–656.

[8] A. Krizhevsky, I. Sutskever, and G. E. Hinton, “Ima-genet classification with deep convolutional neural net-works,” in Advances in neural information processingsystems, 2012, pp. 1097–1105.

[9] J. Donahue, Y. Jia, O. Vinyals, J. Hoffman, N. Zhang,E. Tzeng, and T. Darrell, “Decaf: A deep convolutionalactivation feature for generic visual recognition,”CoRR, vol. abs/1310.1531, 2013. [Online]. Available:http://arxiv.org/abs/1310.1531