PyTorch-based Deep Learning project that uses Transfer Learning (ResNet50) to classify images as "Real" or "Fake". This repository implements a binary classification model to distinguish between genuine and AI-generated faces. It includes data loading utilities, a training script, and a Streamlit-based web interface for easy inference.
This project uses the "140k Real and Fake Faces" dataset from Kaggle (https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces)
- Transfer Learning: Fine-tunes a pre-trained ResNet50 model on deepfake datasets.
- PyTorch Training Pipeline: Custom data loaders, binary cross-entropy loss, and metrics tracking tracking (Accuracy & F1-Score).
- Streamlit Web UI: A simple local web interface to upload images and run inference in real-time.
111.mp4
app.py: Streamlit application for inferencesrc/dataset.py: PyTorch dataset loaders and transformationssrc/model.py: ResNet50 architecture definitionsrc/train.py: Training and evaluation loops
To train the ResNet50 model from scratch, run the train.py script:
python src/train.pyThis will train the model and save the best weights to best_deepfake_model.pth.
To test the trained model interactively using the web interface:
streamlit run app.pyThis will launch a local server where you can upload images and see the prediction confidence scores.