# pratyaksh-saxena018/deepfake-authenticator architecture

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

- Interactive diagram: https://gitdiagram.com/pratyaksh-saxena018/deepfake-authenticator
- Repository: https://github.com/pratyaksh-saxena018/deepfake-authenticator

## Overview

This repository provides image-authenticity detection through two Streamlit interfaces and a spectral-feature command-line workflow. The spectral path detects a face (or falls back to the full image), computes frequency features, and classifies them; training scripts prepare data and produce classifier weights. Separate MobileViT training and inference provide another image-classification path. A forensic-reporting module supports retrieval-grounded reports but is not shown connected to either interface. The README is empty, so relationships below rely on the sampled source; unsampled tests and other internals are omitted.

Main entry points: [`mini_predict.py`](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/mini_predict.py) (CLI prediction), [`prepare_data.py`](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/prepare_data.py) (Dataset preparation), [`train_classifier.py`](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/train_classifier.py) (Spectral training), [`data`](https://github.com/pratyaksh-saxena018/deepfake-authenticator/tree/main/data) (Real/fake images)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_streamlit_v2["Foundation UI<br/>[app_v2.py]"]
  node_foundation_model["Hosted detector"]
  node_streamlit_v3["MobileViT UI<br/>[app_v3.py]"]
end

subgraph group_spectral["Spectral Detection"]
  node_cli["CLI prediction<br/>[mini_predict.py]"]
  node_face["Face extraction<br/>[face_extractor.py]"]
  node_spectral_engine["Spectral features<br/>[spectral_engine.py]"]
end

subgraph group_models["Model Training"]
  node_mobile_weights["MobileViT weights"]
  node_xgb_model["XGBoost model"]
  node_data_builder["Dataset preparation<br/>[prepare_data.py]"]
  node_dataset_source["Hugging Face dataset"]
  node_dataset[("Real/fake images")]
  node_spectral_training["Spectral training"]
  node_deep_training["MobileViT training<br/>[train_deep.py]"]
end

subgraph group_reporting["Forensic Reporting"]
  node_reporter["Report synthesis<br/>[rag_reporter.py]"]
end

node_user(("Image submitter"))

node_user -->|"uploads image"| node_streamlit_v2
node_streamlit_v2 -->|"classifies image"| node_foundation_model
node_user -->|"uploads image"| node_streamlit_v3
node_streamlit_v3 -->|"loads weights"| node_mobile_weights
node_user -->|"provides image"| node_cli
node_cli -->|"extracts face"| node_face
node_cli -->|"computes features"| node_spectral_engine
node_cli -->|"loads classifier"| node_xgb_model
node_data_builder -->|"streams samples"| node_dataset_source
node_data_builder -->|"crops faces"| node_face
node_data_builder -->|"writes images"| node_dataset
node_spectral_training -->|"reads images"| node_dataset
node_spectral_training -->|"extracts features"| node_spectral_engine
node_spectral_training -->|"saves classifier"| node_xgb_model
node_deep_training -.->|"reads images"| node_dataset
node_deep_training -->|"saves weights"| node_mobile_weights

click node_streamlit_v2 "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/app_v2.py"
click node_streamlit_v3 "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/app_v3.py"
click node_mobile_weights "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/models/mobilevit_deepfake.pt"
click node_cli "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/mini_predict.py"
click node_face "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/face_extractor.py"
click node_spectral_engine "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/spectral_engine.py"
click node_xgb_model "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/models/xgboost_spectral_model.json"
click node_data_builder "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/prepare_data.py"
click node_dataset "https://github.com/pratyaksh-saxena018/deepfake-authenticator/tree/main/data"
click node_spectral_training "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/train_classifier.py"
click node_deep_training "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/train_deep.py"
click node_reporter "https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/rag_reporter.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_streamlit_v2,node_foundation_model,node_streamlit_v3 toneBlue
class node_cli,node_face,node_spectral_engine toneAmber
class node_mobile_weights,node_xgb_model,node_data_builder,node_dataset_source,node_dataset,node_spectral_training,node_deep_training toneMint
class node_reporter toneRose
class node_user toneIndigo
```

## Components

### User Interfaces

- [Foundation UI](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/app_v2.py): `app_v2.py`
- **Hosted detector**
- [MobileViT UI](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/app_v3.py): `app_v3.py`

### Spectral Detection

- [CLI prediction](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/mini_predict.py): `mini_predict.py`
- [Face extraction](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/face_extractor.py): `utils/face_extractor.py`
- [Spectral features](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/spectral_engine.py): `utils/spectral_engine.py`

### Model Training

- [MobileViT weights](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/models/mobilevit_deepfake.pt): `models/mobilevit_deepfake.pt`
- [XGBoost model](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/models/xgboost_spectral_model.json): `models/xgboost_spectral_model.json`
- [Dataset preparation](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/prepare_data.py): `prepare_data.py`
- **Hugging Face dataset**
- [Real/fake images](https://github.com/pratyaksh-saxena018/deepfake-authenticator/tree/main/data): `data`
- [Spectral training](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/train_classifier.py): `train_classifier.py`
- [MobileViT training](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/train_deep.py): `train_deep.py`

### Forensic Reporting

- [Report synthesis](https://github.com/pratyaksh-saxena018/deepfake-authenticator/blob/main/utils/rag_reporter.py): `utils/rag_reporter.py`

### Other components

- **Image submitter**

## Connections

- Image submitter → Foundation UI: uploads image (evidence: `app_v2.py`)
- Foundation UI → Hosted detector: classifies image (evidence: `app_v2.py`)
- Image submitter → MobileViT UI: uploads image (evidence: `app_v3.py`)
- MobileViT UI → MobileViT weights: loads weights (evidence: `app_v3.py`)
- Image submitter → CLI prediction: provides image (evidence: `mini_predict.py`)
- CLI prediction → Face extraction: extracts face (evidence: `mini_predict.py`)
- CLI prediction → Spectral features: computes features (evidence: `mini_predict.py`)
- CLI prediction → XGBoost model: loads classifier (evidence: `mini_predict.py`)
- Dataset preparation → Hugging Face dataset: streams samples (evidence: `prepare_data.py`)
- Dataset preparation → Face extraction: crops faces (evidence: `prepare_data.py`)
- Dataset preparation → Real/fake images: writes images (evidence: `prepare_data.py`)
- Spectral training → Real/fake images: reads images (evidence: `train_classifier.py`)
- Spectral training → Spectral features: extracts features (evidence: `train_classifier.py`)
- Spectral training → XGBoost model: saves classifier (evidence: `train_classifier.py`)
- MobileViT training → Real/fake images: reads images
- MobileViT training → MobileViT weights: saves weights (evidence: `train_deep.py`)
