This project provides deepfake detection for images and videos using:
- Face detection: MTCNN (
facenet-pytorch) - UI: Gradio
For videos, the app samples every Nth frame, detects faces, classifies each face, and aggregates one final verdict.
- Image deepfake detection with face bounding boxes
- Video deepfake detection with frame sampling
- Per-face predictions and overall verdict
- Explicit
No face detectedresult when no valid faces are found - Warning banner in UI for safe usage
app.py: Gradio app entrypointsrc/model_service.py: model loading and inferencesrc/face_service.py: MTCNN detection and face cropssrc/image_pipeline.py: image processing flowsrc/video_pipeline.py: sampled-frame video processingsrc/rendering.py: box rendering helperssrc/aggregation.py: overall decision logic
- Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txt- Run the app:
python app.pyThen open the local Gradio URL shown in the terminal.
- The classifier is image-based. Video detection is an approximation through sampled frame analysis.
- First run downloads model weights, so startup can take longer.
- If you get codec issues on videos, install FFmpeg and retry.
You can tune defaults in src/config.py:
FACE_CONFIDENCE_THRESHOLDFAKE_SCORE_THRESHOLDVIDEO_SAMPLE_RATEMAX_FACES_PER_FRAMEMAX_VIDEO_FRAMES_TO_PROCESS