A full-stack deepfake detection and generation platform.
Built, trained, and deployed end-to-end: custom dataset, fine-tuned detection model, GradCAM explainability, and a face-swap generation module for adversarial research.
91.40% accuracy on 4,500 held-out images from a self-collected dataset of 10,852.
| Component | Details |
|---|---|
| Dataset | Collected and generated 10,852 images (real + inswapper_128, SimSwap and DeepFaceLab face-swaps) — published on HuggingFace. |
| Detection model | Fine-tuned EfficientNet-B4 on the custom dataset — 8 epochs, AdamW, cosine scheduler |
| GradCAM | Implemented gradient hooks on the last conv block to produce per-prediction heatmaps |
| Generation pipeline | Integrated InsightFace inswapper_128 with a full parameter control UI |
| Full-stack platform | Next.js 14 frontend + FastAPI backend with Google OAuth |
| Metric | Score |
|---|---|
| Accuracy | 91.40% |
| Precision | 93.57% |
| Recall | 89.51% |
| F1 | 0.9150 |
| AUC-ROC | 0.9486 |
| False Positive Rate | 6.58% |
| Called real | Called swapped | |
|---|---|---|
| Is real | 2,031 | 143 |
| Is swapped | 244 | 2,082 |
Every metric above is derived from this matrix. The 143 false positives are the number that matters operationally — each one is an authentic photograph flagged as fake.
Training: 380 × 380 input · batch 16 · AdamW lr=3e-5 · cosine annealing · flip/rotate/color-jitter augmentation
1. Detecting without explaining
Confidence scores alone are not enough for forensic or academic use. I implemented GradCAM via PyTorch gradient hooks that highlights the exact facial regions — eye boundaries, jaw edges, skin blending — that triggered the prediction, making every result auditable.
2. Generalization across fake types
The model was trained on three swap pipelines — inswapper_128, SimSwap and DeepFaceLab — and holds above 89% across them. It drops to 78.4% on Stable Diffusion faces, which are synthesised whole rather than composited and so leave none of the blending artifacts it learned. I report that gap rather than hide it: it defines what the model is actually for.
3. Compression robustness
JPEG compression destroys high-frequency noise that most detectors rely on. Training augmentation includes color/brightness jitter and resolution downscaling to force the model to detect structural artifacts — boundary blending errors, geometry mismatches — that survive re-encoding.
4. Video analysis
Single-frame detection misses temporal patterns. I built a frame-by-frame timeline pipeline that processes sampled frames, renders a REAL/FAKE bar per frame, and computes a fake ratio across the full clip so temporal swap regions are visible.
5. Closed-loop adversarial testing
By combining generation and detection in one platform, I can generate a swap → run detection → inspect GradCAM → identify blind spots → re-train. This closed loop is not possible with detection-only tools.
| Method | Accuracy | Relationship to training set |
|---|---|---|
| StyleGAN2 | 94.8% | In distribution |
| inswapper_128 | 91.5% | In distribution |
| FaceSwap | 89.3% | In distribution |
| DeepFaceLab | 85.1% | Partially held out |
| Stable Diffusion | 78.4% | Out of distribution |
Accuracy tracks how close a method sits to the training distribution.
Frontend: Next.js 14 · TypeScript · Tailwind · Framer Motion
Backend: FastAPI · Python 3.10
ML: PyTorch · timm · InsightFace · ONNX Runtime
Auth: NextAuth.js + Google OAuth
Dataset: 🤗 Sowaiba01/deepguard-dataset
Model: 🤗 Sowaiba01/deepguard-ai
# Backend
cd backend && python -m venv venv && venv\Scripts\activate
pip install -r requirements.txt
# Add models/efficientnet_b4_deepguard_v2.pth and models/inswapper_128.onnx
uvicorn main:app --reload --port 8000
# Frontend
cd frontend && npm install
# Create .env.local (see .env.example)
npm run devLicense: MIT