NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Context-encoding Variational Autoencoder for Unsupervised Anomaly Detection -- Short Paper

David Zimmerer, Simon Köhl, Jens Petersen, Fabian Isensee, Klaus Maier‐HeinarXiv 2019 · DOI

Abstract

Unsupervised learning can leverage large-scale data sources without the need for annotations. In this context, deep learning-based autoencoders have shown great potential in detecting anomalies in medical images. However, especially Variational Autoencoders (VAEs) often fail to capture the high-level structure in the data. We address these shortcomings by proposing the context-encoding Variational Autoencoder (ceVAE), which improves both, the sample, as well as pixelwise results. In our experiments on the BraTS-2017 and ISLES-2015 segmentation benchmarks the ceVAE achieves unsupervised AUROCs of 0.95 and 0.89, respectively, thus outperforming other reported deep-learning based approaches.

Introduction

Supervised deep learning has revolutionized medical image analysis, particularly in segmentation tasks. However, the reliance on large, pixel-perfect annotated datasets remains a significant barrier to clinical deployment. Unsupervised anomaly detection (UAD) offers a compelling alternative by training models exclusively on healthy data. Under this paradigm, pathologies are identified as deviations from the learned "normal" distribution.

Variational Autoencoders (VAEs) are a popular choice for UAD. Ideally, a VAE trained on healthy brains should fail to accurately reconstruct a tumor, thereby highlighting it. In practice, however, VAEs often suffer from "posterior collapse," where the latent space becomes uninformative, leading to blurry reconstructions that lack high-level anatomical detail. This ambiguity makes it difficult to distinguish between benign reconstruction artifacts and true pathological anomalies.

The ceVAE Framework

To overcome these limitations, we introduce the context-encoding Variational Autoencoder (ceVAE). The core innovation lies in a hybrid training objective that combines standard VAE reconstruction with a context-encoding (CE) task.

The ceVAE architecture integrates a standard VAE path with a context-encoding task to force the model to learn high-level structural features.

As shown in the architecture diagram, the model processes both the original input $x$ and a corrupted version $\tilde{x}$. By requiring the model to "fill in" or inpaint missing information from $\tilde{x}$, we force the latent variables to capture more discriminative, high-level features. This effectively prevents posterior collapse; analysis shows that the ceVAE utilizes significantly more latent variables (KL-divergence of 2.93) compared to a standard VAE (0.53).

Anomaly Detection Strategy

Detecting anomalies at the pixel level requires a robust scoring mechanism. We propose a synergistic approach that combines two distinct signals:

  1. Reconstruction Error: Measures the pixel-wise difference between the input and its reconstruction. This captures regions where the image looks different than what the model expected.
  2. KL-Gradient: The derivative of the KL-divergence with respect to the input, indicating how much a specific region forces the latent variables into an unlikely state.
Qualitative results demonstrating the synergy between reconstruction error and KL-gradient in identifying anomalies across different MRI slices.

The final anomaly map is a pixel-wise multiplication of these two signals. As illustrated in the visual results, while reconstruction error alone can be noisy, its combination with the KL-gradient effectively filters out false positives, resulting in a cleaner and more accurate anomaly map.

Experimental Results

The ceVAE was trained on 2D T2-weighted MRI slices from the Human Connectome Project (HCP) dataset, consisting of 1,092 healthy subjects. Evaluation was performed on two challenging benchmarks: BraTS-2017 (brain tumors) and ISLES-2015 (ischemic strokes).

The model achieved state-of-the-art unsupervised performance, with slice-wise AUROCs of 0.95 on BraTS-2017 and 0.89 on ISLES-2015. Furthermore, on the BraTS dataset, the ceVAE reached a Dice score of 0.52. While this remains below supervised benchmarks, it represents a substantial improvement for unsupervised methods and demonstrates the model's ability to localize complex pathologies without prior exposure to labeled examples.

Conclusion

The ceVAE addresses the fundamental weaknesses of standard VAEs in unsupervised anomaly detection by incorporating context-driven feature learning. By preventing posterior collapse and utilizing a dual-signal scoring mechanism, the model achieves superior performance in identifying and segmenting medical anomalies. Future work will explore extending this framework to 3D volumetric data and higher resolutions to further improve diagnostic accuracy.

Summary updated

BibTeX
@misc{zimmerer2019context,
  author = {David Zimmerer and Simon Köhl and Jens Petersen and Fabian Isensee and Klaus Maier‐Hein},
  title = {{Context-encoding Variational Autoencoder for Unsupervised Anomaly Detection -- Short Paper}},
  year = {2019},
  eprint = {1907.12258},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1907.12258},
}
Figure