uoft-cs/cifar10
Viewer • Updated • 60k • 130k • 105
A Deep Support Vector Data Description (Deep SVDD) model trained for anomaly detection on natural images.
This model uses a ResNet-based encoder to learn a hypersphere representation of normal data. Images are classified as anomalies based on their distance from the center of this hypersphere.
Training Data:
Architecture:
Evaluated on CIFAR-10 (normal) vs MNIST (anomaly):
| Metric | Value |
|---|---|
| Accuracy | 87.00% |
| Precision | 80.33% |
| Recall | 98.00% |
| F1 Score | 88.29% |
Anomaly Score Separation: 6.15x (anomalies score ~6x higher than normal images)
from model import DeepSVDDAnomalyDetector
# Load model
detector = DeepSVDDAnomalyDetector.from_pretrained('.')
# Predict on image
score, is_anomaly = detector.predict('test.jpg')
print(f"Anomaly Score: {score:.6f}")
print(f"Is Anomaly: {is_anomaly}")
from huggingface_hub import snapshot_download
# Download model
model_path = snapshot_download(repo_id="ash12321/deep-svdd-anomaly-detection")
# Load
detector = DeepSVDDAnomalyDetector.from_pretrained(model_path)
The model supports three threshold presets:
# Optimal F1 (default, recommended)
detector.set_threshold('optimal') # threshold = 0.001618
# 95th percentile (balanced)
detector.set_threshold('95th') # threshold = 0.008501
# 99th percentile (conservative, fewer false positives)
detector.set_threshold('99th') # threshold = 0.015922
Threshold Comparison:
| Threshold | Accuracy | Precision | Recall | Use Case |
|---|---|---|---|---|
| Optimal (0.0016) | 87% | 80% | 98% | Recommended - Best F1 |
| 95th (0.0085) | 75% | 95% | 53% | Few false alarms |
| 99th (0.0159) | 68% | 100% | 35% | Zero false alarms |
deepsvdd_model.pth - Model weights and hypersphere parametersthresholds.pkl - All threshold configurationsthresholds.json - Thresholds in JSON formatconfig.json - Model configurationmodel.py - Inference coderequirements.txt - Python dependencies@misc{deep-svdd-anomaly-detection,
title={Deep SVDD Anomaly Detection Model},
author={ash12321},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/ash12321/deep-svdd-anomaly-detection}
}
Apache 2.0
Primary Use: Anomaly detection in natural image datasets
Good for:
Not recommended for: