VariaFlow: Uncertainty-Aware Flow Matching for Unsupervised Anomaly Detection
Authors: Arnela Hadzic, Martin Urschler, Cosmin I. Bercea
Organizations: Institute for Medical Informatics, Statistics and Documentation, Medical University of Graz, Graz, Austria · Institute of Visual Computing, Graz University of Technology, Graz, Austria · Technical University of Munich, School of Medicine and Health, TUM University Hospital, Klinikum rechts der Isar, Department of Diagnostic and Interventional Radiology, Munich, Germany
Reconstruction-based anomaly detection no longer fails at reconstruction. Generative models produce high-quality pseudo-healthy reconstructions, and the remaining difficulty is the step of scoring residuals. The residual between a scan and its reconstruction has two indistinguishable sources, genuine pathology and the anatomical variation that separates one healthy brain from another. Scoring against a single reconstruction treats both as anomalous, inflating false positives where healthy anatomy varies most while small or subtle lesions are lost in the surrounding reconstruction error. We identify the missing quantity as the predictive variance, how much a healthy reconstruction can vary at each location. We introduce VariaFlow, which estimates this variance from an ensemble of mask-guided restorations under an unconditional flow matching prior, each started from a different noise initialization, and which normalizes the residual by the resulting standard deviation. Few-step flow matching keeps the ensemble computationally affordable, and restoring at two spatial scales captures lesions of different size. Across three brain MRI datasets spanning stroke and tumor, VariaFlow is trained once on healthy anatomy and generalizes across all three, attaining the highest AUROC (0.94, 0.80, 0.78) on each and the highest AUPRC on both cross-domain datasets, exceeding the strongest baseline by 37% and 50%. Under domain shift, the same baseline drops by up to 52% in AUPRC, whereas VariaFlow stays more stable and achieves the best small-lesion Dice on all three datasets.
Figures & tables
Figure 1: Given an input image, VariaFlow generates an ensemble of pseudo-healthy reconstructions ( x^(1),x^(2),…,x^(N) ). In anomalous regions, the model consistently generates healthy tissue, yielding a high residual ( R ) and low predictive variance ( σ2 ). Conversely, in variable healthy regions (e.g., ventricle boundaries), anatomical variability causes reconstructions to diverge, creating high predictive variance. Penalizing the residual with the variance suppresses false positives, isolating the pathology in the anomaly score map ( S ).
Dataset
Small
Medium
Large
ATLAS
189
152
59
UCSF-PDGM
30
126
257
BraTS
26
78
217
Total
245
356
533
Table 1: Number of images per lesion size category and dataset.
Table 2: Quantitative results on the ATLAS, UCSF-PDGM, and BraTS datasets. VariaFlow is compared to several state-of-the-art diffusion- and flow-based baselines. Bold and underline indicate the best and the second-best score per metric, respectively.
Figure 2: Qualitative anomaly detection results on ATLAS, UCSF-PDGM, and BraTS. Rows 1-2 show the input images and ground truth masks. Rows 3-6 visualize the anomaly maps generated by the baseline methods, and Row 7 shows the maps generated by VariaFlow , demonstrating both superior detection and false positive suppression.
Figure 3: Comparison of window sizes ( sl=32,sg=64 ) and fusion strategies, with geometric mean consistently yielding the highest AUPRC.
Scoring
AUROC ↑
AUPRC ↑
⌈ Dice ⌉ (%) ↑
Mean residual
0.8463
0.3935
43.11
Median residual
0.8571
0.4008
43.91
Proposed (S)
0.9417
0.5262
54.86
Table 3: Comparison of different scoring formulations. Median residual alone as proposed in Eq. 3 . Mean residual is a variant that uses the mean reconstruction instead in Eq. 1 . Based on median residual, our proposed (S) additionally penalizes variance.
Figure 4: Impact of the ensemble size N on detection performance. Metrics stabilize at N=5 .
Figure 5: Examples of diverse anatomical and structural deviations. Left: The model detects an enlarged ventricle, dominating the lesion attached to it. Right: The model misses a lesion resembling cortical folding while detecting a prominent imaging artifact.
Method
Backbone Architecture
Steps
Time (s)
VRAM (GB)
Params (M)
THOR [ 11 ]
DDPM U-Net
350
3.58
0.52
∼19
REFLECT [ 8 ]
LDM U-Net + VAE
5
0.12
1.67
∼246
VariaFlow (single patch)
Restora-Flow U-Net [ 19 ]
8
0.32
0.40
∼62
VariaFlow (global scale, N=1 )
0.64
0.82
VariaFlow (local scale, N=1 )
2.92
3.34
VariaFlow (dual-scale, N=1 )
3.56
3.34
Table 4: Computational and architectural comparison between methods.
School of Computing, National University of Singapore, Singapore · Institute of Data Science, National University of Singapore, Singapore · Department of Computer and Information Science, SKL-IOTSC, University of Macau, China +1
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