Mean-Shifted Contrastive Loss for Anomaly Detection
Tal Reiss, Yedid Hoshen
Abstract
Deep anomaly detection methods learn representations that separate between normal and anomalous images. Although self-supervised representation learning is commonly used, small dataset sizes limit its effectiveness. It was previously shown that utilizing external, generic datasets (e.g. ImageNet classification) can significantly improve anomaly detection performance. One approach is outlier exposure, which fails when the external datasets do not resemble the anomalies. We take the approach of transferring representations pre-trained on external datasets for anomaly detection. Anomaly detection performance can be significantly improved by fine-tuning the pre-trained representations on the normal training images. In this paper, we first demonstrate and analyze that contrastive learning, the most popular self-supervised learning paradigm cannot be naively applied to pre-trained features. The reason is that pre-trained feature initialization causes poor conditioning for standard contrastive objectives, resulting in bad optimization dynamics. Based on our analysis, we provide a modified contrastive objective, the Mean-Shifted Contrastive Loss. Our method is highly effective and achieves a new state-of-the-art anomaly detection performance including 98.6% ROC-AUC on the CIFAR-10 dataset.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers25
- AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly DetectionQihang Zhou, Guansong Pang, Yu Tian, Shibo He et al.ICLR 2024 · 380 citations
- Deep One-Class Classification via Interpolated Gaussian DescriptorYuanhong Chen, Yu Tian, Guansong Pang, Gustavo CarneiroAAAI 2022 · 139 citations
- PointAD: Comprehending 3D Anomalies from Points and Pixels for Zero-shot 3D Anomaly DetectionQihang Zhou, Jiangtao Yan, Shibo He, Wenchao Meng et al.NeurIPS 2024 · 49 citations
- Focus the Discrepancy: Intra- and Inter-Correlation Learning for Image Anomaly DetectionXincheng Yao, Ruoqi Li, Zefeng Qian, Yan Luo et al.ICCV 2023 · 48 citations
- Invariant Anomaly Detection under Distribution Shifts: A Causal PerspectiveJoão B. S. Carvalho, Mengtao Zhang, Robin Geyer, Carlos Cotrini et al.NeurIPS 2023 · 18 citations
Builds on8
- A Simple Framework for Contrastive Learning of Visual RepresentationsTing Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey E. HintonICML 2020 · 24,064 citations
- Understanding Contrastive Representation Learning through Alignment and Uniformity on the HypersphereTongzhou Wang, Phillip IsolaICML 2020 · 2,360 citations
- CSI: Novelty Detection via Contrastive Learning on Distributionally Shifted InstancesJihoon Tack, Sangwoo Mo, Jongheon Jeong, Jinwoo ShinNeurIPS 2020 · 755 citations
- Classification-Based Anomaly Detection for General DataLiron Bergman, Yedid HoshenICLR 2020 · 412 citations
- Detecting Semantic AnomaliesFaruk Ahmed, Aaron C. CourvilleAAAI 2020 · 93 citations
Related papers
- ADPretrain: Advancing Industrial Anomaly Detection via Anomaly Representation PretrainingXincheng Yao, Yan Luo, Zefeng Qian, Chongyang ZhangNeurIPS 2025 · 6 citations
- Efficient Visual Pretraining with Contrastive DetectionOlivier J. Hénaff, Skanda Koppula, Jean-Baptiste Alayrac, Aäron van den Oord et al.ICCV 2021 · 186 citations
- ReContrast: Domain-Specific Anomaly Detection via Contrastive ReconstructionJia Guo, Shuai Lu, Lize Jia, Weihang Zhang et al.NeurIPS 2023 · 124 citations
- Contrastive Out-of-Distribution Detection for Pretrained TransformersWenxuan Zhou, Fangyu Liu, Muhao ChenEMNLP 2021 · 63 citations
- Boost Supervised Pretraining for Visual Transfer Learning: Implications of Self-Supervised Contrastive Representation LearningJinghan Sun, Dong Wei, Kai Ma, Liansheng Wang et al.AAAI 2022 · 5 citations
