Discriminative-Generative Representation Learning for One-Class Anomaly Detection

Xuan Xia, Xizhou Pan, Xing He, Jingfei Zhang, Ning Ding, Lin Ma · DOI

Abstract

One-Class Anomaly Detection (OCAD) typically relies on either generative reconstruction or discriminative self-supervised learning. While generative methods often fail to capture high-level semantics, discriminative methods suffer from high computational costs during inference. This paper introduces DGAD (Discriminative-Generative Anomaly Detection), a hybrid framework that uses a discriminator to guide a generator through semantic pretext tasks. By forcing the generator to learn abstract features, DGAD achieves state-of-the-art performance on benchmarks like CIFAR-10 and MVTec AD while maintaining high inference speeds.

Introduction

One-Class Anomaly Detection (OCAD) is the task of training a model on a single "normal" class to identify outliers during testing. Traditional approaches are divided into two paradigms: generative methods, which use reconstruction error as an anomaly score, and discriminative methods, which leverage self-supervised pretext tasks to learn robust features.

Generative models, such as GANs and Autoencoders, often over-focus on low-level pixel details, potentially reconstructing anomalies too well or failing to grasp the semantic structure of the data. Conversely, discriminative methods are semantically rich but computationally expensive, often requiring multiple augmented passes of a single image to compute a normality score. DGAD bridges this gap by integrating the strengths of both approaches into a unified framework.

Methodology

The core of DGAD is a hybrid architecture where a discriminator acts as a "semantic teacher" for a generator.

Comparison of (a) Generative, (b) Discriminative, and (c) the proposed Discriminative-Generative methods.

The Guidance Mechanism

Unlike standard GANs where the generator only tries to fool the discriminator's "real vs. fake" judgment, DGAD's discriminator ($D$) also functions as a classifier ($D_{cls}$) for pretext tasks. The generator is tasked with producing reconstructions that not only look realistic but also allow the discriminator to correctly identify their semantic transformations (e.g., rotation angle). This forces the generator to encode high-level geometric and structural information into its latent representations.

Pretext Tasks and Semantic Ambiguity

Common pretext tasks include predicting image rotations or solving jigsaw puzzles. These tasks help the model understand the spatial arrangement of objects.

Examples of geometric pretext tasks: rotation and flipping used to train the discriminative-generative model.

The authors address "label semantic ambiguity"—where a transformation (like rotating a circle) doesn't change the image—by introducing tasks like Jigsaw puzzles that focus on relative spatial positions. Additionally, they found that standard zero-padding can allow the discriminator to "cheat" by using edge artifacts; switching to symmetry padding forces the model to learn more meaningful internal features.

Experiments and Results

The framework was evaluated on MNIST, CIFAR-10, and the MVTec AD industrial dataset.

  • Performance: DGAD significantly outperformed GAN-based baselines, showing a 6% improvement on CIFAR-10 and a 2% gain on MVTec AD. On MNIST, the model achieved a near-perfect mean AUC of 0.9864.
  • Efficiency: By using a simple reconstruction error ($s_{rec}$) for inference, DGAD is 3.6x to 8.5x faster than purely discriminative methods that rely on complex scoring mechanisms, with minimal loss in detection accuracy.

Conclusion

DGAD successfully combines the semantic power of discriminative self-supervision with the efficiency of generative reconstruction. By repurposing the discriminator as a guide for feature learning, the model overcomes the limitations of traditional GAN-based anomaly detection. Future work will focus on improving sensitivity to fine-grained texture anomalies and very small defects, which remain challenging for reconstruction-based scores.

Summary updated

BibTeX
@misc{xia2021discriminative,
  author = {Xuan Xia and Xizhou Pan and Xing He and Jingfei Zhang and Ning Ding and Lin Ma},
  title = {{Discriminative-Generative Representation Learning for One-Class Anomaly Detection}},
  year = {2021},
  eprint = {2107.12753},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.12753},
}
Figure