Adversarially Robust Few-Shot Anomaly Detection with Vision Foundation Models

summary

Video file (mp4)

The gist

The gist The study introduces an adversarially robust Few-Shot Anomaly Detection method that utilizes frozen Vision Foundation Models and a novel two-level defense pipeline to achieve significant

In short

The study introduces a robust few-shot anomaly detection method using frozen Vision Foundation Models. It solves the problem of attacking non-parametric scorers by creating a differentiable surrogate called DistanceProbe. This enables strong gradient-based attacks, and it uses a two-level defense (PatchShift and FeaturePurifier) to significantly boost robustness against adversarial attacks while preserving clean performance.

Key concepts

DistanceProbe (DP)
A lightweight MLP trained to predict the k-NN distances between patches directly from frozen foundation model features. This allows researchers to create a differentiable surrogate for the non-parametric scoring function, making it possible to craft effective gradient-based adversarial attacks against the anomaly detector.
PatchShift (PS)
The first defense layer that applies random pixel shifts to images. This technique exploits the mismatch between where adversarial noise lands and how the foundation model's patch grid is organized. It aggregates scores from these shifted views to create a more stable anomaly map.
FeaturePurifier (FP)
A second defense layer consisting of a residual MLP trained on clean and augmented features. Its goal is to project perturbed feature representations back onto the 'clean' feature manifold, effectively removing adversarial noise while ensuring that the original clean features remain unchanged.

Terminology used across episodes

This episode discusses

The paper

Adversarially Robust Few-Shot Anomaly Detection with Vision Foundation Models · Read on arXiv

Akib Mohammed Khan, Bartosz Krawczyk

Rochester Institute of Technology

Vision foundation models such as DINOv2 enable strong few-shot anomaly detection (FSAD) through simple non-parametric k-nearest-neighbor (k-NN) scoring over frozen patch features. Existing robust anomaly detection methods assume large normal-class training sets and adversarial training of the feature extractor. The few-shot regime, where the detector consists of a frozen backbone and a non-parametric scorer, has remained unaddressed despite its widespread deployment. We develop a white-box attack framework adapted to k-NN memory-bank detectors and introduce an adversarially robust FSAD method which is training-free with respect to the backbone. We introduce the DistanceProbe (DP), a lightweight MLP trained by regression to predict per-patch k-NN distance directly from frozen features, providing the differentiable proxy required for gradient-based attacks against non-parametric scorers. We further propose a two-level combined defense that operates using only the normal reference support set images. At the input level, PatchShift (PS) applies random pixel shifts to exploit the misalignment of adversarial perturbations with the encoder's patch grid, aggregating scores across multiple shifted views via element-wise median pooling. At the feature level we employ the FeaturePurifier (FP), a lightweight residual MLP trained on clean and adversarially augmented support features to project perturbed representations back toward the clean feature manifold. Through comprehensive experiments under various adversarial settings, we show that our method exhibits robust detection and localization with performance gains of 27% image-level AUROC and 51% pixel-level PRO over the undefended attacked baseline across MVTec-AD, VisA, and MPDD at k=4 shots, while preserving clean accuracy within 3%, matching full-shot adversarially-trained baselines on pixel-level AUROC, and holding under adaptive attack.

Transcript

Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.

Tom: Hi, I'm Tom.

Jane: And I'm Jane, here with Lu, Meng and our in-house large language model, Lalam.

Tom: We're looking at the paper: "Adversarially Robust Few-Shot Anomaly Detection with Vision Foundation Models".

Jane: Here's the gist of the paper. The gist The study introduces an adversarially robust Few-Shot Anomaly Detection method that utilizes frozen Vision Foundation Models and a novel two-level defense pipeline to achieve significant robustness against strong gradient-based attacks in few-shot anomaly detection settings.

Tom: Problem Statement Existing robust anomaly detection methods assume access to large normal-class training sets and adversarial training of the feature extractor, which is incompatible with the few-shot regime where detectors consist of a frozen backbone and a non-parametric scorer <ref:2510.13643#pg6>.

Jane: The adversarial robustness of few-shot, foundation-model-based anomaly detectors has therefore remained an open question despite their practical prevalence <ref:2510.13643#pg5>.

Tom: Addressing this gap is non-trivial because evaluating robustness requires a strong gradient-based attack, but the non-parametric k-NN scorer is only piecewise differentiable through its active minimizer <ref:2510.13643#pg8>.

Title and authors: Tom: Now that we know they have this attack tool, let's look at what the paper actually proposes as a defense against those attacks. They introduce a two-level defense pipeline operating only on the k support images, which is quite specific.

Jane: So it’s not trying to fix the backbone itself; it’s focusing all its effort on defending the scoring stage using just what you have available in the few-shot set.

Lu: The first level of defense is PatchShift, which exploits how adversarial perturbations are coupled to the Vision Transformer's patch grid by applying random pixel shifts and then aggregating scores via element-wise median pooling across those shifted views.

Meng: So it’s trying to break the alignment between the attack and how the model sees things by just cropping and shifting a few images?

Lalam: And for the second level, they have FeaturePurifier, which is a lightweight residual MLP trained on clean and adversarially augmented support features to project those perturbed representations back toward what they consider the clean feature manifold.

The paper's summary: Tom: The main point of this paper is that by combining these two specific defenses, PatchShift and FeaturePurifier, they achieve robust detection and localization with performance gains of about twenty-seven percent image-level AUROC and about fifty-one percent pixel-level PRO over the undefended attacked baseline on benchmarks like MVTec-AD, VisA, and MPDD at k=four shots <ref:2510.13643#pg2>.

Jane: That's a pretty concrete number to look at; they show that this combined defense recovers substantial robustness across all those datasets and shot counts without sacrificing too much clean performance.

Lu: What’s interesting is how the defense holds up under adaptive attacks, specifically mentioning the EOT-BPDA attack, which suggests it’s not just robust against a single type of adversarial noise.

Meng: It's good to hear that it holds up against those stronger adaptive attacks because those are often what you see in more real-world deployment scenarios where attackers aren't just using simple PGD.

Lalam: The ablation study confirms that the combination of PatchShift plus FeaturePurifier is preferable for industrial inspection settings because it substantially improves pixel-level localization while preserving spatial structure in the anomaly map.

The paper's improvements: Tom: So what are the actual improvements they are highlighting? They’re focusing on making detection robust without needing to train the backbone, which is a big deal for practical use cases.

Jane: They introduced three main areas of improvement: first, creating a white-box attack framework using DistanceProbe so you can test robustness against k-NN scorers; second, developing the two-level defense pipeline with PatchShift and FeaturePurifier; and third, showing that this combination works across different vision backbones.

Lu: The key improvement there is formalizing adversarial robustness for few-shot anomaly detection with frozen vision foundation models by introducing a tractable attack surrogate and a two-level defense that operates without backbone training.

Meng: That training-free aspect is critical for us because if we can deploy this on top of a large, already trained model like DINOv2, we avoid the massive cost of retraining the feature extractor.

Lalam: They also show that they achieve pixel level localization performance matching or exceeding full shot adversarially trained baselines on MPDD at k=four shots, which points to a superior ability to identify precise defective regions in industrial imagery under attack <ref:2510.13643#pg2>.

Conclusion: Tom: Wrapping up, the paper presents the first adversarial robustness framework for few-shot anomaly detection with frozen vision foundation models, showing that this approach is viable in practice.

Jane: The big implication here is that you don't need a huge normal dataset to build a robust detector if you can introduce these specific tools like DistanceProbe and the PatchShift plus FeaturePurifier defense.

Lu: They successfully formalized adversarial robustness for this setting, demonstrating that the combination of PS+FP recovers substantial robustness while preserving clean accuracy within about three points compared to full-shot adversarially trained baselines on pixel-level AUROC at k=four <ref:2510.13643#pg2>.

Meng: For deployment, the preference for PatchShift plus FeaturePurifier is clear because it really helps with localizing those defective regions, which is the main goal in inspection tasks.

Lalam: So to summarize, the DistanceProbe surrogate enables strong PGD attacks on non-parametric k-NN scorers and their two-stage defense recovers substantial robustness on MVTec-AD, VisA, and MPDD while preserving clean accuracy and matching full shot adversarially trained baselines at k=four <ref:2510.13643#pg2>.

More episodes

← Home