arXiv(opens in a new tab)Computer ScienceApr 2016Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:1604.07379

Context Encoders: Feature Learning by Inpainting

Deepak Pathak, Philipp Krähenbühl, Jeff Donahue, Trevor Darrell, Alexei A. Efros

Abstract

We present an unsupervised visual feature learning algorithm driven by context-based pixel prediction. By analogy with auto-encoders, we propose Context Encoders – a convolutional neural network trained to generate the contents of an arbitrary image region conditioned on its surroundings. In order to succeed at this task, context encoders need to both understand the content of the entire image, as well as produce a plausible hypothesis for the missing part(s). When training context encoders, we have experimented with both a standard pixel-wise reconstruction loss, as well as a reconstruction plus an adversarial loss. The latter produces much sharper results because it can better handle multiple modes in the output. We found that a context encoder learns a representation that captures not just appearance but also the semantics of visual structures. We quantitatively demonstrate the effectiveness of our learned features for CNN pre-training on classification, detection, and segmentation tasks. Furthermore, context encoders can be used for semantic inpainting tasks, either stand-alone or as initialization for non-parametric methods.

1 Introduction

Our visual world is very diverse, yet highly structured, and humans have an uncanny ability to make sense of this structure. In this work, we explore whether state-of-the-art computer vision algorithms can do the same. Consider the image shown in Figure 1(a). Although the center part of the image is missing, most of us can easily imagine its content from the surrounding pixels, without having ever seen that exact scene. Some of us can even draw it, as shown on Figure 1(b). This ability comes from the fact that natural images, despite their diversity, are highly structured (e.g. the regular pattern of windows on the facade). We humans are able to understand this structure and make visual predictions even when seeing only parts of the scene. In this paper, we show that it is possible to learn and predict this structure using convolutional neural networks (CNNs), a class of models that have recently shown success across a variety of image understanding tasks.

Figure

(a) Input context

Figure

(b) Human artist

Figure

(c) Context Encoder (L2L2 loss)

Figure

(d) Context Encoder (L2L2 + Adversarial loss)

Figure 1: Qualitative illustration of the task. Given an image with a missing region (a), a human artist has no trouble inpainting it (b). Automatic inpainting using our context encoder trained with L2L2 reconstruction loss is shown in (c), and using both L2L2 and adversarial losses in (d).

Given an image with a missing region (e.g., Fig. 1(a)), we train a convolutional neural network to regress to the missing pixel values (Fig. 1(d)). We call our model context encoder, as it consists of an encoder capturing the context of an image into a compact latent feature representation and a decoder which uses that representation to produce the missing image content. The context encoder is closely related to autoencoders [20, 3], as it shares a similar encoder-decoder architecture. Autoencoders take an input image and try to reconstruct it after it passes through a low-dimensional “bottleneck” layer, with the aim of obtaining a compact feature representation of the scene. Unfortunately, this feature representation is likely to just compresses the image content without learning a semantically meaningful representation. Denoising autoencoders [38] address this issue by corrupting the input image and requiring the network to undo the damage. However, this corruption process is typically very localized and low-level, and does not require much semantic information to undo. In contrast, our context encoder needs to solve a much harder task: to fill in large missing areas of the image, where it can’t get “hints” from nearby pixels. This requires a much deeper semantic understanding of the scene, and the ability to synthesize high-level features over large spatial extents. For example, in Figure 1(a), an entire window needs to be conjured up “out of thin air.” This is similar in spirit to word2vec [30] which learns word representation from natural language sentences by predicting a word given its context.

Like autoencoders, context encoders are trained in a completely unsupervised manner. Our results demonstrate that in order to succeed at this task, a model needs to both understand the content of an image, as well as produce a plausible hypothesis for the missing parts. This task, however, is inherently multi-modal as there are multiple ways to fill the missing region while also maintaining coherence with the given context. We decouple this burden in our loss function by jointly training our context encoders to minimize both a reconstruction loss and an adversarial loss. The reconstruction (L2) loss captures the overall structure of the missing region in relation to the context, while the the adversarial loss [16] has the effect of picking a particular mode from the distribution. Figure 1 shows that using only the reconstruction loss produces blurry results, whereas adding the adversarial loss results in much sharper predictions.

We evaluate the encoder and the decoder independently. On the encoder side, we show that encoding just the context of an image patch and using the resulting feature to retrieve nearest neighbor contexts from a dataset produces patches which are semantically similar to the original (unseen) patch. We further validate the quality of the learned feature representation by fine-tuning the encoder for a variety of image understanding tasks, including classification, object detection, and semantic segmentation. We are competitive with the state-of-the-art unsupervised/self-supervised methods on those tasks. On the decoder side, we show that our method is often able to fill in realistic image content. Indeed, to the best of our knowledge, ours is the first parametric inpainting algorithm that is able to give reasonable results for semantic hole-filling (i.e. large missing regions). The context encoder can also be useful as a better visual feature for computing nearest neighbors in non-parametric inpainting methods.

References (36)

  • Learning to see by moving
  • Patchmatch: A randomized correspondence algorithm for structural image editing
  • Image inpainting
  • A unified architecture for natural language processing: Deep neural networks with multitask learning
  • Context as supervisory signal: Discovering objects with predictable context
  • Unsupervised visual representation learning by context prediction
  • What makes paris look like paris? ACM Transactions on Graphics, 2012
  • Decaf: A deep convolutional activation feature for generic visual recognition
  • Learning to generate chairs with convolutional neural networks
  • Texture synthesis by non-parametric sampling
  • The Pascal Visual Object Classes challenge: A retrospective
  • Rich feature hierarchies for accurate object detection and semantic segmentation
  • Generative adversarial nets
  • Unsupervised learning of spatiotemporally coherent metrics
  • Semantic contours from inverse detectors
  • Scene completion using millions of photographs
  • Reducing the dimensionality of data with neural networks
  • Learning image representations tied to ego-motion
  • Caffe: Convolutional architecture for fast feature embedding
  • Adam: A method for stochastic optimization
  • Auto-encoding variational bayes
  • Data-dependent initializations of convolutional neural networks
  • ImageNet classification with deep convolutional neural networks
  • Backpropagation applied to handwritten zip code recognition
  • Fully convolutional networks for semantic segmentation
  • Beyond categories: The visual memex model for reasoning about object relationships
  • Distributed representations of words and phrases and their compositionality
  • Building the gist of a scene: The role of global image features in recognition
  • An iterative regularization method for total variation-based image restoration
  • Unsupervised representation learning with deep convolutional generative adversarial networks
  • Learning temporal embeddings for complex video analysis
  • Modeling natural images using gated mrfs
  • Disentangling factors of variation for facial expression recognition
  • Imagenet large scale visual recognition challenge
  • Unsupervised learning of visual representations using videos
  • Visualizing and understanding convolutional networks