Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🕵️ Real vs Fake Face Detector

An AI-powered system to detect Deepfake and AI-Generated faces using Deep Learning and Computer Vision.

🚀 Project Overview

With the rise of generative AI (GANs, Diffusion Models), distinguishing real human faces from synthetic ones has become a critical challenge. This project implements a Convolutional Neural Network (CNN) using Transfer Learning to classify images as "Real" or "Fake".

The system includes a Streamlit Web App for easy user interaction.

🛠️ Tech Stack

  • Deep Learning: TensorFlow, Keras
  • Architecture: MobileNetV2 (Transfer Learning)
  • Frontend: Streamlit
  • Data Processing: NumPy, PIL
  • Visualization: Matplotlib

🏗️ Model Architecture

We use MobileNetV2 pre-trained on ImageNet as a feature extractor, with a custom classification head:

  1. Input Layer: 128x128x3 (RGB Images)
  2. Base Model: MobileNetV2 (Frozen Weights)
  3. GlobalAveragePooling2D: Reduces spatial dimensions
  4. Dropout (0.2): Prevents overfitting
  5. Dense (Output): Sigmoid activation (0 = Fake, 1 = Real)

⚡ Optimizations for CPU Training

  • Image Size: Reduced to 128x128 for speed.
  • Batch Size: 32.
  • Data Pipeline: Uses tf.data.AUTOTUNE for caching and prefetching to prevent memory crashes.

📊 Results (10 Epochs)

  • Training Accuracy: ~80%
  • Test Accuracy: ~77% (on unseen data)
  • Loss: ~0.45

💻 How to Run Locally

1. Install Dependencies

pip install tensorflow numpy matplotlib streamlit pillow

2. Run the Streamlit App

streamlit run app.py

The app will open in your browser at http://localhost:8501.

3. Usage

  • Drag and drop an image of a face.
  • The model analyzes it in real-time.
  • Results show REAL (Green) or FAKE (Red) with a confidence score.

About

Binary Image Classification for Anti-Spoofing using a fine-tuned MobileNetV2 architecture. Features CPU-optimized training pipeline and an interactive real-time inference app built with Streamlit.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages