How iitzirfan/deep-fake works
Project Type and Purpose
• This is a full-stack deep learning application for detecting deepfake videos.
• It consists of two main workflows:
a) The training pipeline (data ingestion, preprocessing, model training, evaluation, weight storage).
b) The inference service or web interface (serving predictions via a simple backend + browser UI).
Key Directories & Files
• data/: raw video folders (real/fake), entry point for the dataset.
• dataset.py + src/data_preprocessing.py: data I/O and preprocessing logic.
• train.py + src/cnn_model.py + src/config.py + src/evaluate.py: orchestrate training, model definition, hyper-parameters, evaluation metrics.
• best_model.h5 (implied by README): stores trained weights.
• frontend/app.py: lightweight web server (likely Flask) exposing an endpoint for video uploads and predictions.
• src/utils.py: shared utilities (e.g., loading model, image/video transforms).
• notebooks/: exploratory analysis and prototyping.
Architectural Patterns & Dependencies
• Layered architecture:
• Data layer (raw + processed) →
• Processing layer (dataset, preprocessing) →
• Model layer (training + evaluation) →
• Persistence layer (model weights file) →
• Service/API layer (inference endpoints) →
• Presentation layer (web UI).
• Technology stack: Python 3.7+, TensorFlow/Keras (implied by .h5), Flask or similar for frontend, Jupyter for notebooks.
Main Components
A. Data Source
• raw dataset directories (data/raw/real, data/raw/fake)
B. Data Processing Pipeline
• dataset.py, src/data_preprocessing.py
• outputs processed tensors/batches
C. Training Pipeline
• train.py orchestrates: loads config.py → imports cnn_model.py → trains model → calls evaluate.py → saves best_model.h5
D. Model Store
• best_model.h5 (artifact repository or local disk)
E. Inference Service
• frontend/app.py loads best_model.h5 via src/utils.py → exposes REST endpoint (/predict)
F. Web UI / Client
• Browser sends uploaded video to /predict → receives real/fake decision.
Architectural Patterns & Principles
• Separation of concerns: data ingestion vs. training vs. serving.
• Single responsibility: each module (dataset, model, utils, evaluate) has a clear role.
• Reusability: src/utils.py used by both train.py and frontend/app.py.
• Config-driven design: using config.py for hyper-parameters and paths.