NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SoftPatch: Unsupervised Anomaly Detection with Noisy Data

Xi Jiang, Jianlin Liu, Jinbao Wang, Qiang Nie, Kai Wu, Yong Liu, Chengjie Wang, Feng Zheng

In the ideal world of academic research, unsupervised anomaly detection (AD) starts with a perfectly clean set of "normal" images. In the messy reality of a factory floor, however, that "clean" training set often contains a few defects that slipped through the cracks.

Presented at NeurIPS 2022, SoftPatch addresses this gap. It is a memory-based anomaly detection method designed to remain accurate even when its training data is contaminated with the very anomalies it is supposed to detect.

The Problem: Overconfidence in Coresets

Most unsupervised sensory AD algorithms—like those used in industrial quality inspection—are "one-class" learners. They look at a pile of normal images, learn what constitutes normal, and then flag anything that deviates from that baseline.

The core problem with applying these models to real-world data is overconfidence. Modern state-of-the-art methods, such as PatchCore, use a "coreset" (a representative subset of image features) to build a memory bank. Because these methods try to cover the entire distribution of the training set, they are ironically very good at picking up and memorizing the few anomalous samples hidden in a noisy training set.

When a similar anomaly appears during testing, the model thinks, "I've seen this in my 'normal' training set before!" and fails to flag it.

Conceptual comparison between previous coreset methods and SoftPatch.

The SoftPatch Architecture

SoftPatch introduces a patch-level denoising and soft-reweighting strategy to protect anomaly detection models from noisy training data. It builds upon the popular PatchCore architecture but adds three critical layers of defense:

The overall architecture of the SoftPatch framework.

1. Patch-Level Denoising

Instead of discarding an entire image because it might be noisy, SoftPatch operates on individual feature patches. Since defects usually occupy only a tiny area of an image, this allows the model to keep the "normal" parts of a noisy image while throwing away the "bad" parts. This patch-level approach is significantly more data-efficient than image-level denoising.

2. Noise Discriminators

Before building the memory bank, SoftPatch evaluates every patch using a noise discriminator to identify outliers. The authors tested three types of discriminators:

  • Nearest Neighbor: Measures the distance to other patches.
  • Multi-Variate Gaussian: Models the distribution of patches at each spatial location.
  • Local Outlier Factor (LOF): A density-based outlier detector. LOF proved to be the most effective because it accounts for varying densities in feature space. While simple distance-based metrics might mistakenly flag naturally spread-out "normal" features as noise, LOF recognizes these inherent density differences.

3. Soft Re-weighting

Instead of a hard "in or out" decision for the memory bank, patches are assigned "soft weights" based on their outlier scores. During inference, the final anomaly score is adjusted by these weights. This softens the decision boundary, ensuring that even if a slightly suspicious patch makes it into the memory bank, it won't easily trigger a "normal" classification for a test anomaly.

Datasets and Key Insights

The authors evaluated SoftPatch on two primary benchmarks:

  • MVTecAD: The industry standard for anomaly detection. To test noise robustness, they created MVTecAD-noise-n, intentionally injecting anomalous images into the training set at various ratios (up to 15%).
  • BTAD (BeanTech Anomaly Detection): A real-world industrial dataset. Interestingly, the authors found that the "clean" training set of BTAD already contained inherent noise (small scratches), making it a perfect natural test case.

A major insight from the paper is highlighting the Greedy Sampling Trap. Greedy sampling, used by PatchCore to select a coreset, is a double-edged sword. While it ensures high coverage of normal data, it is mathematically biased toward selecting outliers, making it highly vulnerable to noise without a mechanism like SoftPatch to filter them out.

Key Results

SoftPatch demonstrates remarkable resilience in contaminated scenarios while remaining highly competitive on clean data:

  • Robustness to Injected Noise: On MVTecAD with 10% noise, SoftPatch-LOF maintained an Image-level AUROC of 0.982. In stark contrast, the previous state-of-the-art (PatchCore) plummeted to 0.683 in the "Overlap" setting (where similar anomalies exist in both training and test sets).
  • New SOTA on BTAD: SoftPatch achieved a mean AUROC of 0.977 on the original BTAD dataset, surpassing all previous methods. This suggests SoftPatch is inherently better at handling the subtle, unintentional noise found in real-world "clean" datasets.
  • No Penalty for Cleanliness: In scenarios with 0% noise, SoftPatch's performance is comparable to PatchCore, meaning there is virtually no performance penalty for using this more robust architecture.

Limitations and Future Work

While highly effective, SoftPatch does have limitations. The authors used a fixed noise threshold across all experiments, but the optimal threshold might vary depending on the specific industrial application and expected contamination levels. Additionally, calculating LOF for every patch adds computational overhead during the memory bank construction phase, though it remains much faster than methods requiring long training epochs.

Looking forward, the authors suggest moving toward a "fully unsupervised" setting where there is no distinction between training and test sets—paving the way for systems that can learn to detect anomalies continuously from a stream of completely unlabelled data.

Summary updated

BibTeX
@inproceedings{jiang2022softpatch,
  author = {Xi Jiang and Jianlin Liu and Jinbao Wang and Qiang Nie and Kai Wu and Yong Liu and Chengjie Wang and Feng Zheng},
  title = {{SoftPatch: Unsupervised Anomaly Detection with Noisy Data}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=TqPFi5h5y_},
}
Figure