Skip to main content
Deepfake Detection System
Computer Vision

Deepfake Detection System — Case Study

AUC: 0.8994
PythonTensorFlowMobileNetV2OpenCVGrad-CAMStreamlit

The Challenge

The first version of the model had an AUC of only 0.52 — essentially random guessing. After extensive debugging, the root cause was found: the class labels were reversed during training (fake=0 when it should be fake=1). This one mistake made the model predict the exact opposite of what was correct.

💡 The Approach

Switched from EfficientNetB4 (17 million parameters) to MobileNetV2 (3.4 million) which fits the limited 3,200-sample dataset better. Fixed the label ordering with explicit class mapping. Used 2-phase transfer learning: first train only the head, then fine-tune the last 30 layers.

🔄 Step-by-Step Process

01

Extracted faces from 400 videos (200 real, 200 fake) using OpenCV Haar cascade — creating 3,200 face crops

02

Split dataset 70% training / 15% validation / 15% testing with explicit class ordering fixed

03

Phase 1: Froze MobileNetV2 base, trained classification head only — AUC jumped to 0.8634

04

Phase 2: Unfroze last 30 layers, fine-tuned at lower learning rate — AUC reached 0.8994

05

Implemented Grad-CAM heatmaps to show WHERE in the face AI manipulation artifacts appear

06

Deployed publicly at deepfakedetectionai.streamlit.app for live testing by anyone

Final Result

Final validation AUC of 0.8994 — production-ready accuracy. Works on images, video files, and batch processing. Grad-CAM visualization shows exactly where manipulation occurred, making the AI explainable.

📚 Key Lesson

Always print your class label mapping before training. One reversed mapping turns a potentially excellent model into one that predicts the opposite of what you want — and the training loss still decreases, hiding the bug.