feat: Add Hugging Face Spaces demo link, remove Hugging Face login requirement for dataset download, and detail the computational environment.
Browse files- README.md +18 -3
- scripts/download_mvtec.py +11 -30
README.md
CHANGED
|
@@ -14,14 +14,17 @@ license: mit
|
|
| 14 |
[](https://www.python.org/downloads/)
|
| 15 |
[](https://github.com/openvinotoolkit/anomalib)
|
| 16 |
[](LICENSE)
|
|
|
|
| 17 |
|
| 18 |
A comprehensive benchmark for anomaly detection models on the [MVTec AD dataset](https://www.mvtec.com/company/research/datasets/mvtec-ad) using [Anomalib](https://github.com/openvinotoolkit/anomalib).
|
| 19 |
|
|
|
|
|
|
|
| 20 |
## 🎯 Features
|
| 21 |
|
| 22 |
- **Multiple Models**: PatchCore, EfficientAD, FastFlow, STFPM, PaDiM
|
| 23 |
- **Full Benchmark**: Train and evaluate on all 15 MVTec categories
|
| 24 |
-
- **Interactive Demo**: Gradio UI for real-time anomaly detection
|
| 25 |
- **Easy Configuration**: YAML-based model configs
|
| 26 |
|
| 27 |
## 📦 Installation
|
|
@@ -50,8 +53,8 @@ python scripts/download_mvtec.py
|
|
| 50 |
|
| 51 |
The script features an **interactive menu** where you can choose between:
|
| 52 |
|
| 53 |
-
1. **Hugging Face** (Recommended - Fast): Downloads from `micguida1/mvtech_anomaly_detection`.
|
| 54 |
-
2. **HTTP Mirror** (Fallback): Downloads from the original public mirror (~5GB, slower).
|
| 55 |
|
| 56 |
The dataset will be automatically extracted to `data/MVTecAD/`.
|
| 57 |
|
|
@@ -169,3 +172,15 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
| 169 |
- [Anomalib](https://github.com/openvinotoolkit/anomalib) - Anomaly detection library
|
| 170 |
- [MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad) - Dataset
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
[](https://www.python.org/downloads/)
|
| 15 |
[](https://github.com/openvinotoolkit/anomalib)
|
| 16 |
[](LICENSE)
|
| 17 |
+
[](https://huggingface.co/spaces/micguida1/mvtec-anomaly-benchmark)
|
| 18 |
|
| 19 |
A comprehensive benchmark for anomaly detection models on the [MVTec AD dataset](https://www.mvtec.com/company/research/datasets/mvtec-ad) using [Anomalib](https://github.com/openvinotoolkit/anomalib).
|
| 20 |
|
| 21 |
+
**🚀 [Try the Live Demo on Hugging Face Spaces](https://huggingface.co/spaces/micguida1/mvtec-anomaly-benchmark)**
|
| 22 |
+
|
| 23 |
## 🎯 Features
|
| 24 |
|
| 25 |
- **Multiple Models**: PatchCore, EfficientAD, FastFlow, STFPM, PaDiM
|
| 26 |
- **Full Benchmark**: Train and evaluate on all 15 MVTec categories
|
| 27 |
+
- **Interactive Demo**: [Gradio UI for real-time anomaly detection](https://huggingface.co/spaces/micguida1/mvtec-anomaly-benchmark)
|
| 28 |
- **Easy Configuration**: YAML-based model configs
|
| 29 |
|
| 30 |
## 📦 Installation
|
|
|
|
| 53 |
|
| 54 |
The script features an **interactive menu** where you can choose between:
|
| 55 |
|
| 56 |
+
1. **Hugging Face** (Recommended - Fast): Downloads from `micguida1/mvtech_anomaly_detection`. No login required.
|
| 57 |
+
2. **HTTP Mirror** (Fallback): Downloads from the original public mirror (~5GB, slower).
|
| 58 |
|
| 59 |
The dataset will be automatically extracted to `data/MVTecAD/`.
|
| 60 |
|
|
|
|
| 172 |
- [Anomalib](https://github.com/openvinotoolkit/anomalib) - Anomaly detection library
|
| 173 |
- [MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad) - Dataset
|
| 174 |
|
| 175 |
+
## 💻 Computational Environment
|
| 176 |
+
|
| 177 |
+
All experiments were conducted on a cloud machine rented via [Lightning.ai](https://lightning.ai/) with the following specifications:
|
| 178 |
+
|
| 179 |
+
| Component | Specification |
|
| 180 |
+
|-----------|---------------|
|
| 181 |
+
| **CPU** | Intel® Xeon® Platinum 8468 (16 vCPUs, 8 physical cores @ 2.1 GHz) |
|
| 182 |
+
| **RAM** | 196 GB |
|
| 183 |
+
| **GPU** | NVIDIA H200 (141 GB HBM3 VRAM) |
|
| 184 |
+
|
| 185 |
+
This high-performance setup enabled fast training and evaluation of all models across the entire MVTec AD dataset.
|
| 186 |
+
|
scripts/download_mvtec.py
CHANGED
|
@@ -29,8 +29,8 @@ def download_mvtec():
|
|
| 29 |
|
| 30 |
print("\n--- BANCA DATI MVTEC AD - DOWNLOADER ---")
|
| 31 |
print("Scegli il metodo di download:")
|
| 32 |
-
print("1. Hugging Face (
|
| 33 |
-
print("2. HTTP Mirror (
|
| 34 |
print("q. Esci")
|
| 35 |
|
| 36 |
while True:
|
|
@@ -53,51 +53,32 @@ def download_mvtec():
|
|
| 53 |
extract_dataset(target_dir, archive_name)
|
| 54 |
|
| 55 |
def download_huggingface(target_dir, archive_name):
|
| 56 |
-
print("\n---
|
| 57 |
try:
|
| 58 |
-
from huggingface_hub import hf_hub_download
|
| 59 |
except ImportError:
|
| 60 |
-
print("
|
| 61 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "huggingface_hub"])
|
| 62 |
-
from huggingface_hub import hf_hub_download
|
| 63 |
|
| 64 |
-
print("Tentativo di accesso...")
|
| 65 |
try:
|
| 66 |
-
|
| 67 |
-
# Usiamo force_download=False per check veloce, ma se fallisce gestiamo
|
| 68 |
-
hf_hub_download(
|
| 69 |
-
repo_id="micguida1/mvtech_anomaly_detection",
|
| 70 |
-
filename="mvtec_anomaly_detection.tar.xz",
|
| 71 |
-
repo_type="dataset",
|
| 72 |
-
local_dir=target_dir,
|
| 73 |
-
local_dir_use_symlinks=False
|
| 74 |
-
)
|
| 75 |
-
print("Login valido o cache presente.")
|
| 76 |
-
except Exception as e:
|
| 77 |
-
print(f"\nAccesso non riuscito o file non trovato ({e}).")
|
| 78 |
-
print("È necessario il login a Hugging Face (se il repo è privato).")
|
| 79 |
-
print("Inserisci il tuo token (lo trovi su https://huggingface.co/settings/tokens)")
|
| 80 |
-
login()
|
| 81 |
-
|
| 82 |
-
try:
|
| 83 |
-
print("Avvio download da Hugging Face (repo: micguida1/mvtech_anomaly_detection)...")
|
| 84 |
filepath = hf_hub_download(
|
| 85 |
repo_id="micguida1/mvtech_anomaly_detection",
|
| 86 |
filename="mvtec_anomaly_detection.tar.xz",
|
| 87 |
repo_type="dataset",
|
| 88 |
local_dir=target_dir,
|
| 89 |
-
local_dir_use_symlinks=False
|
| 90 |
-
force_download=True # Forza riscaricamento per evitare file corrotti in cache
|
| 91 |
)
|
| 92 |
-
# Fix path
|
| 93 |
if os.path.exists(filepath) and filepath != archive_name:
|
| 94 |
if os.path.exists(archive_name):
|
| 95 |
os.remove(archive_name)
|
| 96 |
os.rename(filepath, archive_name)
|
| 97 |
-
print("Download
|
| 98 |
return True
|
| 99 |
except Exception as e:
|
| 100 |
-
print(f"
|
| 101 |
return False
|
| 102 |
|
| 103 |
def download_http(archive_name):
|
|
|
|
| 29 |
|
| 30 |
print("\n--- BANCA DATI MVTEC AD - DOWNLOADER ---")
|
| 31 |
print("Scegli il metodo di download:")
|
| 32 |
+
print("1. Hugging Face (Recommended - Fast)")
|
| 33 |
+
print("2. HTTP Mirror (Slower ~5GB)")
|
| 34 |
print("q. Esci")
|
| 35 |
|
| 36 |
while True:
|
|
|
|
| 53 |
extract_dataset(target_dir, archive_name)
|
| 54 |
|
| 55 |
def download_huggingface(target_dir, archive_name):
|
| 56 |
+
print("\n--- Method: Hugging Face ---")
|
| 57 |
try:
|
| 58 |
+
from huggingface_hub import hf_hub_download
|
| 59 |
except ImportError:
|
| 60 |
+
print("Library 'huggingface_hub' not found. Installing...")
|
| 61 |
subprocess.check_call([sys.executable, "-m", "pip", "install", "huggingface_hub"])
|
| 62 |
+
from huggingface_hub import hf_hub_download
|
| 63 |
|
|
|
|
| 64 |
try:
|
| 65 |
+
print("Starting download from Hugging Face (repo: micguida1/mvtech_anomaly_detection)...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
filepath = hf_hub_download(
|
| 67 |
repo_id="micguida1/mvtech_anomaly_detection",
|
| 68 |
filename="mvtec_anomaly_detection.tar.xz",
|
| 69 |
repo_type="dataset",
|
| 70 |
local_dir=target_dir,
|
| 71 |
+
local_dir_use_symlinks=False
|
|
|
|
| 72 |
)
|
| 73 |
+
# Fix path if needed
|
| 74 |
if os.path.exists(filepath) and filepath != archive_name:
|
| 75 |
if os.path.exists(archive_name):
|
| 76 |
os.remove(archive_name)
|
| 77 |
os.rename(filepath, archive_name)
|
| 78 |
+
print("Download completed!")
|
| 79 |
return True
|
| 80 |
except Exception as e:
|
| 81 |
+
print(f"HF download error: {e}")
|
| 82 |
return False
|
| 83 |
|
| 84 |
def download_http(archive_name):
|