This is an image-based deepfake detector that classifies if images are Real or Deepfake using a two-branch fusion model: a DoRA-fine-tuned CLIP + ViT-L/14 backbone for spatial features combined with a small CNN over the 2D FFT magnitude spectrum for frequency artifacts. Trained with a SupCon + cross-entropy loss across three datasets
0
stars
31
commits
Python
primary language
Aug 18, 2026
updated
https://huggingface.co/spaces/knmrfr/deepfake-detector-demo?logs=build
Note: This will only work for GAN-based and Stable-Diffusion deepfakes so it won't work on things that are fully AI generated
An image-based deepfake detection web app that classifies face images as Real or Deepfake using a two-branch fusion model: a DoRA-fine-tuned CLIP ViT-L/14 backbone (spatial features) combined with a lightweight CNN over the 2D FFT magnitude spectrum (frequency artifacts). A Flask backend serves predictions; a React/Vite frontend provides the UI.
pip install -r requirements.txt
# Configure HuggingFace auth (required to pull CLIP weights)
cp .env.example .env
# then edit .env and set HF_TOKEN=<your-token>
# One-time: prep the OpenRL DeepFakeFace diffusion dataset
python scripts/download_deepfakeface.py
python train.py # fine-tune the model (also pulls Kaggle datasets via kagglehub)
python evaluate.py # evaluate on held-out test sets
python app.py # start the Flask API at http://127.0.0.1:5001
# Frontend (optional)
cd frontend
npm install
npm run dev
openai/clip-vit-large-patch14q_proj, k_proj, v_proj, out_proj), with LoRA dropout 0.1.q/k/v/out_proj layers are trained; the 300M+ backbone weights stay frozen. Massive VRAM savings, and DoRA typically closes the gap to full fine-tuning that plain LoRA leaves on the table.ACCUM_STEPS) — lets a small per-step batch simulate a much larger effective batch without the memory cost.num_workers=4 and pin_memory=True enabled automatically on CUDA only (MPS / CPU get num_workers=0 to avoid Python multiprocessing stalls on macOS).head_weights.pt and the DoRA adapter are overwritten only when validation AUC improves.dora_epoch{N}_auc{X}) — any prior epoch can be rolled back to without re-training.train_state.pt — stores optimizer, scheduler, epoch, best-AUC, and patience counter in sync with the best weights, so python train.py can safely resume from interruption.merge_and_unload) — the final inference checkpoint is a plain CLIPVisionModel with the adapter folded in, so app.py does not need PEFT at serve time.torch.no_grad() everywhere in /predict — no autograd graph is built for inference.snapshot_download for the DeepFakeFace dataset). https://github.com/huggingface/huggingface_hubImageFolder, dataset utilities). https://github.com/pytorch/visionroc_auc_score, roc_curve, classification_report, confusion_matrix). Pedregosa, F. et al. Scikit-learn: Machine Learning in Python. JMLR 12, 2011. https://scikit-learn.orgThis repository is for research and educational use. Please respect the upstream licenses of the datasets and pretrained weights:
31 commits
Python
64.9%
TypeScript
27.0%
Jupyter Notebook
5.7%
CSS
1.0%
This is an image-based deepfake detector that classifies if images are Real or Deepfake using a two-branch fusion model: a DoRA-fine-tuned CLIP + ViT-L/14 backbone for spatial features combined with a small CNN over the 2D FFT magnitude spectrum for frequency artifacts. Trained with a SupCon + cross-entropy loss across three datasets
0
stars
31
commits
Python
primary language
Aug 18, 2026
updated
https://huggingface.co/spaces/knmrfr/deepfake-detector-demo?logs=build
Note: This will only work for GAN-based and Stable-Diffusion deepfakes so it won't work on things that are fully AI generated
An image-based deepfake detection web app that classifies face images as Real or Deepfake using a two-branch fusion model: a DoRA-fine-tuned CLIP ViT-L/14 backbone (spatial features) combined with a lightweight CNN over the 2D FFT magnitude spectrum (frequency artifacts). A Flask backend serves predictions; a React/Vite frontend provides the UI.
pip install -r requirements.txt
# Configure HuggingFace auth (required to pull CLIP weights)
cp .env.example .env
# then edit .env and set HF_TOKEN=<your-token>
# One-time: prep the OpenRL DeepFakeFace diffusion dataset
python scripts/download_deepfakeface.py
python train.py # fine-tune the model (also pulls Kaggle datasets via kagglehub)
python evaluate.py # evaluate on held-out test sets
python app.py # start the Flask API at http://127.0.0.1:5001
# Frontend (optional)
cd frontend
npm install
npm run dev
openai/clip-vit-large-patch14q_proj, k_proj, v_proj, out_proj), with LoRA dropout 0.1.q/k/v/out_proj layers are trained; the 300M+ backbone weights stay frozen. Massive VRAM savings, and DoRA typically closes the gap to full fine-tuning that plain LoRA leaves on the table.ACCUM_STEPS) — lets a small per-step batch simulate a much larger effective batch without the memory cost.num_workers=4 and pin_memory=True enabled automatically on CUDA only (MPS / CPU get num_workers=0 to avoid Python multiprocessing stalls on macOS).head_weights.pt and the DoRA adapter are overwritten only when validation AUC improves.dora_epoch{N}_auc{X}) — any prior epoch can be rolled back to without re-training.train_state.pt — stores optimizer, scheduler, epoch, best-AUC, and patience counter in sync with the best weights, so python train.py can safely resume from interruption.merge_and_unload) — the final inference checkpoint is a plain CLIPVisionModel with the adapter folded in, so app.py does not need PEFT at serve time.torch.no_grad() everywhere in /predict — no autograd graph is built for inference.snapshot_download for the DeepFakeFace dataset). https://github.com/huggingface/huggingface_hubImageFolder, dataset utilities). https://github.com/pytorch/visionroc_auc_score, roc_curve, classification_report, confusion_matrix). Pedregosa, F. et al. Scikit-learn: Machine Learning in Python. JMLR 12, 2011. https://scikit-learn.orgThis repository is for research and educational use. Please respect the upstream licenses of the datasets and pretrained weights:
31 commits
Python
64.9%
TypeScript
27.0%
Jupyter Notebook
5.7%
CSS
1.0%