CNC: Cross-modal Normality Constraint for Unsupervised Multi-class Anomaly Detection

Xiaolei Wang, Xiaoyang Wang, Huihui Bai, Eng Gee Lim, Jimin Xiao

Abstract

Multi-class anomaly detection (AD) faces the challenge of "over-generalization," where models trained on diverse normal samples inadvertently learn to reconstruct defects. We present CNC (Cross-modal Normality Constraint), a framework that anchors the concept of normality using learnable, class-agnostic text prompts. By combining this cross-modal constraint with a Gated Mixture-of-Experts (MoE) architecture and Feature-level Normality Promotion (FNP), CNC effectively distinguishes anomalies from normal patterns. Our method achieves state-of-the-art results on MVTec AD and VisA, reaching 98.6% and 93.2% Image-level AUROC, respectively.

Introduction

Industrial visual anomaly detection (AD) is transitioning from category-specific models to multi-class systems capable of detecting defects across various products simultaneously. While Reverse Distillation (RD) is a leading technique, multi-class training often leads to "over-generalization." In this scenario, the student decoder becomes so proficient at reconstructing diverse normal patterns that it also successfully reconstructs unseen abnormal patches. This reduces the reconstruction error for defects, making them nearly invisible to the detection system.

Methodology

The CNC framework introduces three key components to mitigate over-generalization:

  1. Cross-modal Normality Constraint (CNC): This component utilizes CLIP's shared textual-visual space. By employing learnable, class-agnostic prompts like "a photo of a normal [object]," the model establishes a universal linguistic anchor for normality. This forces the visual decoder to align its reconstructions with a consistent conceptual definition of "normal," regardless of the specific object class.
  2. Feature-level Normality Promotion (FNP): FNP calculates a normality score by comparing visual features to the learned text prompts. This score is used to modulate visual features, amplifying signals from normal regions and increasing the model's sensitivity to the lack of normality in defective areas.
  3. Gated Mixture-of-Experts (MoE): To address the high intra-class variance in multi-class datasets, the authors replace the standard bottleneck with an MoE module. A router network directs patches to specialized "expert" sub-networks, reducing inter-class interference and preventing the "average" reconstructions that contribute to over-generalization.
Figure 4: Correspondence between modalities and the motivation for cross-modal constraints.

Experiments and Results

The CNC framework was evaluated on the MVTec AD and VisA benchmarks. MVTec AD consists of 15 industrial categories, while VisA includes 12 categories with more complex defect patterns.

CNC demonstrated superior performance across multiple metrics. On MVTec AD, it achieved a mean performance of 89.0 across five key metrics, including a near-perfect 98.6% Image-level AUROC. On the more challenging VisA dataset, CNC reached 93.2% I-AUROC, significantly outperforming previous state-of-the-art models like UniAD and DiAD.

Figure 6: Comprehensive comparison of CNC against other state-of-the-art methods on the MVTec AD dataset.

Discussion and Conclusion

The primary innovation of CNC is the use of language as a stabilizing anchor for the concept of "normality." While visual textures vary significantly across industrial parts, the linguistic definition of a "normal" or "damaged" object remains consistent. By remaining class-agnostic, the model avoids memorizing specific defects and instead learns a generalizable representation of anomaly. Although the MoE architecture and CLIP backbone increase computational complexity, the resulting improvements in detection accuracy and reduction in false positives represent a significant advancement for multi-class industrial anomaly detection.

Summary updated

Abstract

Existing unsupervised distillation-based methods rely on the differences between encoded and decoded features to locate abnormal regions in test images. However, the decoder trained only on normal samples still reconstructs abnormal patch features well, degrading performance. This issue is particularly pronounced in unsupervised multi-class anomaly detection tasks. We attribute this behavior to ‘over-generalization’ (OG) of decoder: the significantly increasing diversity of patch patterns in multi-class training enhances the model generalization on normal patches, but also inadvertently broadens its generalization to abnormal patches. To mitigate ‘OG’, we propose a novel approach that leverages class-agnostic learnable prompts to capture common textual normality across various visual patterns, and then apply them to guide the decoded features towards a ‘normal’ textual representation, suppressing ‘over-generalization’ of the decoder on abnormal patterns. To further improve performance, we also introduce a gated mixture-of-experts module to specialize in handling diverse patch patterns and reduce mutual interference between them in multi-class training. Our method achieves competitive performance on the MVTec AD and VisA datasets, demonstrating its effectiveness.
BibTeX
@inproceedings{wang2025cnc,
  author = {Xiaolei Wang and Xiaoyang Wang and Huihui Bai and Eng Gee Lim and Jimin Xiao},
  title = {{CNC: Cross-modal Normality Constraint for Unsupervised Multi-class Anomaly Detection}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i8.32856},
}
Figure