# adityacodes15/deepfake_detection architecture

> Architecture diagram of the GitHub repository adityacodes15/deepfake_detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adityacodes15/deepfake_detection
- Repository: https://github.com/adityacodes15/deepfake_detection

## Overview

DeepFake Detection accepts an image in the Gradio interface, runs YuNet face detection and face selection/preparation, then classifies a face as real or fake with a ResNet18-based inference engine. The dataset path separately preprocesses images into face samples and splits them by original image; evaluation and analysis report held-out and image-level results. The README also documents landmark transformation, standardized 224×224 inputs, and the 0.24 decision threshold. Some implementation details are unsampled, so only documented or indexed relationships are shown.

Main entry points: [`preprocessing/dataset_preprocessor.py`](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/dataset_preprocessor.py) (Dataset Preprocessor), [`engine/inference.py`](https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py) (Inference Engine), [`ui/app.py`](https://github.com/adityacodes15/deepfake_detection/blob/main/ui/app.py) (Gradio App), [`preprocessing/multi_face_processor.py`](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/multi_face_processor.py) (Multi-face Processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_gradio["Gradio App<br/>[app.py]"]
end

subgraph group_inference["Detection and Inference"]
  node_inference_engine["Inference Engine<br/>[inference.py]"]
  node_yunet["YuNet Detector<br/>[face_detector.py]"]
  node_face_selection["Face Selection<br/>[inference.py]"]
  node_classifier["ResNet18 Classifier<br/>[inference.py]"]
end

subgraph group_dataset["Dataset Preparation"]
  node_dataset_preprocessor["Dataset Preprocessor"]
  node_multi_face["Multi-face Processor"]
  node_face_processor["Face Processor<br/>[face_processor.py]"]
  node_facial_regions["Facial Regions<br/>[facial_regions.py]"]
  node_dataset_splitter["Dataset Splitter"]
end

subgraph group_reporting["Evaluation and Reporting"]
  node_evaluation["Model Evaluation<br/>[evaluate_model.py]"]
  node_result_analysis["Result Analysis<br/>[analyze_results.py]"]
  node_graph_generation["Result Graphs<br/>[generate_graphs.py]"]
end

node_user(("Image Uploader"))

node_user -->|"uploads image"| node_gradio
node_gradio -->|"requests prediction"| node_inference_engine
node_inference_engine -->|"detects faces"| node_yunet
node_inference_engine -->|"selects face"| node_face_selection
node_face_selection -.->|"provides face"| node_classifier
node_dataset_preprocessor -->|"detects faces"| node_yunet
node_dataset_preprocessor -->|"processes faces"| node_multi_face
node_dataset_preprocessor -->|"uses regions"| node_facial_regions
node_multi_face -->|"processes face"| node_face_processor
node_dataset_splitter -.->|"reads processed data"| node_dataset_preprocessor
node_evaluation -.->|"supplies predictions"| node_result_analysis
node_result_analysis -.->|"summarizes results"| node_graph_generation

click node_gradio "https://github.com/adityacodes15/deepfake_detection/blob/main/ui/app.py"
click node_inference_engine "https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py"
click node_yunet "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/face_detector.py"
click node_face_selection "https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py"
click node_classifier "https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py"
click node_dataset_preprocessor "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/dataset_preprocessor.py"
click node_multi_face "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/multi_face_processor.py"
click node_face_processor "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/face_processor.py"
click node_facial_regions "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/facial_regions.py"
click node_dataset_splitter "https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/dataset_splitter.py"
click node_evaluation "https://github.com/adityacodes15/deepfake_detection/blob/main/results/evaluate_model.py"
click node_result_analysis "https://github.com/adityacodes15/deepfake_detection/blob/main/results/analyze_results.py"
click node_graph_generation "https://github.com/adityacodes15/deepfake_detection/blob/main/results/generate_graphs.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_gradio toneBlue
class node_inference_engine,node_yunet,node_face_selection,node_classifier toneAmber
class node_dataset_preprocessor,node_multi_face,node_face_processor,node_facial_regions,node_dataset_splitter toneMint
class node_evaluation,node_result_analysis,node_graph_generation toneRose
class node_user toneIndigo
```

## Components

### User Interface

- [Gradio App](https://github.com/adityacodes15/deepfake_detection/blob/main/ui/app.py): `ui/app.py`

### Detection and Inference

- [Inference Engine](https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py): `engine/inference.py`
- [YuNet Detector](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/face_detector.py): `preprocessing/face_detector.py`
- [Face Selection](https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py): `engine/inference.py`
- [ResNet18 Classifier](https://github.com/adityacodes15/deepfake_detection/blob/main/engine/inference.py): `engine/inference.py`

### Dataset Preparation

- [Dataset Preprocessor](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/dataset_preprocessor.py): `preprocessing/dataset_preprocessor.py`
- [Multi-face Processor](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/multi_face_processor.py): `preprocessing/multi_face_processor.py`
- [Face Processor](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/face_processor.py): `preprocessing/face_processor.py`
- [Facial Regions](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/facial_regions.py): `preprocessing/facial_regions.py`
- [Dataset Splitter](https://github.com/adityacodes15/deepfake_detection/blob/main/preprocessing/dataset_splitter.py): `preprocessing/dataset_splitter.py`

### Evaluation and Reporting

- [Model Evaluation](https://github.com/adityacodes15/deepfake_detection/blob/main/results/evaluate_model.py): `results/evaluate_model.py`
- [Result Analysis](https://github.com/adityacodes15/deepfake_detection/blob/main/results/analyze_results.py): `results/analyze_results.py`
- [Result Graphs](https://github.com/adityacodes15/deepfake_detection/blob/main/results/generate_graphs.py): `results/generate_graphs.py`

### Other components

- **Image Uploader**

## Connections

- Image Uploader → Gradio App: uploads image (evidence: `ui/app.py`)
- Gradio App → Inference Engine: requests prediction (evidence: `ui/app.py`)
- Inference Engine → YuNet Detector: detects faces (evidence: `engine/inference.py`)
- Inference Engine → Face Selection: selects face (evidence: `engine/inference.py`)
- Face Selection → ResNet18 Classifier: provides face (evidence: `engine/inference.py`)
- Dataset Preprocessor → YuNet Detector: detects faces (evidence: `preprocessing/dataset_preprocessor.py`)
- Dataset Preprocessor → Multi-face Processor: processes faces (evidence: `preprocessing/dataset_preprocessor.py`)
- Dataset Preprocessor → Facial Regions: uses regions (evidence: `preprocessing/dataset_preprocessor.py`)
- Multi-face Processor → Face Processor: processes face (evidence: `preprocessing/multi_face_processor.py`)
- Dataset Splitter → Dataset Preprocessor: reads processed data
- Model Evaluation → Result Analysis: supplies predictions
- Result Analysis → Result Graphs: summarizes results
