Download README.md from Vshayan3/AFR: direct link, hf CLI and curl.
- Browser
- Download file 2.56 kB
-
https://huggingface.co/Vshayan3/AFR/resolve/main/README.md
- Command line
-
hf download hf://Vshayan3/AFR/README.md
-
curl -L -o README.md https://huggingface.co/Vshayan3/AFR/resolve/main/README.md
license: mit
library_name: pytorch
tags:
- anomaly-detection
- industrial-inspection
- flow-matching
- diffusion-transformer
- dinov2
- mvtec-ad
- visa
- btad
AFR: Antithetic Flow-Matching Residuals for Multi-Class Anomaly Detection
Checkpoints of the paper Antithetic Flow-Matching Residuals for Multi-Class Anomaly Detection (Shayan Shashaani, Marco Tasca, Jawad Tayyub). Code: https://github.com/Vshayan/Antithetic-Flow-Matching
AFR detects and localizes defects with one flow-matching model per dataset, trained on the normal images of all categories, without category labels. The model is a DiT-B (130.7M parameters) that works on frozen DINOv2 ViT-B/14 (with registers) patch features at 448 x 448 pixels. A test image is noised at 10 levels with one antithetic noise pair (+e, -e) shared by all levels, and the anomaly score of a patch is the average over levels of its pair-mean residual, with every channel divided by its normal variance.
Files
| File | Trained on | Steps |
|---|---|---|
afr_mvtec.pt |
MVTec AD, all 15 categories | 40k |
afr_visa.pt |
VisA, all 12 categories | 95k |
afr_btad.pt |
BTAD, all 3 products | 20k |
EMA weights, about 520 MB each. They are loaded by the code in the GitHub repository.
Usage
git clone https://github.com/Vshayan/Antithetic-Flow-Matching && cd Antithetic-Flow-Matching
pip install -r requirements.txt huggingface_hub
huggingface-cli download Vshayan3/AFR afr_mvtec.pt --local-dir checkpoints
python -m afr.features --dataset mvtec
python -m afr.score --dataset mvtec --ckpt checkpoints/afr_mvtec.pt
python -m afr.evaluate --dataset mvtec --save-maps
See the repository README for the data layout and the other datasets.
Results
Multi-class setting, category means. mAD is the mean of I-AUROC, I-AP, I-F1max, P-AUROC, P-AP, P-F1max and AUPRO. Loose masks follow the mask resizing of the Dinomaly and INP-Former evaluation code, strict masks use nearest-neighbor resizing.
| Dataset | I-AUROC | P-AUROC | AUPRO | mAD (loose masks) | mAD (strict masks) |
|---|---|---|---|---|---|
| MVTec AD | 99.70 | 98.67 | 96.12 | 91.25 | 90.48 |
| VisA | 99.12 | 99.15 | 95.82 | 86.57 | 85.48 |
| BTAD | 97.36 | 98.41 | 82.07 | 88.61 | 88.17 |
Citation
@article{shashaani2026afr,
title = {Antithetic Flow-Matching Residuals for Multi-Class Anomaly Detection},
author = {Shashaani, Shayan and Tasca, Marco and Tayyub, Jawad},
journal = {arXiv preprint arXiv:2612.01546},
year = {2026}
}