Industrial Anomaly Detection: PatchCore vs EfficientAD on MVTec AD
Compares two SOTA unsupervised anomaly detection methods on the MVTec AD benchmark — a memory-based approach (PatchCore) and a knowledge-distillation approach (EfficientAD) — with a Gradio demo for interactive defect visualisation.
mvtec-anomaly/
├── app.py # Gradio demo
├── data/
│ ├── mvtec_dataset.py # Dataset loader
│ └── download_mvtec.sh # Download instructions
├── models/
│ ├── patchcore.py # PatchCore (CVPR 2022)
│ └── efficientad.py # EfficientAD (WACV 2024)
├── scripts/
│ ├── train.py # Train + evaluate, auto-generates plots
│ └── plot_results.py # Heatmap grids + comparison charts
├── utils/
│ ├── paths.py # Central path config via .env
│ └── metrics.py # AUROC, AP, PRO score
└── results/ # Generated plots (gitignored)
python -m venv venv && source venv/bin/activate
pip install -r requirements.txtDownload MVTec AD (free, requires registration):
bash data/download_mvtec.sh# Single category, both models
python scripts/train.py --category bottle
# All 15 categories
python scripts/train.py --category all
# Single model
python scripts/train.py --category bottle --model patchcorepython app.py # local
python app.py --share # public link| Model | Paper | Key Idea | Inference Speed |
|---|---|---|---|
| PatchCore | CVPR 2022 | Memory bank of normal patch features | Medium |
| EfficientAD | WACV 2024 | Teacher-Student knowledge distillation | Fast |
| Metric | Description |
|---|---|
| Image AUROC | Discriminates normal vs anomalous images |
| Pixel AUROC | Localises defects at pixel level |
| PRO Score | Per-Region Overlap — primary MVTec metric |