Skip to content

huda-usman/deepfake-detector-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# πŸ” DeepFake Image Detector

Can you tell what's real? Our CNN can.

A deep learning system that detects AI-generated (fake) face images with high confidence β€” featuring a full interactive GUI, batch detection, and live analytics.


Python TensorFlow Kaggle License



✨ What It Does

Upload a face image β†’ get an instant REAL or FAKE verdict with confidence score, probability breakdown, and visual analytics.

Feature
πŸ€– CNN classifier trained on thousands of real and AI-generated face images
πŸ–ΌοΈ Single & batch detection β€” analyze one image or hundreds at once
πŸ“Š Live analytics dashboard β€” confidence charts, distribution graphs
πŸ“‹ Prediction history β€” full log with CSV export
⚑ Runs on Kaggle β€” no installation or setup needed

πŸš€ Quickstart β€” Run in 4 Steps on Kaggle

No installation. No configuration. Just click and run.

1. Go to kaggle.com and create a free account
        ↓
2. Add the dataset β†’ search "deepfake-and-real-images" in Kaggle datasets
        ↓
3. Open notebooks/deepfake_detector.ipynb in a new Kaggle notebook
        ↓
4. Click "Run All" β€” training + evaluation + interactive app launches automatically βœ…

🧠 Model Architecture

Input Image (128 Γ— 128 Γ— 3)
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Conv2D(32)  + BatchNorm    β”‚  ← Block 1
β”‚  MaxPool    + Dropout(0.25) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Conv2D(64)  + BatchNorm    β”‚  ← Block 2
β”‚  MaxPool    + Dropout(0.25) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Conv2D(128) + BatchNorm    β”‚  ← Block 3
β”‚  MaxPool    + Dropout(0.30) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Dense(128)  + BatchNorm    β”‚  ← Classifier Head
β”‚  Dropout(0.50)              β”‚
β”‚  Dense(1, sigmoid)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
   πŸ€– FAKE (0)  or  πŸ‘€ REAL (1)
Setting Value
Optimizer Adam (lr = 0.001)
Loss Binary Cross-Entropy
Input Size 128 Γ— 128 Γ— 3
Early Stopping patience = 5
LR Scheduler ReduceLROnPlateau

πŸ–₯️ Interactive App

The app runs directly inside the Kaggle notebook with 3 tabs:

πŸ” Detect Tab

Upload a single image or a batch β€” choose between two modes:

  • Basic Mode β†’ Label + confidence donut chart
  • Diagnostic Mode β†’ Label + confidence + full probability bar chart

πŸ“Š Dashboard Tab

Live statistics that update after every detection:

  • Real vs Fake distribution pie chart
  • Confidence score histogram across all predictions

πŸ“‹ History Tab

  • Scrollable log of every prediction made
  • Timestamp, filename, result, confidence, raw score
  • One-click CSV export

πŸ“ Project Structure

deepfake-detector-system/
β”‚
β”œβ”€β”€ πŸ““ notebooks/
β”‚   └── deepfake_detector.ipynb   ← ⭐ Start here
β”‚
β”œβ”€β”€ 🧠 src/
β”‚   β”œβ”€β”€ data_loader.py            ← Dataset paths + generators
β”‚   β”œβ”€β”€ model.py                  ← CNN architecture
β”‚   β”œβ”€β”€ train.py                  ← Training loop + callbacks
β”‚   β”œβ”€β”€ evaluate.py               ← Metrics + confusion matrix
β”‚   └── predict.py                ← Single & batch inference
β”‚
β”œβ”€β”€ πŸ–₯️ app/
β”‚   └── app.py                    ← Interactive GUI
β”‚
β”œβ”€β”€ πŸ“¦ data/                      ← Dataset (not tracked by Git)
β”œβ”€β”€ πŸ’Ύ models/                    ← Saved .h5 files (not tracked)
β”œβ”€β”€ πŸ“€ outputs/                   ← Evaluation outputs
β”‚
β”œβ”€β”€ requirements.txt
└── README.md

πŸ’» Run Locally

Click to expand local setup instructions

1. Clone the repo

git clone https://github.com/huda-usman/deepfake-detector-system
cd deepfake-detector-system

2. Install dependencies

pip install -r requirements.txt

3. Download the dataset

Get it from Kaggle and place it as:

data/
└── Dataset/
    β”œβ”€β”€ Train/   β†’ Fake/  Real/
    β”œβ”€β”€ Validation/ β†’ Fake/  Real/
    └── Test/    β†’ Fake/  Real/

4. Train

python src/train.py

5. Evaluate

python src/evaluate.py

6. Predict a single image

python src/predict.py --image path/to/face.jpg

7. Launch the app

jupyter notebook notebooks/deepfake_detector.ipynb

πŸ“¦ Requirements

Package Version
Python β‰₯ 3.9
TensorFlow β‰₯ 2.10
OpenCV β‰₯ 4.6
scikit-learn β‰₯ 1.1
ipywidgets β‰₯ 8.0
pandas β‰₯ 1.5
matplotlib β‰₯ 3.6
pip install -r requirements.txt

πŸ—‚οΈ Dataset

deepfake-and-real-images on Kaggle

Split Fake Real
Train βœ… βœ…
Validation βœ… βœ…
Test βœ… βœ…

πŸ™‹β€β™€οΈ Connect with Me

Developed by Huda Usman

LinkedIn


⭐ If you found this project interesting, please give it a star! ⭐

About

CNN-based DeepFake Image Detector with GUI, batch detection, and confidence analytics.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors