Skip to content

amay09x/DeepShield

 
 

Repository files navigation

DeepShield AI — Upgraded System

What changed

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

Folder structure (after dataset prep)

data/
├── train/
│   ├── fake/     ← deepfake frames/images
│   └── real/     ← authentic frames/images
├── val/
│   ├── fake/
│   └── real/
└── test/
    ├── fake/
    └── real/

Step 1 — Prepare datasets

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 100

Or 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

Step 2 — Train

# 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  5

Step 3 — Run the web app

python app.py
# → http://127.0.0.1:5000

Supports image upload (jpg/png/webp/…) and video upload (mp4/avi/mov/…).


Face detection

facenet-pytorch MTCNN is used when installed, falls back to OpenCV Haar Cascade automatically.

pip install facenet-pytorch   # enables MTCNN

Dataset download links

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/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 47.0%
  • Python 41.3%
  • CSS 7.9%
  • JavaScript 3.8%