Skip to content

Dipakk7/DeepfakeDetect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Deepfake Detection Platform

A Full-Stack AI-Powered Solution for Detecting Manipulated Videos

Python React FastAPI PyTorch License

Features โ€ข Installation โ€ข Usage โ€ข API Documentation โ€ข Model Details


๐Ÿ“– Overview

Deepfake Detection Platform is a comprehensive full-stack application that leverages state-of-the-art deep learning to identify manipulated videos in real-time. Built with a hybrid ResNet50 + LSTM architecture, the platform combines spatial feature extraction with temporal sequence modeling to achieve high accuracy in detecting deepfake content.

๐ŸŽฏ Key Highlights

  • ๐ŸŽฅ Real-time Video Analysis - Upload and analyze videos instantly
  • ๐Ÿง  Advanced AI Model - ResNet50 + LSTM architecture with 80%+ accuracy
  • ๐ŸŽจ Modern Web Interface - Beautiful, responsive React frontend with dark mode
  • โšก RESTful API - FastAPI backend with comprehensive endpoints
  • ๐Ÿ”’ Privacy-First - Files processed securely and deleted after analysis
  • ๐Ÿ“Š Detailed Analytics - Confidence scores and visual feedback

โœจ Features

๐Ÿ–ฅ๏ธ Frontend (React Web Application)

  • ๐ŸŽจ Modern UI/UX - Built with Tailwind CSS and Framer Motion animations
  • ๐ŸŒ™ Dark Mode - Comfortable viewing in any lighting condition
  • ๐Ÿ“ค Drag & Drop Upload - Intuitive file upload with progress tracking
  • ๐Ÿ“ˆ Visual Results - Interactive confidence meters and analytics charts
  • ๐Ÿ“ฑ Responsive Design - Works seamlessly on desktop, tablet, and mobile
  • ๐Ÿ“š Help & Documentation - Comprehensive guides and FAQ sections
  • ๐ŸŽญ Smooth Animations - Polished user experience with Framer Motion

โš™๏ธ Backend (FastAPI REST API)

  • ๐ŸŽฅ Video Processing - Supports multiple formats (MP4, AVI, MKV, MOV, WEBM)
  • ๐Ÿงฉ Face Detection - MTCNN-based face extraction before analysis
  • โšก High Performance - Optimized inference pipeline with GPU support
  • ๐Ÿ“Š Confidence Scoring - Sigmoid-based probability outputs
  • ๐Ÿ”„ Batch Processing - Analyze multiple videos simultaneously
  • ๐Ÿ“ก RESTful Endpoints - Well-documented API with OpenAPI/Swagger docs
  • ๐Ÿฅ Health Monitoring - System health and model status endpoints

๐Ÿ› ๏ธ Tech Stack

Backend Technologies

Component Technology Purpose
Deep Learning PyTorch, TorchVision Model architecture and inference
API Framework FastAPI, Uvicorn REST API server
Video Processing OpenCV, Pillow Video frame extraction and preprocessing
Face Detection facenet-pytorch (MTCNN) Face detection and alignment
Language Python 3.10+ Backend development

Frontend Technologies

Component Technology Purpose
Framework React 18.2 UI framework
Styling Tailwind CSS Utility-first CSS framework
Routing React Router DOM Client-side routing
Animations Framer Motion Smooth UI animations
Icons Lucide React Icon library
Charts Recharts Data visualization
File Upload React Dropzone Drag-and-drop file handling

๐Ÿ“ฆ Installation & Setup

Prerequisites

  • Python 3.10 or higher
  • Node.js 16+ and npm
  • CUDA-capable GPU (optional, for faster inference)

Step 1: Clone the Repository

git clone https://github.com/Dipakk7/DeepfakeDetect.git
cd DeepfakeDetect

Step 2: Backend Setup

Create and activate a virtual environment:

# Windows
python -m venv venv
venv\Scripts\activate

# Linux/Mac
python -m venv venv
source venv/bin/activate

Install Python dependencies:

pip install -r requirements.txt

