How saarthaktiwari-04710/deepfake-detection works
This repository combines a two-stream deepfake classifier, a training workflow, and a FastAPI inference/localization path. Training loads labeled images, prepares spatial and FFT inputs, optimizes the model, and evaluates AUC/EER. The inference router accepts uploads, runs face-aware classification, optionally requests localization for confident fake predictions, and formats a response. The separately defined main.py endpoint is a placeholder and is not shown as invoking that router. The README describes the two-stream design; the graph follows sampled implementation for wiring.
Main entry points: train.py Training loop · predict.py Prediction router · detector.py Detection service · localizer.py Localization service
Components 15
Model training
- Training loop
train.py - Image dataset
src/dataset.py - Two-stream model
src/models.py - Loss and metrics
src/utils.py - Training config
configs/train_config.yaml
Inference services
- Detection service
backend/app/routers/backend/app/services/detector.py - YOLO face detector
HTTP interfaces
- Prediction router
backend/app/routers/predict.py - Prediction response
backend/app/schemas.py - Placeholder endpoint
backend/app/main.py
Localization
- Localization service
backend/app/services/localizer.py - SAM segmentation
- Grad-CAM
Other components
- Image uploader
- API client
Connections 17
- Training loop → Training config: reads config
- Training loop → Image dataset: creates datasets
- Image dataset → Training loop: yields image batches
- Training loop → Two-stream model: trains and evaluates
- Training loop → Loss and metrics: computes loss and EER
- Training loop → Two-stream model: saves weights
- Image uploader → Prediction router: uploads image
- Prediction router → Detection service: requests prediction
- Detection service → YOLO face detector: detects face
- Detection service → Two-stream model: runs classifier
- Detection service → Prediction router: returns verdict
- Prediction router → Localization service: requests mask
- Localization service → Grad-CAM: finds hotspot
- Localization service → SAM segmentation: segments hotspot
- Localization service → Prediction router: returns mask
- Prediction router → Prediction response: formats response
- API client → Placeholder endpoint: posts image