Industrial Anomaly Detection Playground π
An interactive playground for industrial anomaly detection. Two methods run side by side on the same image so you can compare memorization-based and zero-shot detection:
| Method | What it does | Needs |
|---|---|---|
| Memory bank (PatchCore-style) | DINOv2 patch features + nearest-neighbor distance against a bank of normal reference images; per-patch distances form the anomaly heatmap, and the image threshold is auto-calibrated on held-out normal references | ~8 normal reference images of the object type |
| Zero-shot (WinCLIP-style) | CLIP with a compositional prompt ensemble ("flawless/damaged {object}") scored on the full image and a 3Γ3 grid of overlapping crops | nothing β no references at all |
Features: 15 MVTec AD object/texture categories, clickable sample images (normal and defective), your own uploads, tunable thresholds, and heatmap overlays for both methods at once.
Run locally
pip install -r requirements.txt gradio
python app.py
The first launch downloads facebook/dinov2-base (350 MB) and 600 MB) and takes 1β2 minutes. The first use of each category downloads openai/clip-vit-base-patch16
(12 sample images
(2 MB) and encodes the reference bank (~20 s on CPU), then caches it in memory.
Host it as a Hugging Face Space
The app is Space-ready. Create a Gradio Space and add these three files (app.py,
requirements.txt, and this README): the Space needs only gradio from the SDK β the rest comes
from requirements.txt. It runs on free CPU tier (models load in RAM, inference is a few seconds
per image).
Data and attribution
- Sample images are MVTec AD test images (Β© MVTec Software GmbH, CC BY-NC-SA 4.0 β non-commercial use), fetched at runtime from the four-panel visualizations in abulhawa/industrial-component-anomaly-detection-models (top-left "Image" panel, 256Γ256). The category list and defect types match the MVTec AD dataset.
- Methods reimplemented after:
- PatchCore β Roth et al., Towards Total Recall in Industrial Anomaly Detection, CVPR 2022, arXiv:2106.08265 (features swapped to DINOv2, as in AnomalyDINO, arXiv:2405.14529)
- WinCLIP β Jeong et al., WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation, CVPR 2023, arXiv:2303.14814
- DINOv2 β Oquab et al., arXiv:2304.07193
Honest caveats: this is a demo, not a benchmark. Reference banks are built from ~8 normal images (not full training sets), thresholds are calibrated on 4 held-out normals, and the zero-shot map comes from 9 coarse crops rather than WinCLIP's full multi-scale sliding windows β expect somewhat lower accuracy than the papers' numbers, and treat both verdicts as exploratory.