Abstract
For anomaly detection (AD), early approaches often train separate models forindividual classes, yielding high performance but posing challenges inscalability and resource management. Recent efforts have shifted towardtraining a single model capable of handling multiple classes. However, directlyextending early AD methods to multi-class settings often results in degradedperformance. In this paper, we investigate this performance degradationobserved in reconstruction-based methods, identifying the key issue:inter-class confusion. This confusion emerges when a model trained inmulti-class scenarios incorrectly reconstructs samples from one class as thoseof another, thereby exacerbating reconstruction errors. To this end, we proposea simple yet effective modification, called class-aware contrastive learning(CCL). By explicitly leveraging raw object category information (\eg carpet orwood) as supervised signals, we introduce local CL to refine multiscale densefeatures, and global CL to obtain more compact feature representations ofnormal patterns, thereby effectively adapting the models to multi-classsettings. Experiments across five datasets validate the effectiveness of ourapproach, demonstrating significant improvements and superior performancecompared to state-of-the-art methods. Notably, ablation studies indicate thatpseudo-class labels can achieve comparable performance.