Step 3: Frontend Setup

Install Node.js dependencies:

npm install

Step 4: Download Model Weights

The pretrained model weights are required for inference. Download them from:

๐Ÿ‘‰ Google Drive Link

Or use command line:

pip install gdown
gdown 1ZSp7lvbaQhoN51nsaO8Oi0WA1cMFYnb6 -O model_epoch_30.pth

Set the model path (optional, defaults to model_epoch_30.pth):

# Windows
set MODEL_PATH=model_epoch_30.pth

# Linux/Mac
export MODEL_PATH=model_epoch_30.pth

Step 5: Run the Application

Terminal 1 - Start Backend Server:

python backend.py

โœ… Backend API running at http://localhost:8000

Terminal 2 - Start Frontend Development Server:

npm start

โœ… Frontend app running at http://localhost:3000

๐Ÿ’ก Tip: Make sure both servers are running simultaneously. The frontend is configured to proxy API requests to the backend.


๐Ÿš€ Usage

Web Interface

  1. Navigate to http://localhost:3000 in your browser
  2. Click "Analyze Now" or go to the Upload page
  3. Drag and drop a video file or click to browse
  4. Wait for the analysis to complete (typically 3-5 seconds)
  5. View detailed results with confidence scores and visualizations

API Usage

Single Video Prediction

curl -X POST "http://localhost:8000/predict" \
  -F "file=@path/to/your/video.mp4"

Response:

{
  "video_name": "video.mp4",
  "prediction": "REAL",
  "confidence": 0.87,
  "is_fake": false,
  "frames_analyzed": 12,
  "raw_score": 1.95
}

Batch Prediction

curl -X POST "http://localhost:8000/predict/batch" \
  -F "files=@video1.mp4" \
  -F "files=@video2.mp4"

Health Check

curl http://localhost:8000/health

๐Ÿ“ก API Endpoints

Method Endpoint Description Response
GET / Basic health check Status and device info
GET /health Detailed system health Model status and configuration
POST /predict Single video prediction Prediction results with confidence
POST /predict/batch Batch video analysis Array of prediction results
GET /info Model information Architecture and configuration details
GET /docs API documentation Interactive Swagger UI

Interactive API Documentation

Visit http://localhost:8000/docs for interactive API documentation powered by Swagger UI.


๐Ÿง  Model Architecture

ResNet50 + LSTM Hybrid Model

The detection model combines the strengths of convolutional and recurrent neural networks:

Input Video โ†’ Frame Extraction โ†’ Face Detection (MTCNN) โ†’ ResNet50 Feature Extraction 
โ†’ LSTM Temporal Modeling โ†’ Classification Head โ†’ Output (Real/Fake + Confidence)

Architecture Details:

  • Spatial Feature Extractor: ResNet50 (pretrained on ImageNet)
  • Temporal Model: Bidirectional LSTM (256 hidden units)
  • Input: 12 frames per video, 224ร—224 resolution
  • Output: Binary classification (Real/Fake) with confidence score

Training Details

  • Dataset: Deepfake Detection Challenge (DFDC) by Meta
  • Training Strategy: Class-imbalance handling (weighted loss + oversampling)
  • Optimization: Adam optimizer with learning rate scheduling
  • Validation: 5-fold cross-validation

Performance Metrics

Metric Value
Accuracy 80.%
Precision 74.%
Recall 54.%
F1-Score 51.%

๐Ÿ“‚ Project Structure

