This project focuses on detecting deepfake images and videos, as well as AI-generated images. The model classifies inputs into three categories: real, deepfake, and AI-generated. The model has achieved an accuracy of 98.1% using the EfficientNet_b3 architecture.
- Architecture: EfficientNet_b3, a Convolutional Neural Network (CNN) known for its efficiency and accuracy.
- Training Data: Diverse dataset of images and videos, including celebrity images and various other sources.
- Accuracy: Achieved an accuracy of 98.1% on the validation set.
- Real-time detection: Upload an image or video to get instant classification results.
- Three-class classification: Classifies inputs as real, deepfake, or AI-generated.
- User-friendly interface: Drag-and-drop functionality for easy file upload.
- Flask backend: Serves the model and handles predictions.
- Next.js frontend: Provides a user-friendly interface for file upload and displays results.
- Docker (optional)
- Python 3.7+
- Flask
- Flask-CORS
- EfficientNet_pytorch
- Pillow
- OpenCV
- Node.js
- npm
- next
- react-dropzone
- react-router-dom
-
Clone the repository:
git clone https://github.com/yourusername/deepfake-detection.git cd deepfake-detection/backend -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Run the Flask app:
python app.py
OR
-
Clone the repository:
git clone https://github.com/yourusername/deepfake-detection.git cd deepfake-detection -
Build and run the Docker container:
docker build -t deepfake-backend . docker run -p 9000:9000 deepfake-backend -
Backend will be available at:
http://localhost:9000
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the Next.js app:
npm run dev
deepfake-detection/
│
├── backend/
│ ├── app.py
│ ├── requirements.txt
│ └── model_epoch_1.pth
│
├── frontend/
│ ├── app/
│ ├── components/
│ ├── public/
│ ├── package.json
│ ├── next.config.js
│ └── ...
│
├── Dockerfile
│
└── README.md
-
Backend: Start using Docker.
docker run -p 9000:9000 deepfake-backend
OR
cd backend python app.py -
Frontend: Start the Next.js application.
cd frontend npm run dev -
Access the application: Open your browser and navigate to
http://localhost:3000.
- Upload a file: Drag and drop an image or video file into the dropzone, or click to select a file.
- View results: The model will process the file and display the classification results along with the probabilities for each class (real, deepfake, AI-generated).
The EfficientNet_b3 model was trained on a diverse dataset including real and deepfake images, as well as AI-generated images. The training process involved using various augmentation techniques to enhance the model's ability to generalize across different types of images and videos.
The Flask backend handles the model loading, preprocessing of input files, and prediction. It also includes endpoints to serve the Next.js frontend and manage API requests.
The Next.js frontend provides a user-friendly interface for uploading files and viewing the classification results. It uses react-dropzone for drag-and-drop functionality and communicates with the Flask backend to fetch predictions.
Contributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or improvements.