File size: 1,148 Bytes
a7dead4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ---
tags:
- anomaly-detection
- computer-vision
- patchcore
- defect-detection
- industrial
datasets:
- mvtec-ad
---
# DefectVision — PatchCore Anomaly Detection (bottle)
PatchCore implemented from scratch with PyTorch on MVTec AD.
## Why PatchCore over YOLOv8?
| Model | Approach | Key Metric |
|-------|----------|------------|
| YOLOv8n | Supervised | mAP50 = 0.09 |
| PatchCore | Unsupervised | AUROC = 0.9976 |
YOLOv8 struggles with MVTec AD because defect images are scarce.
PatchCore trains on normal images only and generalizes to unseen defects.
## Architecture
- **Backbone**: WideResNet50 (ImageNet pretrained)
- **Layers**: layer2 + layer3 → 1536-dim patch features
- **Memory Bank**: coreset 10% of train patches
- **Scoring**: max nearest-neighbor distance (k=9)
## Metrics — bottle
- **AUROC** : 0.9976
- **Best F1**: 0.9920
## Usage
```python
import torch
from huggingface_hub import hf_hub_download
path = hf_hub_download(repo_id='Chasston/defect-vision-patchcore-bottle', filename='memory_bank.pt')
data = torch.load(path)
memory_bank = data['memory_bank']
```
## Author
[Chasston](https://huggingface.co/Chasston)
|