DeepfakeDetect/
โ”œโ”€โ”€ backend.py                 # FastAPI backend server
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ package.json              # Node.js dependencies
โ”œโ”€โ”€ .gitignore                # Git ignore rules
โ”‚
โ”œโ”€โ”€ src/                      # React frontend source
โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ Button.js
โ”‚   โ”‚   โ”œโ”€โ”€ Card.js
โ”‚   โ”‚   โ”œโ”€โ”€ FileUpload.js
โ”‚   โ”‚   โ”œโ”€โ”€ VideoPlayer.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ pages/               # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ LandingPage.js
โ”‚   โ”‚   โ”œโ”€โ”€ UploadPage.js
โ”‚   โ”‚   โ”œโ”€โ”€ ResultsPage.js
โ”‚   โ”‚   โ”œโ”€โ”€ AboutPage.js
โ”‚   โ”‚   โ””โ”€โ”€ HelpPage.js
โ”‚   โ”œโ”€โ”€ context/             # React context providers
โ”‚   โ”‚   โ””โ”€โ”€ DarkModeContext.js
โ”‚   โ”œโ”€โ”€ App.js              # Main app component
โ”‚   โ””โ”€โ”€ index.js            # Entry point
โ”‚
โ”œโ”€โ”€ public/                  # Static assets
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ images/
โ”‚
โ”œโ”€โ”€ Backend/                 # Additional backend files
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ””โ”€โ”€ model_epoch_30.pth      # Pretrained model weights (download separately)

โš™๏ธ Configuration

Environment Variables

Variable Description Default
MODEL_PATH Path to model weights file model_epoch_30.pth
PREDICTION_THRESHOLD Classification threshold (0-1) 0.5
HOST Backend server host 0.0.0.0
PORT Backend server port 8000

Example Configuration

# Windows
set MODEL_PATH=model_epoch_30.pth
set PREDICTION_THRESHOLD=0.5
set PORT=8000

# Linux/Mac
export MODEL_PATH=model_epoch_30.pth
export PREDICTION_THRESHOLD=0.5
export PORT=8000

๐Ÿ“Š Dataset Information

The model was trained on the Deepfake Detection Challenge (DFDC) dataset, released by Meta (Facebook) and partners. This dataset contains:

  • Thousands of real and manipulated videos
  • Diverse deepfake generation techniques
  • Various video qualities and resolutions
  • Real-world scenarios and conditions

Dataset Access:

  • Kaggle Competition
  • Download using Kaggle API: kaggle competitions download -c deepfake-detection-challenge

๐Ÿงช Development

Running Tests

# Backend tests (if available)
python -m pytest tests/

# Frontend tests
npm test

Building for Production

Frontend:

npm run build

Backend: The FastAPI server can be deployed using:

  • Docker
  • Gunicorn with Uvicorn workers
  • Cloud platforms (AWS, GCP, Azure)

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can help:

  1. ๐Ÿ› Report Bugs - Open an issue describing the bug
  2. ๐Ÿ’ก Suggest Features - Share your ideas for improvements
  3. ๐Ÿ”ง Submit Pull Requests - Fix bugs or add new features
  4. ๐Ÿ“ Improve Documentation - Help make the docs better

Contribution Guidelines

  • Fork the repository
  • Create a feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

๐Ÿ› Known Issues

  • Model weights need to be downloaded separately (due to GitHub file size limits)
  • GPU recommended for faster inference (CPU works but slower)
  • Large video files may take longer to process

๐Ÿ”ฎ Future Enhancements

  • Real-time video stream analysis
  • Image deepfake detection
  • Model explainability features
  • User authentication and history
  • API rate limiting and usage analytics
  • Docker containerization
  • CI/CD pipeline setup

๐Ÿ‘จโ€๐Ÿ’ป Author

Sayali More

Dipak Khandagale

Priya Marmat


๐Ÿ™ Acknowledgments

  • Meta (Facebook) for the Deepfake Detection Challenge dataset
  • PyTorch team for the excellent deep learning framework
  • FastAPI creators for the modern Python web framework
  • React team for the powerful UI library
  • All open-source contributors whose libraries made this project possible

โญ Star this repo if you find it helpful!

Built with โค๏ธ using FastAPI, PyTorch, React, and OpenCV to ensure digital media authenticity.

โฌ† Back to Top

About

In this project, I built a deep learning model to detect fake and real videos. I used ResNet50 for feature extraction and LSTM to understand video sequences. The model was trained on around 400 videos and achieved about 84.85% accuracy. I deployed the model using FastAPI for real-time predictions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors