How balaji-kartheek/deepfake_detection works
Project Type and Purpose
• This is a full-stack DeepFake detection system with three main phases:
a. Offline Data and Model Workflow (Pre-processing + Model Training)
b. Model Registry (Saved Models)
c. Online Inference & Deployment (Flask web app with frontend UI)
• Purpose: ingest user-uploaded videos, detect whether they are real or fake by combining CNN feature extractors + RNN classifier, and display results with face detection overlays.
File Structure Analysis
• Top-level directories:
• Dataset (raw video files and Readme)
• Pre-Processing (Jupyter notebook and documentation)
• Model Training (training scripts/data/config)
• Saved Models (trained .h5 artifacts)
• Deploy (Flask app: app.py, templates/, static/, whl packages, requirements.txt)
• Pattern: separate offline ML pipelines vs. online inference service.
• Deployment: Flask “app.py” serves HTML/CSS frontend (templates/upload.html, upload.css) and static assets (uploads folder, model .h5 in Deploy/models).
README Insights
• Offline steps: load dataset → extract frames → face subframe extraction → landmark detection → framewise feature extraction.
• Prediction: user uploads video → frames extracted → face detected → features passed to model → classification per frame aggregated → result (REAL/FAKE).
• Technologies: Python, OpenCV, TensorFlow (efficientNet, InceptionV3, GRU), Flask frontend.
a. Main Components
1. Data Source Layer
‑ Raw video dataset (real & fake videos)
2. Offline Pipeline (batch processes)
‑ Frame Extractor
‑ Face Detector & Landmark Extraction
‑ Feature Extractor (pre-trained CNNs)
‑ Sequence Model Trainer (GRU RNN)
3. Model Registry
‑ Saved .h5 models (CNN, CNN+RNN)
4. Deployment Service (Flask API)
‑ Inference Engine (loads model, runs detection)
‑ File Storage (static/uploads)
5. Frontend UI
‑ Upload Page (HTML/CSS)
‑ Result Display (video player + overlay)
6. External Services & Libraries
‑ OpenCV, TensorFlow, Flask, Python packages
b. Relationships and Interactions
• Offline Pipeline reads Dataset → produces Saved Models
• Deploy Service loads Saved Models at startup
• User uploads video via Frontend → Flask API writes to static/uploads → Inference Engine invokes:
1) Frame extraction
2) Face detection/landmarks
3) Feature extraction (CNN)
4) Sequence classification (GRU)
• Inference Engine returns:
• Classification result (REAL vs FAKE)
c. Architectural Patterns and Principles
• Separation of Concerns: offline ML training vs online inference
• Modular pipeline steps (pre-processing, training, inference)
• Model Registry for versioning
• Client-Server pattern: Web UI ↔ REST API
• Stateless inference service (each video independent)
d. Key Technologies
• OpenCV for video/frame processing & face detection
• TensorFlow / Keras for CNN + RNN models
• Flask for lightweight web service
• HTML5/CSS for frontend
• Python libraries: pandas, seaborn, scikit-learn