| File | Changes |
|---|---|
train.py |
Auto-detects flat vs split structure, class-balanced sampler, stronger augmentation, early stopping, LR logging |
utils.py |
MTCNN → Haar fallback face detector, blur/dup filtering, extract_video_frames(), prepare_unified_dataset() |
app.py |
500 MB upload limit, face detect on by default for video, /api/model-info route |
prepare_dataset.py |
New — multi-dataset pipeline (FF-C23, DFDC, Celeb-DF, FFHQ, VGGFace2) |
requirements.txt |
Added facenet-pytorch |
data/
├── train/
│ ├── fake/ ← deepfake frames/images
│ └── real/ ← authentic frames/images
├── val/
│ ├── fake/
│ └── real/
└── test/
├── fake/
└── real/
python prepare_dataset.py \
--ffc23 /datasets/FaceForensics++ \
--dfdc /datasets/DFDC \
--celebdf /datasets/Celeb-DF \
--ffhq /datasets/FFHQ/images1024x1024 \
--output ./data \
--sample-rate 15 \
--max-frames 100Or use a config file:
{
"sources": [
{"path": "/datasets/FF/manipulated_sequences/Deepfakes", "label": "fake", "type": "video", "name": "ffc23_df"},
{"path": "/datasets/FF/original_sequences", "label": "real", "type": "video", "name": "ffc23_real"},
{"path": "/datasets/FFHQ/images", "label": "real", "type": "image", "name": "ffhq"}
]
}python prepare_dataset.py --config dataset_config.json --output ./data# Standard
python train.py --data-dir ./data --epochs 20
# With early stopping and frozen backbone (fast fine-tune)
python train.py --data-dir ./data --freeze-backbone --early-stop 5
# All options
python train.py \
--data-dir ./data \
--output model.pth \
--epochs 20 \
--batch-size 32 \
--lr 0.0001 \
--early-stop 5python app.py
# → http://127.0.0.1:5000Supports image upload (jpg/png/webp/…) and video upload (mp4/avi/mov/…).
facenet-pytorch MTCNN is used when installed, falls back to OpenCV Haar Cascade automatically.
pip install facenet-pytorch # enables MTCNN| Dataset | URL |
|---|---|
| FaceForensics++ | https://github.com/ondyari/FaceForensics |
| DFDC | https://ai.meta.com/datasets/dfdc/ |
| Celeb-DF | https://github.com/yuezunli/celeb-deepfakeforensics |
| FFHQ | https://github.com/NVlabs/ffhq-dataset |
| VGGFace2 | https://www.robots.ox.ac.uk/~vgg/data/vgg_face2/ |