ICLR 2025

Published as a conference paper at ICLR 2025
MITIGATING SPURIOUS NEGATIVE PAIRS FOR ROBUST
INDUSTRIAL ANOMALY DETECTION
Hossein Mirzaei1, Mojtaba Nafez2, Jafar Habibi2, Mohammad Sabokrou3, and Mohammad
Hossein Rohban2
1École Polytechnique Fédérale de Lausanne (EPFL), Switzerland
2Sharif University of Technology, Iran
3Okinawa Institute of Science and Technology, Japan
rohban@sharif.edu, hossein.mirzaeisadeghlou@epfl.ch
ABSTRACT
Despite significant progress in Anomaly Detection (AD), the robustness of existing
detection methods against adversarial attacks remains a challenge, compromising
their reliability in critical real-world applications such as autonomous driving. This
issue primarily arises from the AD setup, which assumes that training data is
limited to a group of unlabeled normal samples, making the detectors vulnerable to
adversarial anomaly samples during testing. Additionally, implementing adversar-
ial training as a safeguard encounters difficulties, such as formulating an effective
objective function without access to labels. An ideal objective function for adver-
sarial training in AD should promote strong perturbations both within and between
the normal and anomaly groups to maximize margin between normal and anomaly
distribution. To address these issues, we first propose crafting a pseudo-anomaly
group derived from normal group samples. Then, we demonstrate that adversarial
training with contrastive loss could serve as an ideal objective function, as it cre-
ates both inter- and intra-group perturbations. However, we notice that spurious
negative pairs compromise the conventional contrastive loss to achieve robust AD.
Spurious negative pairs are those that should be closely mapped but are erroneously
separated. These pairs introduce noise and misguide the direction of inter-group
adversarial perturbations. To overcome the effect of spurious negative pairs, we
define opposite pairs and adversarially pull them apart to strengthen inter-group
perturbati...