ReFP-AD: Rectified Flow Preconditioning for Energy-Based Anomaly Detection
Abstract
Unified anomaly detection requires modeling highly heteroge-neous normal data without access to anomalous samples. While foundationmodels like DINOv2 provide rich token representations, leveraging thesespaces for explicit density estimation remains challenging. Energy-BasedModels (EBMs) offer a principled formulation, but their training inhigh-dimensional token spaces is unstable due to anisotropy and strongcross-dimensional correlations, which degrades finite-step Markov ChainMonte Carlo (MCMC) sampling. We identify this instability as fundamen-tally geometric and introduce ReFP-AD (Rectified Flow Preconditioningfor Anomaly Detection), which learns a geometric reparameterization thatmaps high-dimensional embeddings into a well-conditioned latent spacevia an optimal transport (OT)-coupled rectified flow. This precondition-ing enables stable persistent contrastive divergence with preconditionedStochastic Gradient Langevin Dynamics (SGLD) in full-dimensional tokenspaces. Anomaly scores are then derived from the learned energy landscapeusing gradient norms. Under a strict unified protocol on the MVTec-ADand VisA datasets, ReFP-AD achieves 98.6%/97.9% Image/Pixel AUROCon MVTec-AD and 97.3%/99.0% on VisA, outperforming prior unifiedEBM baselines by up to +10.8% in Image AUROC. Ablation experimentsdemonstrate that geometric reparameterization is critical for finite-stepMCMC and accurate anomaly localization in high-dimensional tokenspaces. Code is available at https://github.com/CLendering/ReFP-AD