ash12321's picture
Upload Deep SVDD anomaly detection model
0e9dcc1 verified
Raw
History Blame Contribute Delete
766 Bytes
"""
Example usage of Deep SVDD Anomaly Detection Model
"""
from model import DeepSVDDAnomalyDetector
from huggingface_hub import snapshot_download
# Download model from HuggingFace
print("Downloading model...")
model_path = snapshot_download(repo_id="ash12321/deep-svdd-anomaly-detection")
# Load model
print("Loading model...")
detector = DeepSVDDAnomalyDetector.from_pretrained(model_path)
# Example: Predict on image
score, is_anomaly = detector.predict('test.jpg')
print(f"Score: {score:.6f}")
print(f"Anomaly: {is_anomaly}")
# Try different thresholds
for threshold in ['optimal', '95th', '99th']:
detector.set_threshold(threshold)
score, is_anomaly = detector.predict('test.jpg')
print(f"{threshold}: Score={score:.6f}, Anomaly={is_anomaly}")