G2D: Generate to Detect Anomaly

Masoud PourReza, Bahram Mohammadi, Mostafa Khaki, Samir Bouindour, Hichem Snoussi, Mohammad SabokrouWACV 2020

Abstract

Anomaly detection is traditionally framed as a one-class classification problem due to the scarcity of outlier data. The G2D (Generate to Detect) framework redefines this task as a binary classification problem by leveraging Generative Adversarial Networks (GANs) to "hallucinate" synthetic anomalies. By harvesting "imperfect" samples from various stages of the GAN training process—ranging from random noise to subtle boundary cases—G2D creates a robust training set for a dedicated detector. Experimental results on UCSD Ped2, MNIST, and Caltech-256 demonstrate that G2D consistently outperforms state-of-the-art methods, maintaining high performance even in high-outlier scenarios.

Introduction

Anomaly detection is critical in fields like surveillance, medical imaging, and industrial inspection. The primary challenge lies in the inherent imbalance of data: while "normal" samples are abundant, anomalies are rare, diverse, and often unknown at training time. This typically necessitates One-Class Classification (OCC) approaches. While GANs have been employed to model normalcy, they suffer from training instability and the "stopping problem"—determining when the generator has learned the normal distribution without beginning to overfit or produce anomalous-looking samples.

Methodology: The G2D Framework

The G2D framework addresses these issues by intentionally utilizing the generator's intermediate states. It consists of three components: an Irregularity Generator ($I$), a Critic ($C$), and a Detector ($D$).

The G2D framework architecture, illustrating the multi-stage sampling from the generator to create synthetic anomalies for training the binary detector.

The process begins with adversarial training of $I$ and $C$ using a Wasserstein GAN (WGAN) objective on normal data only. Instead of relying solely on the converged generator, G2D samples from $I$ at multiple epochs:

  • Early Stages: Generate samples far from the normal distribution (noise).
  • Intermediate Stages: Generate "boundary" samples that share semantic similarities with the target class but remain distinct.
  • Late Stages: Generate augmented normal samples.

These synthetic samples, combined with real normal data, transform the anomaly detection task into a supervised binary classification problem for the Detector ($D$).

Experimental Results

G2D was evaluated across three distinct types of data, consistently outperforming state-of-the-art (SOTA) methods:

  • Video Anomaly (UCSD Ped2): G2D achieved an Equal Error Rate (EER) of 11%, surpassing previous SOTA methods like ALOCC (13%) and Deep-Anomaly (13%).
  • Image Outliers (MNIST): G2D maintained a high F1-score (above 0.9) even when outliers made up 50% of the data, whereas competing methods like LOF saw performance plummet.
  • Object Detection (Caltech-256): G2D achieved the highest AUC (up to 0.957) compared to six other established methods.
t-SNE visualizations showing the distribution of normal samples (blue) and synthetic/real anomalies (red) across different experimental settings.

Discussion and Key Insights

The core innovation of G2D is treating GAN "imperfections" as a feature rather than a bug. By capturing the evolution of the generator, the model gains exposure to a wide spectrum of potential anomalies—from total noise to subtle boundary cases. This synthesis-based approach simplifies optimization and enhances robustness against varying outlier ratios.

However, the method's reliance on hyperparameter tuning (e.g., sampling frequency) and its current focus on spatial rather than temporal features in video data present opportunities for future research. Incorporating time-based features could further improve results in video surveillance contexts.

Conclusion

G2D offers a pragmatic shift in anomaly detection by "hallucinating" the very outliers it seeks to detect. By reframing OCC as binary classification through multi-stage GAN sampling, it provides a stable and high-performing alternative to traditional unsupervised methods.

Summary updated

BibTeX
@inproceedings{pourreza2020g,
  author = {Masoud PourReza and Bahram Mohammadi and Mostafa Khaki and Samir Bouindour and Hichem Snoussi and Mohammad Sabokrou},
  title = {{G2D: Generate to Detect Anomaly}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2020},
  doi = {10.1109/wacv48630.2021.00205},
}
Figure