Inspiration

🎯 Inspiration

With the rise of deepfake technology, distinguishing real content from AI-generated media has become a major challenge. Deepfakes can be misused in misinformation, identity theft, or digital impersonation. This project aims to tackle this problem by building a reliable deepfake detection model using modern computer vision techniques.

🛠️ What It Does

The model takes an image or video frame from a given test dataset and classifies it as either real or fake. This allows us to flag AI-generated visuals by analyzing subtle differences that are often imperceptible to the human eye. The system is designed to work on various domains, including human faces, animals, and vehicles — each labeled as "real" or "fake" based on metadata.

🧱 How We Built It

We used the PyTorch framework to define, train, and evaluate our classification model.

The model architecture was sourced from the timm library (PyTorch Image Models), which offers a wide selection of pre-trained CNN and transformer-based models.

We trained the model on the ArtiFact_240K dataset, which was organized into real/fake subfolders across various classes.

Images were preprocessed, augmented, and loaded using a custom PyTorch DataLoader pipeline.

Training was performed using GPU acceleration for faster convergence.

For evaluation, we used accuracy, precision, recall, and confusion matrix visualization to validate performance on a held-out test set.

Dataset Details

Dataset: ArtiFact_240K

Structure:

go Copy Edit train/ ├── real/ │ ├── human_faces/ │ ├── animals/ │ └── vehicles/ ├── fake/ ├── human_faces/ ├── animals/ └── vehicles/ A metadata.csv file was used to map each image path to its class label (real/fake) and category (human_faces, animals, vehicles).

Model Architecture

Model: vit_base_patch16_224 from timm library

Loss Function: CrossEntropyLoss

Optimizer: AdamW

Scheduler: Cosine Annealing LR

Evaluation Metrics: Accuracy, Precision, Recall, F1-score

How to Use

Clone the repo:

bash Copy Edit git clone https://github.com/your-username/deepfake-detector.git Install dependencies:

bash Copy Edit pip install -r requirements.txt Run the model:

bash Copy Edit python train.py python evaluate.py

Results

Achieved over 95% test accuracy on detecting deepfakes in the human_faces class.

Transfer learning with ViT models significantly improved generalization.

The model was robust to multiple domains (not just faces).

Future Work

Add support for video frame extraction and real-time deepfake detection.

Deploy as a web app using Streamlit or Flask.

Expand dataset to include other synthetic image types (e.g., GAN-generated).

Built With

Share this project:

Updates