Introduction
Few-Shot Anomaly Detection (FSAD) has seen significant advancements through the use of Vision Foundation Models (VFMs) like DINOv2. By extracting rich features and employing simple nearest-neighbor searches, these models can identify defects with high accuracy using minimal "normal" reference data. However, as these systems move into safety-critical industrial applications, two critical "trust gaps" emerge: adversarial vulnerability and a lack of uncertainty calibration. This paper investigates the fragility of DINOv2-based FSAD to imperceptible perturbations and proposes Platt scaling as a mechanism for both calibration and attack detection.
Methodology
The study utilizes AnomalyDINO, a training-free detector, as its baseline. To address the non-differentiable nature of k-Nearest Neighbor (k-NN) logic, the authors developed a novel "Probe" attack.
The "Probe" Attack
Since gradients cannot be easily backpropagated through a k-NN search, a lightweight linear "probe" head is attached to the frozen DINOv2 features. This probe is used to generate adversarial perturbations via the Fast Gradient Sign Method (FGSM). The resulting attacked image is then evaluated against the original k-NN detector.
Calibration and Uncertainty
To transform raw distance-based anomaly scores into interpretable probabilities, the researchers applied Platt scaling. This involves fitting a logistic regression model to a small validation set of scores. Furthermore, the calibrated probabilities allow for the calculation of predictive entropy, which serves as a measure of the model's uncertainty.
Experimental Results
The approach was evaluated on the MVTec-AD and VisA datasets, representing gold-standard benchmarks for industrial inspection.
Adversarial Vulnerability
Results indicate that DINOv2-based FSAD is highly susceptible to adversarial attacks. On MVTec-AD (4-shot), the AUROC plummeted from 97.55% to 59.68% under a standard FGSM attack. On the more complex VisA dataset, performance dropped to near-random levels (~52%). This suggests that tiny perturbations can effectively "push" anomaly embeddings into the "normal" cluster in feature space, causing confident misclassifications.
Calibration and Detection
Platt scaling significantly improved the reliability of anomaly scores without altering the ranking of results. In the 1-shot MVTec-AD setting, the Expected Calibration Error (ECE) was reduced from 0.4261 to 0.0536, making the scores far more representative of actual defect probabilities.
Crucially, predictive entropy was found to be a robust indicator of adversarial tampering. In the 1-shot setting, clean images exhibited a mean entropy of 0.12, whereas adversarial images showed a sharp increase to 0.51. This clear separation allows for the implementation of an entropy-based alarm system to flag potential attacks for human operators.
Conclusion
While DINOv2 provides a powerful foundation for FSAD, its feature space remains brittle. This work demonstrates that simple post-processing techniques like Platt scaling can mitigate interpretability issues and provide a vital signal for detecting adversarial attacks through predictive entropy. Future research will focus on more complex iterative attacks and developing geometry-aware defense mechanisms to enhance the inherent robustness of the feature space.
Summary updated