# viveklumbhani/deepfake-detection-using-machine-learning architecture

> Architecture diagram of the GitHub repository viveklumbhani/deepfake-detection-using-machine-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/viveklumbhani/deepfake-detection-using-machine-learning
- Repository: https://github.com/viveklumbhani/deepfake-detection-using-machine-learning

## Overview

This is a deepfake-image detection system with a data preparation and model-training workflow, evaluation, and Streamlit inference apps. Videos can be sampled into labeled frames; image directories feed augmented training and validation generators. Training builds and saves three transfer-learning classifiers, while evaluation reports metrics for each and their averaged predictions. The interactive app accepts an image, shows individual and ensemble predictions, and can display a Grad-CAM overlay. Source excerpts establish the shown calls; other README capabilities are represented only where their implementation is supported by the tree.

Main entry points: [`src/config.py`](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/config.py) (Paths and settings), [`src/models.py`](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/models.py) (CNN builders), [`src/data_pipeline.py`](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/data_pipeline.py) (Image generators), [`app/app.py`](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/app/app.py) (Detection app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_preprocess["Frame extraction<br/>[preprocess.py]"]
  node_generators["Image generators<br/>[data_pipeline.py]"]
end

subgraph group_ml["Model development"]
  node_models["CNN builders<br/>[models.py]"]
  node_training["Model training<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_gradcam["Grad-CAM<br/>[explainability.py]"]
end

subgraph group_apps["Inference apps"]
  node_app["Detection app<br/>[app.py]"]
  node_simple_app["Simple detection app<br/>[app_simple.py]"]
end

subgraph group_shared["Shared configuration"]
  node_config["Paths and settings<br/>[config.py]"]
end

node_user(("Image user"))
node_video_source[("Video dataset")]

node_video_source -->|"provides videos"| node_preprocess
node_preprocess -.->|"prepares frames"| node_generators
node_generators -->|"supplies batches"| node_training
node_models -->|"builds classifiers"| node_training
node_training -->|"trains classifiers"| node_models
node_generators -->|"supplies validation data"| node_evaluation
node_models -->|"builds classifiers"| node_evaluation
node_user -->|"uploads image"| node_app
node_app -->|"builds classifiers"| node_models
node_app -->|"requests heatmap"| node_gradcam
node_user -->|"uploads image"| node_simple_app
node_simple_app -->|"builds classifiers"| node_models
node_preprocess -->|"reads paths and settings"| node_config
node_generators -->|"reads settings"| node_config
node_models -->|"reads input size"| node_config
node_training -->|"reads training settings"| node_config
node_evaluation -->|"reads model paths"| node_config
node_app -->|"reads model paths"| node_config
node_simple_app -->|"reads model paths"| node_config

click node_preprocess "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/preprocess.py"
click node_generators "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/data_pipeline.py"
click node_config "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/config.py"
click node_models "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/models.py"
click node_training "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/train.py"
click node_evaluation "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/evaluate.py"
click node_app "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/app/app.py"
click node_simple_app "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/app/app_simple.py"
click node_gradcam "https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/explainability.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_preprocess,node_generators,node_user toneBlue
class node_models,node_training,node_evaluation,node_gradcam,node_video_source toneAmber
class node_app,node_simple_app toneMint
class node_config toneRose
```

## Components

### Data preparation

- [Frame extraction](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/preprocess.py): `src/preprocess.py`
- [Image generators](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/data_pipeline.py): `src/data_pipeline.py`

### Model development

- [CNN builders](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/models.py): `src/models.py`
- [Model training](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/train.py): `src/train.py`
- [Model evaluation](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/evaluate.py): `src/evaluate.py`
- [Grad-CAM](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/explainability.py): `src/explainability.py`

### Inference apps

- [Detection app](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/app/app.py): `app/app.py`
- [Simple detection app](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/app/app_simple.py): `app/app_simple.py`

### Shared configuration

- [Paths and settings](https://github.com/viveklumbhani/deepfake-detection-using-machine-learning/blob/main/src/config.py): `src/config.py`

### Other components

- **Image user**
- **Video dataset**

## Connections

- Video dataset → Frame extraction: provides videos (evidence: `README.md`)
- Frame extraction → Image generators: prepares frames
- Image generators → Model training: supplies batches (evidence: `src/train.py`)
- CNN builders → Model training: builds classifiers (evidence: `src/train.py`)
- Model training → CNN builders: trains classifiers (evidence: `src/train.py`)
- Image generators → Model evaluation: supplies validation data (evidence: `src/evaluate.py`)
- CNN builders → Model evaluation: builds classifiers (evidence: `src/evaluate.py`)
- Image user → Detection app: uploads image (evidence: `app/app.py`)
- Detection app → CNN builders: builds classifiers (evidence: `app/app.py`)
- Detection app → Grad-CAM: requests heatmap (evidence: `app/app.py`)
- Image user → Simple detection app: uploads image (evidence: `app/app_simple.py`)
- Simple detection app → CNN builders: builds classifiers (evidence: `app/app_simple.py`)
- Frame extraction → Paths and settings: reads paths and settings (evidence: `src/preprocess.py`)
- Image generators → Paths and settings: reads settings (evidence: `src/data_pipeline.py`)
- CNN builders → Paths and settings: reads input size (evidence: `src/models.py`)
- Model training → Paths and settings: reads training settings (evidence: `src/train.py`)
- Model evaluation → Paths and settings: reads model paths (evidence: `src/evaluate.py`)
- Detection app → Paths and settings: reads model paths (evidence: `app/app.py`)
- Simple detection app → Paths and settings: reads model paths (evidence: `app/app_simple.py`)
