For anomaly detection (AD), early approaches often train separate models for individual classes, yielding high performance but posing challenges in scalability and resource management. Recent efforts have shifted toward training a single model capable of handling multiple classes. However, directly extending early AD methods to multi-class settings often results in degraded performance.
In this paper, we investigate this performance degradation observed in reconstruction-based methods, identifying the key issue: inter-class confusion. This confusion emerges when a model trained in multi-class scenarios incorrectly reconstructs samples from one class as another, thereby exacerbating reconstruction errors. To this end, we propose a simple yet effective modification, called class-aware contrastive learning (CCL). By explicitly leveraging raw object category information (e.g., carpet or wood) as supervised signals, we introduce local CL to refine multiscale dense features, and global CL to obtain more compact feature representations of normal patterns, thereby effectively adapting the models to multi-class settings. Experiments across five datasets validate the effectiveness of our approach, demonstrating significant improvements and superior performance compared to state-of-the-art methods. Notably, ablation studies indicate that pseudo-class labels can achieve comparable performance.
(This is version 2 of the paper, which includes additional experiments and analysis, compared to the first version (V1: Revitalizing Reconstruction Models for Multi-class Anomaly Detection via Class-Aware Contrastive Learning ).)
We focus on the question: "Why do one-for-one models degrade when trained on multiple classes?". Specifically, previous AD methods, such as RD, DeSTSeg, SimpleNet, DRAEM, perform well yet training different models for different categories. We refer to such training strategy one-for-one models, which is challenging to handle due to computational cost and model management. However, when directly trianing these one-for-one models on multiple classes, the performance will decrease significantly.
We found two issues when training one-for-one models on multiple classes:
# we will update the BibTex citation once the camera-ready version is available
@article{fan2024revitalizing,
title={Revitalizing Reconstruction Models for Multi-class Anomaly Detection via Class-Aware Contrastive Learning},
author={Fan, Lei and Huang, Junjie and Di, Donglin and Su, Anyang and Pagnucco, Maurice and Song, Yang},
journal={arXiv preprint arXiv:2412.04769},
year={2024}
}