Source-linked AI summary
Flownomaly: Single-Step Conditional-Mean Recovery for Few-Shot Anomaly Detection
Bernardo Perrone Ribeiro, Erkut Akdag, Egor Bondarev
TL;DR
Few-shot anomaly detection must model category-specific normality from only a handful of defect-free images, while existing approaches have limitations including exemplar dependence, rigid linearity, and anomaly reproduction risk. Flownomaly uses conditional flow matching to recover normal-biased counterparts from frozen DINOv2 features in one step, with support-only calibration. It achieves state-of-the-art results on VisA and Real-IAD and leads most evaluated comparisons on MVTec-AD.
Problem
Few-shot anomaly detection must characterize category-specific normality from a handful of defect-free images, while existing approaches can depend on finite exemplars, rigid linearity, query-time optimization, or risk reproducing anomalies.
Source: §1 · p. 1Method
Flownomaly learns a conditional-flow-matching velocity field over frozen DINOv2 patch tokens, using a single recovery step and a normal-only criterion to calibrate operating time.
Source: §3 · p. 3, §3.5 · p. 5Results
Flownomaly achieves state-of-the-art results on VisA and Real-IAD and leads most evaluated comparisons on MVTec-AD.
Source: §5 · p. 8Takeaways & Limitations
Single-step recovery matches trajectory integration without a detection advantage from integration, while substantially reducing velocity-network latency.
Source: §4.8 · p. 7, §5 · p. 8The normal-only Jacobian gain-to-noise rule selects operating time without anomalous samples or test labels, rather than estimating the category-wise test-label optimum.
Source: §3.5 · p. 5
Abstract
from arXiv · showhide
Few-shot industrial anomaly detection requires modeling category-specific normality from only a handful of defect-free images. Common approaches tie inference to stored exemplars, impose rigid linear structure, or risk reproducing anomalous content. Flownomaly instead casts the problem as normal-counterpart recovery in frozen DINOv2 feature space. Given normal supports, a velocity field is learned through conditional flow matching over frozen patch tokens to transport Gaussian noise toward normal features. Along straight paths, a single recovery step using one evaluation of the optimal field yields the posterior mean of the clean normal token without trajectory integration. The operating time governs how strongly recovery modifies a query token. With no anomalous validation samples available for tuning, a normal-only Jacobian gain-to-noise criterion selects this time from the supports alone. Squared residuals between query tokens and their recovered counterparts yield anomaly signals for both dense localization and image-level detection. Across 1-, 2-, and 4-shot benchmarks on MVTec-AD and VisA, together with sample-shot evaluations on Real-IAD, Flownomaly achieves state-of-the-art performance against recent category-specific methods. In the 1-shot setting, image- and pixel-level AUROC reach 97.8% and 98.0% on MVTec-AD and 95.3% and 98.7% on VisA, with a 2.1-point image-level AUROC improvement over the strongest baseline on VisA. Code is available at https://github.com/b-rbmp/Flownomaly.
1. Introduction
Few-shot industrial anomaly detection must characterize category-specific normality from only a few defect-free images, while existing feature-space approaches have distinct constraints. Flownomaly recovers normal-biased counterparts in frozen feature space using single-step conditional flow matching and support-only operating-time calibration.
1. Introduction
- Few-shot anomaly detection models category-specific normality from a handful of defect-free reference images to detect unseen defects at image and pixel levels.Source: §1 · p. 1
- Existing approaches tie inference to finite exemplars, impose rigid linear assumptions, require query-time optimization, or risk reproducing anomalous content.Source: §1 · p. 1
- Flownomaly formulates detection as normal-counterpart recovery: discrepancy between a query token and its recovered counterpart provides the anomaly signal.Conditional flow matching [23] [24] trains the recovery operator.Source: §1 · p. 1
- A straight-path conditional-flow-matching field yields the posterior mean of a clean normal feature in one evaluation, while a normal-only Jacobian gain-to-noise criterion selects operating time from supports.The operating time controls recovery strength, and support-derived augmentations also support field fitting and checkpoint selection.Source: §1 · p. 2
- Across MVTec-AD, VisA, and Real-IAD, Flownomaly achieves state-of-the-art results and strong detection and localization performance.The largest image-level gains are reported on VisA and Real-IAD.Source: §1 · p. 2
2. Related Work
Prior few-shot anomaly detectors model normal supports through references, learned prompts, correspondences, reconstruction, or feature geometry, while flow-based methods use likelihood proxies or trajectory-based scoring. Flownomaly instead uses a continuous velocity field for support-only feature recovery and a single batched evaluation for detection and localization.
2.1. Few-Shot Anomaly Detection
- Flownomaly models category normality with a continuous, time-conditioned velocity field, avoiding nearest-neighbor search and query-time optimization.This contrasts with reference-based approaches [6] [27], linear subspaces [18], and registration-based approaches [29].Source: §2.1 · p. 2
2.2. Normal-Counterpart Recovery
- Flownomaly learns feature-space recovery from the support set alone, without synthetic abnormal–normal pairs, teacher distillation, pixel decoders, or auxiliary segmentation heads.Prior reconstruction approaches include Reverse Distillation [8], UniAD [32], FastRecon, FastRef, and INP-Former [25].Source: §2.2 · p. 2
2.3. Flow-Based Anomaly Detection
- Unlike flow-based detectors using likelihood proxies, reverse trajectories, or multi-path velocity discrepancies, Flownomaly uses one batched field evaluation for residuals supporting both localization and image-level detection.Prior approaches include CFLOW-AD, FastFlow [33], MSFlow, Reflect [3], WT-Flow [19], TCCM [22], and Flow Mismatching [5].Source: §2.3 · pp. 2–3
3. Method
Flownomaly learns a nonlinear recovery operator over frozen DINOv2 patch tokens from few-shot normal supports, then uses recovered-token residuals for image detection and dense localization. Conditional flow matching supplies a single-step conditional-mean estimate, and a normal-only criterion calibrates the operating time.
3. Method
- Flownomaly models category-specific normality with a nonlinear recovery operator over frozen DINOv2 patch tokens, using few-shot supports to predict image scores and dense localization maps.The velocity field is trained by conditional flow matching along straight paths; its single-step update yields a posterior-mean normal counterpart without trajectory integration.Source: §3 · p. 3
3.1. Problem Setup and Support Features
- For k ∈ {1, 2, 4} defect-free support images, the method predicts an image anomaly score and a dense pixel-level localization map for an unlabelled query.It uses standardized multi-depth tokens from frozen middle-to-late DINOv2 blocks, with disjoint augmented views for fitting, validation, and calibration.Source: §3.1 · p. 3
3.2. Conditional Flow Matching on Normal Tokens
- Conditional flow matching trains a time-conditioned field on straight interpolations from Gaussian noise to normal support tokens, with fitting and checkpoint selection based on support-derived views.The encoder remains frozen while the velocity field predicts the interpolation velocity under a squared-error objective.Source: §3.2 · p. 3
3.3. Single-Step Conditional-Mean Recovery
- At the population optimum, one field evaluation along the straight path estimates the conditional mean of the clean normal token, without integrating a trajectory.For potentially anomalous queries, the recovered counterpart is normality-biased; the identity does not guarantee recovery of an actual defect-free counterpart or anomaly separation.Source: §3.3 · p. 4
3.4. Anomaly Scoring
- Squared residuals between query tokens and recovered counterparts form the anomaly map, which is smoothed and upsampled for localization; image-level scoring averages the largest α fraction of the map.Source: §3.4 · p. 5
3.5. Normal-Only Operating-Time Calibration
- The operating time controls recovery strength, and the normal-only Jacobian gain-to-noise criterion selects it by comparing perturbation response with upper-tail residual noise on normal calibration tokens.The selected time is the smallest maximizer of aggregated calibration scores; it is not an estimator of the category-wise test-label optimum.Source: §3.5 · p. 5
4. Experiments
Experiments evaluate Flownomaly on MVTec-AD, VisA, and Real-IAD, covering few-shot and sample-shot detection and localization. Results show strong benchmark performance, with ablations testing recovery, calibration, scoring, and backbone choices.
4.1. Datasets; 4.2. Evaluation Metrics
- Evaluation spans 15 MVTec-AD, 12 VisA, and 30 Real-IAD categories; MVTec-AD and VisA use 1-, 2-, and 4-shot normal references, and Real-IAD uses five views per selected sample.Image- and pixel-level metrics are averaged across categories.Source: §4.1 · p. 5, §4.2 · p. 5, §4 · p. 5
4.5. Few-Shot Anomaly Detection Performance
- Across 1-, 2-, and 4-shot settings, Flownomaly achieves best or tied-best pixel-level results; on VisA, its image-level AUROC exceeds the strongest baseline by 2.1, 2.3, and 1.1 pp, respectively.On MVTec-AD it leads or ties seven of nine image-level comparisons and is within 0.2 pp of ANoCo on the other two; in full-shot settings it is best or tied-best in 11 of 12 metric–dataset comparisons. Qualitative examples show sharper defect delineation and fewer background activations.Source: Table 1 · p. 6, §4.5 · p. 6, Figure 3 · p. 7
4.6. Sample-Shot Anomaly Detection on Real-IAD
- At every Real-IAD sample-shot setting, Flownomaly has the strongest image-level performance and highest pixel-level AUROC and F_{1,\max }; with one sample, image AUROC rises from 85.2% for SubspaceAD to 88.2%.In the one-sample setting, pixel-level F_{1,\max } rises from 42.7% to 50.6%.Source: §4.6 · p. 6, Table 2 · p. 7
4.7. Computational Efficiency
- In the 1-shot setting, fitting one category takes a median of 24 s on MVTec-AD and 28 s on VisA; the velocity network adds 2.2 ms to 60.9 ms total image latency and 23.2 M parameters per category.Its parameter footprint does not grow with k.Source: §4.7 · p. 7
4.8. Ablation Study
- Increasing velocity-field evaluations from 1 to 20 changes image- and pixel-level AUROC by at most 0.2 pp, while velocity-network latency rises 13.3× from 2.2 to 29.2 ms/image.Total model latency rises from 60.9 to 87.9 ms/image, with negligible detection benefit from full trajectory integration.Source: Table 3 · p. 7, §4.8 · p. 7
- The median category-wise JGN selection is t = 0.65 on both datasets, within a broad low-regret region; median image-AUROC regret is 0.06 pp on MVTec-AD and 0.14 pp on VisA.Test labels define only the retrospective reference used to measure regret.Source: §4.8 · p. 8, Figure 4 · p. 8
- Replacing recovery-residual scoring with velocity norm lowers image AUROC by 0.9/1.0 pp on MVTec-AD/VisA, while cosine discrepancy lowers it by 1.1/5.1 pp.The comparison holds other settings fixed.Source: §4.8 · p. 8, Table 4 · p. 8
- Scaling from DINOv2-S to DINOv2-g improves image AUROC by 3.1 pp on MVTec-AD and 3.5 pp on VisA, while latency rises from 18.1 to 60.9 ms/image.DINOv3-7B does not improve over DINOv2-g in this setting.Source: §4.8 · p. 8, Table 5 · p. 8
5. Conclusion
Flownomaly reframes few-shot anomaly detection as single-step normal-counterpart recovery in frozen DINOv2 feature space. It reports strong results on VisA and Real-IAD, while global structural anomalies remain challenging.
5. Conclusion
- Flownomaly estimates a normality-biased counterpart through one-step conditional-mean recovery in frozen DINOv2 feature space, using residuals for detection and localization.Support-derived normal data alone is used for field fitting and checkpoint selection, while a normal-only Jacobian gain-to-noise criterion calibrates operating time.Source: §5 · p. 8
- Flownomaly achieves state-of-the-art results on VisA and Real-IAD and leads most evaluated comparisons on MVTec-AD.Additional field evaluations provide negligible detection benefit, and performance remains stable across a broad range of operating times.Source: §5 · p. 8
- Token-wise residual scoring does not explicitly enforce global structural constraints, leaving logical anomalies such as incorrect part counts challenging.Future work will investigate explicit global-constraint modeling, category-agnostic recovery fields, and more compact feature extractors.Source: §5 · p. 8
Supplementary Material
The supplement collects implementation details and additional analyses and evaluations. Support sampling builds fitting, validation, and calibration pools from the same selected defect-free images using disjoint augmentations.
Supplementary Material
- The supplement covers implementation and efficiency, additional analyses, full-shot and backbone evaluations, extended localization results, and per-category performance tables.These materials are presented as supporting the main paper.Source: Supplementary Material · p. 11
A.1. Support Sampling
- Three support samplings use random seeds 42, 43, and 44; for each category, the selected k defect-free images determine fitting, validation, and calibration views.Source: §A.1 · p. 11
- Fitting uses each support image plus 30 uniformly sampled rotations, while validation and calibration use three rotations per image from separate random streams.Source: §A.1 · p. 11
- Tokens in rotation-padding regions are masked from all pools, standardization statistics, fitting batches, validation loss, and calibration statistics.Source: §A.1 · p. 11
- Standardized multi-depth tokens average selected-block features after channel-wise normalization using fitting-view statistics, which are applied unchanged to validation, calibration, and query tokens.Source: §A.1 · p. 11
A.2. Architecture and Optimization
The supplement specifies the velocity-network training and normal-only operating-time calibration, then reports runtime, recovery diagnostics, and selection robustness. Recovery is associated with distance to the empirical support set, but the analysis does not establish anomaly separation.
A.2. Architecture and Optimization
- The velocity network uses a 256-dimensional sinusoidal time embedding, four residual blocks, and a gated input skip, with 23.2 M trainable parameters.AdamW training uses weight decay 10^-4 and a cosine learning rate from 10^-3 to 10^-6 for up to 1000 epochs, with fixed-draw validation and early stopping.Source: §A.2 · p. 11
A.3. Calibration and Scoring
- Operating-time calibration uses three views per support image in k-shot settings and selects the earliest candidate maximizing the median Jacobian-gain-to-residual-floor ratio.It evaluates four Gaussian-noise repetitions and four random probes per token; the ratio uses direction-averaged Jacobian gain and the top-1% mean normal residual.Source: §A.3 · pp. 11–12
- At inference, residual maps are Gaussian-smoothed with sigma = 0.8 token widths before upsampling, while image scores aggregate the unsmoothed upsampled map.Source: §A.3 · p. 12
A.4. Runtime, Memory, and Model Size
- 1-shot fitting takes median 24 s per MVTec-AD category and 28 s per VisA category; calibration adds 14 s, peak GPU memory is 2.6 GB, and the velocity network has 23.2 M parameters.Measurements use one NVIDIA H100 GPU; the frozen 1.1 B-parameter encoder is shared across categories, and network footprint does not grow with k.Source: §A.4 · p. 12
B.1. Recovery Contracts Toward Normal Support Features
- The recovery diagnostics use a finite bank of unrotated fitting supports, not the full training distribution or an assumed normal manifold, and do not guarantee anomaly separation.The empirical analysis is based on distances to that finite support set; larger residuals are associated with greater support distance.Source: §B.1 · pp. 12–13
- 0.825 on MVTec-AD and 0.817 on VisA are median category-wise Spearman correlations between recovery residual and nearest-support distance, remaining strong within normal and anomalous tokens.The within-normal / within-anomalous correlations are 0.803 / 0.921 on MVTec-AD and 0.809 / 0.918 on VisA.Source: §B.1 · p. 13
- Recovery contracts tokens toward empirical normal supports: anomalous-token contraction is 2.8 times / 2.2 times larger than the normal-token distance scale on MVTec-AD / VisA.Median after-to-before distances are 0.861 / 0.826 for normal tokens and 0.760 / 0.782 for anomalous tokens on MVTec-AD / VisA.Source: §B.1 · p. 13
B.2. Operating-Time Selection and Robustness
- Median regret was 0.06 percentage points (pp) on MVTec-AD and 0.14 pp on VisA, with both regret statistics computed for seed 42.VisA’s larger mean and 4.82 pp maximum were driven by macaroni2, whose empirical test curve favored an earlier operating time. Across category–seed pairs from seeds 42–44, selections stayed in [0.60, 0.75] on MVTec-AD and [0.65, 0.70] on VisA.Source: §B.2 · p. 13
B.3. Feature and Support-View Ablations
Feature depth and support-view construction affect benchmark performance and calibration, while token-wise scoring can miss anomalies defined by global configuration; DINOv3-7B does not improve over DINOv2-g in the tested setting.
B.3. Feature and Support-View Ablations
- Shallow 20–40% features reduce image AUROC by 12.1 pp on MVTec-AD and 9.3 pp on VisA, while pixel AUROC drops by 2.1 and 5.2 pp, respectively.Using only the 80%-depth block preserves MVTec-AD performance but lowers VisA image AUROC by 3.3 pp.Source: §B.3 · p. 13, Table S3 · p. 14
- Removing rotation-derived views reduces image AUROC by 4.0 pp on MVTec-AD and 2.0 pp on VisA; this ablation also removes view diversity from validation and calibration pools.Removing layer-wise standardization has little effect on MVTec-AD but reduces VisA image AUROC by 1.3 pp.Source: §B.3 · p. 13, Table S3 · p. 14
- JGN’s median selected t* shifts from 0.60 for shallow features to 0.85 without layer standardization, with the same ordering on both datasets.The selection therefore responds to changes in feature representation rather than remaining fixed.Source: §B.3 · pp. 13–14
B.4. Qualitative Failure Modes
- Swapped wires and a missing component exposing familiar background produce essentially empty anomaly maps because the observed tokens remain locally compatible with normality.The method scores token-wise discrepancies and does not explicitly model object-level relations, part counts, or global configurations.Source: §B.4 · p. 14, Figure S3 · p. 15
C.1. Backbone Comparison
- DINOv3-7B does not improve over DINOv2-g at either evaluated resolution.The comparison uses a matched 48 × 48 token grid as well as the default resolution.Source: §C.1 · pp. 14–15, Table S4 · p. 15
C.2. Full-Shot Evaluation
The full-shot evaluation uses all available normal training images, with rotations disabled and separate fitting, validation, and calibration pools.
C.2. Full-Shot Evaluation
- Flownomaly is evaluated using all available normal training images, beyond its few-shot design.Aggregate results are reported for MVTec-AD and VisA in Tables S5 and S6.Source: §C.2 · p. 15
- Rotation augmentations are disabled in the full-shot evaluation.The fitting, validation, and calibration pools are formed by partitioning the normal training images.Source: §C.2 · p. 15
- For n normal training images, validation and calibration each receive max(4, ceil(0.05n)) images.The remaining partition is used for fitting.Source: §C.2 · p. 15
D. Additional Qualitative Results
Additional qualitative comparisons show anomaly maps for representative MVTec-AD, VisA, and Real-IAD samples, illustrating localization across categories and anomaly types.
D. Additional Qualitative Results
- The additional examples are reported to show sharp defect delineation while suppressing background responses in the 1-shot and 1-sample settings.The comparisons cover MVTec-AD, VisA, and Real-IAD.Source: D. Additional Qualitative Results · p. 15
- MVTec-AD and VisA figures compare input images and ground-truth masks with baseline anomaly maps and Flownomaly predictions.The cited baselines are AnomalyDINO and SubspaceAD.Source: Figure S4 · p. 16, Figure S5 · p. 17
- The Real-IAD examples span five multi-view captures of a single normal physical sample and show query images, masks, baseline maps, and Flownomaly maps.The baselines shown are AnomalyDINO and SubspaceAD.Source: Figure S6 · p. 18
E. Per-Category Few-Shot and Sample-Shot Results
Per-category results are tabulated across few-shot settings for MVTec-AD and VisA and sample-shot settings for Real-IAD.
E. Per-Category Few-Shot and Sample-Shot Results
- Real-IAD per-category results are split between Table S9 for 1- and 2-sample settings and Table S10 for the 4-sample setting.Each physical sample comprises five fixed multi-view captures, yielding 5, 10, or 20 support images; results are mean and sample standard deviation over three seeds.Source: E. Per-Category Few-Shot and… · p. 19, Table S9 · p. 21, Table S10 · p. 22
- Tables S7 and S8 report per-category MVTec-AD and VisA detection and localization results for the 1-, 2-, and 4-shot settings.Results are mean and sample standard deviation over three seeds.Source: Table S7 · p. 19, E. Per-Category Few-Shot and… · p. 19, Table S8 · p. 20
- The Real-IAD tables report per-category anomaly detection and localization results under the sample-shot protocol.The 1- and 2-sample results are in Table S9, and the 4-sample results are in Table S10.Source: Table S9 · p. 21, Table S10 · p. 22