--- license: apache-2.0 tags: - deepfake-detection - ensemble - deep-svdd - autoencoder - computer-vision datasets: - cifar10 - mnist metrics: - accuracy - precision - recall - f1 library_name: pytorch --- # Ensemble Deepfake Detector **State-of-the-art ensemble model** combining Deep SVDD + Autoencoder for deepfake detection with **77.5% accuracy** and **88.75% recall**. ## Model Description This ensemble combines two complementary anomaly detection approaches: 1. **Deep SVDD** - Detects anomalies via hypersphere distance in latent space 2. **Autoencoder** - Detects anomalies via reconstruction error Each model has 50% voting weight, and scores are averaged with an optimized threshold. ## Performance Evaluated on 800 test images (CIFAR-10 vs MNIST, CIFAR-10 vs Fashion-MNIST): | Metric | Value | |--------|-------| | **Accuracy** | **77.50%** | | **Precision** | **72.22%** | | **Recall** | **88.75%** 🎯 | | **F1 Score** | **79.46%** | | **Model Agreement** | 53.00% | **Key Strength:** 88.75% recall means it catches **nearly 9 out of 10 fakes**! ## Quick Start ```python from ensemble_model import EnsembleDeepfakeDetector # Load ensemble (downloads both models automatically) detector = EnsembleDeepfakeDetector.from_pretrained() # Predict on image score, is_fake = detector.predict('image.jpg') print(f"Deepfake Score: {score:.4f}") print(f"Is Fake: {is_fake}") ``` ## Installation ```bash pip install torch torchvision huggingface-hub pillow ``` ## Threshold Options The ensemble uses an **optimized threshold of 0.1163** by default: ```python # Use different thresholds detector.set_threshold(0.1163) # Optimal (default) - 88.75% recall detector.set_threshold(0.5) # Conservative - fewer false positives detector.set_threshold(0.05) # Sensitive - catch even more fakes ``` **Threshold Comparison:** | Threshold | Accuracy | Precision | Recall | Use Case | |-----------|----------|-----------|--------|----------| | **0.1163 (optimal)** | 77.5% | 72.2% | **88.8%** | **Recommended** - Best balance | | 0.5 (conservative) | 66.9% | 73.1% | 47.5% | Minimize false alarms | | 0.05 (sensitive) | ~70% | ~65% | ~95% | Maximum detection | ## Component Models This ensemble uses: - [ash12321/deep-svdd-anomaly-detection](https://huggingface.co/ash12321/deep-svdd-anomaly-detection) - [ash12321/deepfake-autoencoder-cifar10-v2](https://huggingface.co/ash12321/deepfake-autoencoder-cifar10-v2) ## How It Works 1. **Deep SVDD**: Learns a hypersphere around normal images. Fakes fall outside this sphere. 2. **Autoencoder**: Learns to reconstruct normal images. Fakes have high reconstruction error. 3. **Ensemble**: Averages both scores (50/50 voting) for robust detection. **Low Model Agreement (53%)** indicates the models detect different anomaly types - this is a strength! ## Training Data - CIFAR-10 (natural images) - CIFAR-100 (natural images) - STL-10 (natural images) ## Limitations - Trained on natural images - best for detecting distribution shift - May not generalize to all deepfake types - Requires RGB images resized to 128x128 ## Citation ```bibtex @misc{ensemble-deepfake-detector, title={Ensemble Deepfake Detector}, author={ash12321}, year={2024}, publisher={Hugging Face}, url={https://huggingface.co/ash12321/deepfake-ensemble-detector} } ``` ## License Apache 2.0