Deep Feature Consistent Variational Autoencoder

Xianxu Hou, LinLin Shen, Ke Sun, Guoping Qiu

TL;DR

Standard Variational Autoencoders (VAEs) often produce blurry images because they rely on pixel-by-pixel comparisons that ignore human visual perception. This paper introduces the Deep Feature Consistent VAE, which replaces traditional pixel-wise loss with a "feature perceptual loss" derived from a pre-trained deep CNN. The result is a model that generates significantly sharper images and a semantically rich latent space capable of state-of-the-art facial attribute prediction.

What Problem Does This Paper Address?

Generative models like VAEs aim to learn the underlying distribution of data (like faces) to create new, realistic samples. However, VAEs have historically suffered from a "blurriness" problem.

The culprit is the standard reconstruction loss. Most VAEs use an $L_2$ (squared Euclidean distance) loss, comparing the input and output pixel by pixel. This approach assumes pixels are independent, which is fundamentally untrue for natural images. For example, if an image is shifted by just two pixels, the $L_2$ loss might be massive, even though a human would see almost no difference. Because the model tries to minimize this "unintelligent" loss, it tends to average out details, leading to the characteristic VAE blur.

Methods

The authors propose a simple but powerful shift: instead of comparing images in "pixel space," compare them in "feature space."

  1. The Architecture: The system uses a standard VAE setup (Encoder and Decoder). The encoder maps an image $x$ to a latent vector $z$, and the decoder reconstructs it as $\bar{x}$.
  2. The Loss Network: They employ a pre-trained VGG-19 network (originally trained for ImageNet classification) as a fixed "loss network."
  3. Feature Perceptual Loss: Both the original image and the reconstructed image are passed through the VGG-19. The model then calculates the difference between their hidden layer representations (feature maps).
  4. Lower layers capture basic shapes and colors.
  5. Higher layers capture complex semantic structures (like eyes or smiles).
  6. Optimization: The total loss is a weighted sum of the KL Divergence (which regularizes the latent space) and the multi-layer feature reconstruction loss.
Model Overview showing the VAE and the VGG-19 loss network

Datasets

The model was trained and evaluated on the CelebA (CelebFaces Attributes) Dataset.

  • Scale: 202,599 face images.
  • Annotations: 5 landmark locations and 40 binary attributes (e.g., "Smiling," "Wearing Glasses," "Male").
  • Preprocessing: Images were cropped and scaled to $64 \times 64$ pixels.

Key Insights and Ideas

  • Semantic Consistency: By using a network trained for classification (VGG), the VAE is forced to preserve features that are "meaningful" for recognizing objects. This ensures the output preserves spatial correlations and natural visual appearance.
  • Latent Space Arithmetic: The learned latent space ($z$) is remarkably linear. You can perform "vector arithmetic" on faces. For instance, taking the latent vector of a non-smiling face and adding a "smiling vector" (calculated from the mean difference of smiling vs. non-smiling latent codes) successfully adds a smile to the generated image.
  • Beyond Generation: The latent representations are so high-quality that they can be used directly for other tasks. The authors used the latent vectors to train simple SVM classifiers for facial attribute prediction, proving the VAE learned a deep understanding of the data.
Linear interpolation between latent vectors showing smooth transitions

Key Results

  • Qualitative Quality: Compared to a "Plain VAE" (PVAE), the proposed model produces much clearer facial features (eyes, noses, teeth). While GANs (like DCGAN) produce sharp images, they often suffer from "weird" facial distortions; the Feature Consistent VAE maintains better overall structural integrity.
  • Attribute Prediction: The model achieved an average accuracy of 86.95% across 40 facial attributes. This outperformed several specialized baselines (like FaceTracer and PANDA) and was nearly identical to the state-of-the-art LNets+ANet (87.30%), despite the VAE being an unsupervised generative model.
  • Clustering: Using t-SNE to visualize the latent space, the authors found that the model naturally clusters images by background color, gender, and even head pose (looking left vs. right) without any explicit labels.

Limitations and Future Work

  • Hair Texture: The authors acknowledge that while eyes and mouths are sharp, human hair remains blurry. They attribute this to the extremely subtle, high-frequency texture of hair that even high-level features struggle to capture perfectly.
  • Weighting Layers: The current model uses a specific set of VGG layers (relu1_2, relu2_1, etc.). Future work could explore more optimal weighting or combinations of these layers.
  • Hybrid Models: A promising direction mentioned is combining this perceptual loss with Generative Adversarial Networks (GANs) to leverage the stability of VAEs with the high-frequency detail of GANs.

Summary updated

BibTeX
@inproceedings{hou2017deep,
  author = {Xianxu Hou and LinLin Shen and Ke Sun and Guoping Qiu},
  title = {{Deep Feature Consistent Variational Autoencoder}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2017},
  url = {https://openreview.net/forum?id=wck7eWbyK_t},
}
Figure