Skip to content

aliviahossain/DeepFakes

Repository files navigation

Deepfake-Classifier

A deep learning classifier to determine if an image is Real or Fake (Deepfake).

🎭 Deepfake Classifier

A project that applies Deep Learning to classify images as Real or Fake. Designed to help understand the real-world application of Convolutional Neural Networks (CNNs) in media forensics and misinformation detection.


📌 Project Goal

Use a trained Convolutional Neural Network (CNN) to:

  • Classify user-uploaded images as "Real" or "Fake"
  • Demonstrate how deep learning can be applied to detect digital forgeries
  • Provide an open-source tool for learning, research, or further development in media verification

What this project does

This project is a binary image classifier for deepfake detection. It demonstrates how a pre-trained deep learning model can analyze an image to find subtle artifacts and patterns indicative of AI-generation.

It is not a comprehensive forensic analysis suite or a video detector. Instead, it focuses on a fundamental classification task:

“Is this image real or was it generated by AI?”


How it works

Given:

  • A pre-trained model – e.g., EfficientNet, ResNet, or a custom CNN trained on a large dataset of real and fake images.
  • Input Image – A user uploads an image file (e.g., JPG, PNG).

The classifier applies inference using the trained model to compute the output probability: the updated probability that the image is 'Fake' vs. 'Real'.


Why this matters

Deepfakes represent a significant challenge to digital trust. They can spread misinformation, commit fraud, and harass individuals. This tool makes the detection process explicit and transparent.

It can be useful as:

  • An educational resource for students and data scientists learning about CNNs and computer vision
  • A demo app for understanding the capabilities and limitations of deepfake detection
  • A foundation to expand toward more robust, multi-modal (video/audio) detection systems

💡 What is a Convolutional Neural Network (CNN)?

A CNN is a class of deep neural networks, most commonly applied to analyzing visual imagery. They use a series of 'filters' (convolutions) to automatically learn and detect hierarchical features in an image, from simple edges to complex patterns like eyes or artifacts.

Simplified Flow: Input Image -> [Convolution + Pooling Layers] -> [Flattening] -> [Fully Connected Layers] -> Output (Real / Fake)

Where:

  • Convolutional Layers: Scan the image to find patterns and features.
  • Pooling Layers: Reduce the image size while retaining the most important information.
  • Fully Connected Layers: Make the final classification decision based on the detected features.

🛠️ Features

  • 🧠 Implements a deep learning model (e.g., EfficientNet, TensorFlow/Keras)
  • 📤 Simple web interface to upload and classify images
  • ⚙️ Simple, extensible Python script using Flask
  • 👶 Beginner-friendly for open source contributors

🔍 Sample Use Case

Given:

  • A user uploads an image of a person's face.
  • The model analyzes the image for inconsistencies in lighting, shadows, skin texture, or eye reflections.

Output:

Classification: FAKE Confidence: 98.78%


🗂️ Project Struct

PROJECT/
├── .venv/
├── .vscode/
├── hardrvsf/
│   ├── fake/
│   └── real/
├── data.csv
├── logs/
├── rvsf/
│   ├── real_vs_fake / real-vs-fake/
│   │   ├── test/
│   │   ├── train/
│   │   └── valid/
│   ├── test.csv
│   ├── train.csv
│   └── valid.csv
└── python.ipynb

For a detailed, beginner-friendly explanation of what each file does, please read our guide:

➡️ View the Project Structure Guide


🚀 Getting Started

1. Clone the Repository

git clone [https://github.com/your-username/Deepfake-Classifier.git](https://github.com/your-username/Deepfake-Classifier.git)
cd Deepfake-Classifier

(Optional) Create and activate a virtual environment It's recommended to use a virtual environment to keep dependencies isolated.

On Windows (PowerShell):

python -m venv venv
.\venv\Scripts\Activate.ps1

On macOS / Linux:

python3 -m venv venv
source venv/bin/activate

2. Install Requirements

pip install -r requirements.txt

(Note: You may also need to download the pre-trained model file and place it in the /models directory if it's not included in the repo via Git LFS).

3. Run the App

python run.py

4. Open in Browser

[http://127.0.0.1:5000/](http://127.0.0.1:5000/)

Read the CONTRIBUTING.md file before making a pull request.


📜 License

This project is licensed under the MIT License.


🙌 Acknowledgements

This project was created and maintained by U Vikram and Alivia Hossain. Inspired by the challenge of combating digital misinformation and the fascinating field of generative AI.


About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages