Traditional unsupervised anomaly detection (UAD) methods are designed to flag or localise deviations from a normative distribution, ignoring the underlying generative mechanisms of the anomalies. Yet the nature of an anomaly is often as important as its presence. We reformulate UAD as a Bayesian inverse problem, in which the objective is to infer the most probable corruption responsible for each observation. Our framework yields a probabilistic anomaly score as the energy of the inferred corruption parameters, and serves as a principled recipe for developing new UAD algorithms. We derive several existing methods as instances of the general framework, each corresponding to the same energy score under different modelling choices. Experimentally, we study the framework's components in a controlled setting, and improve object-class AUROC on the MVTec AD dataset by 2.3% by adapting the underlying corruption model. Finally, we validate the framework on a brain MRI benchmark, achieving strong detection performance while producing estimates of pathology intensity, bias, and geometry. Code is available at https://github.com/jgmyles/inverse-uad.
Figures & tables
Figure 1: Qualitative corruption inference for MorphoMNIST [ morpho ] digits and BraTS-T2, BraTS-T1 [ brats1 , brats2 , brats3 ] and ATLAS [ atlas ] brain MRI scans. Rows show, from top to bottom: the observed image, anomaly parameter samples from the posterior estimator, and the de-corrupted sample corresponding to the posterior mode x∗ . Posterior sample are indicated by dots coloured from green to red by inferred severity, defined as swelling strength γ for MorphoMNIST and max(αtext,bmaxαbias) for brain MRI. The fractured digit lies outside the scope of the corruption function and is correctly left unaltered.
Table 2
Figure 2: AP (x-axis) against Dice (y-axis) on the brain MRI benchmark [ UPD_study ] . Baseline metrics are taken from [ UPD_study ] and [ cond_ddpm ] . We note that DISYREv2 [ disyre_v2 ] reported 73.0 , 51.0 and 45.0 Dice on BraTS-T2, BraTS-T1 and ATLAS respectively, but did not provide slice-level detection metrics. ’Ours’ denotes our method, with results reported a single seed.
Dataset
Size correlation ↑
Bias correlation ↑
Centre localisation (%) ↑
ATLAS
0.600 [0.591, 0.608]
0.323 [0.311, 0.336]
29.4
BraTS-T1
0.558 [0.549, 0.567]
0.120 [0.107, 0.135]
54.3
BraTS-T2
0.735 [0.726, 0.743]
0.492 [0.482, 0.503]
71.7
Table 3: Quantitative parameter recovery metrics on the brain MRI benchmark, computed over anomalous slices only. Size and bias correlation report Spearman rank correlation between inferred and ground-truth values, where ground-truth bias is the mean intensity difference between the lesion mask and the corresponding region in matched healthy slices. Centre localisation is the proportion of samples where the inferred anomaly centre falls within 4 pixels of the mask boundary. Confidence intervals are 95% bootstrap intervals.
Unsupervised anomaly detection (UAD) aims to localize abnormal regions in medical scans without pixel-level annotations. A typical strategy seeks to reconstruct a pseudo-healthy image that preserves subject-specific anatomy. Recently, diffusion models have been proposed to perform UAD. However, these methods rely on heuristic noise schedules or synthetic corruptions to balance subject-specificity and anomaly removal. In this work, we propose an alternative formulation of UAD as a Bayesian inverse problem under a diffusion prior. First, we introduce a latent spatial anomaly mask that models pixel-wise consistency between a test image and its latent corresponding pseudo-healthy image. Then, we propose an approximation of the unknown generation process that links healthy anatomy, anomalies, and the observed image, enabling a well-defined likelihood within the Bayesian framework. Building on recent advances in diffusion-based inverse problem methods, we jointly infer the pseudo-healthy image and the anomaly mask via annealed posterior sampling. We evaluate our approach on FDG PET (ADNI) and FLAIR MRI (BraTS 2021), demonstrating improved anomaly localization performance compared to other diffusion-based approaches and validating the contribution of our introduced model. Our code is available at https://github.com/HuguesRoy/UAD_DAPS.
Hugues Roy, Reuben Dorent, Ninon Burgos
Sorbonne Université, Institut du Cerveau - Paris Brain Institute - ICM, CNRS, Inria, Inserm, AP-HP, Hôpital de la Pitié Salpêtrière, F-75013, Paris, France
Unsupervised anomaly detection (UAD) aims to detect anomalies without labeled data, a necessity in many machine learning applications where anomalous samples are rare or not available. Most state-of-the-art methods fall into two categories: reconstruction-based approaches, which often reconstruct anomalies too well, and decoupled representation learning with density estimators, which can suffer from suboptimal feature spaces. While some recent methods attempt to couple feature learning and anomaly detection, they often rely on surrogate objectives, restrict kernel choices, or introduce approximations that limit their expressiveness and robustness. To address this challenge, we propose a novel method that couples representation learning the exact One-Class SVM (OCSVM) optimization problem, through a custom loss formulation that directly aligns latent features with the OCSVM decision boundary. The model is evaluated on two tasks: a benchmark based on MNIST-C, and a challenging brain MRI lesion detection task. Unlike most methods that focus on large, hyperintense lesions at the image level, our approach succeeds to target small, non-hyperintense lesions, while we evaluate voxel-wise metrics, addressing a more clinically relevant scenario. Both experiments evaluate a form of robustness to domain shifts, including corruption types in MNIST-C and texture or population age variations in MRI. Results demonstrate performance and robustness of our proposed model, highlighting its potential for general UAD and real-world medical imaging applications. The source code is available at https://github.com/Nicolas-Pinon/uad\_ocsvm\_guided\_repr\_learning.
Unsupervised Anomaly Detection (UAD) aims to identify abnormal regions by establishing correspondences between test images and normal templates. Existing methods primarily rely on image reconstruction or template retrieval but face a fundamental challenge: matching between test images and normal templates inevitably introduces noise due to intra-class variations, imperfect correspondences, and limited templates. Observing that Retrieval-Augmented Generation (RAG) leverages retrieved samples directly in the generation process, we reinterpret UAD through this lens and introduce RAID, a retrieval-augmented UAD framework designed for noise-resilient anomaly detection and localization. Unlike standard RAG that enriches context or knowledge, we focus on using retrieved normal samples to guide noise suppression in anomaly map generation. RAID retrieves class-, semantic-, and instance-level representations from a hierarchical vector database, forming a coarse-to-fine pipeline. A matching cost volume correlates the input with retrieved exemplars, followed by a guided Mixture-of-Experts (MoE) network that leverages the retrieved samples to adaptively suppress matching noise and produce fine-grained anomaly maps. RAID achieves state-of-the-art performance across full-shot, few-shot, and multi-dataset settings on MVTec, VisA, MPDD, and BTAD benchmarks. https://github.com/Mingxiu-Cai/RAID.
Mingxiu Cai, Zhe Zhang, Gaochang Wu +2
State Key Laboratory of Synthetical Automation for Process Industries, Northeastern University · University of Surrey