A small, reproducible baseline pipeline for the Kaggle Deepfake Detection Dataset 2026.
The dataset contains 6,557 face-image records with binary REAL / FAKE labels, image URLs, metadata, and split information. This repo downloads the CSV, fetches the referenced images, generates basic EDA outputs, trains a ResNet-18 baseline, and evaluates it on the held-out split.
configs/default.yaml Pipeline settings
scripts/download_kaggle_dataset.py Kaggle CSV download helper
src/deepfake_detection/ Reusable pipeline code
notebooks/ EDA and baseline training notebooks
data/raw/ Downloaded Kaggle files
data/processed/ Downloaded images and enriched metadata
models/ Trained checkpoints
reports/ EDA and evaluation outputs
Large data, generated reports, and model files are ignored by Git.
Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
make installConfigure Kaggle API credentials before downloading. On Windows, place your kaggle.json token at:
C:\Users\<your-user>\.kaggle\kaggle.json
Download and extract the Kaggle dataset:
make downloadGenerate summary JSON and distribution plots:
make edaDownload the image URLs into split/label folders and write enriched metadata:
make imagesTrain the baseline model:
make trainEvaluate the best checkpoint:
make evaluateLaunch the runtime image tester after training:
make appOr run it directly:
python -m streamlit run app.pyDeploy the Streamlit app to Render with the included render.yaml blueprint. See docs/render_deployment.md for the full setup, including how to provide the trained checkpoint through MODEL_CHECKPOINT_PATH.
To run the full workflow:
make pipelineLaunch Jupyter from the repo root:
make notebookAvailable notebooks:
notebooks/01_dataset_eda.ipynb: inspect metadata, label balance, split distributions, missing values, and EDA plots.notebooks/02_baseline_training.ipynb: run image download, ResNet-18 training, and test evaluation from notebook cells.
Edit configs/default.yaml to adjust paths, batch size, image size, epoch count, learning rate, worker count, or Kaggle dataset slug.
For quick smoke tests, set download.limit to a small number such as 100. Leave it blank to process the full dataset.
You can pass a different config or evaluation split into Make:
make train CONFIG=configs/default.yaml
make evaluate SPLIT=valThe training script uses a ResNet-18 binary classifier with ImageNet pretrained weights by default. It expects label_numeric to use the dataset convention:
1:REAL0:FAKE
If the CSV includes a valid split column, the pipeline uses it. If not, it creates a stratified 70% train, 10% validation, and 20% test split.
The most direct task is binary deepfake classification: train a model that takes a face image and predicts REAL (1) or FAKE (0). This is useful for social media moderation, fake-profile detection, media verification, and identity fraud prevention.
The dataset also supports production-style cybersecurity and KYC workflows. Synthetic faces can be used for fake accounts, scam profiles, bot identities, and fraudulent applications; a detector can provide a risk score before an account or identity check is approved.
Because the CSV includes metadata, this project can go beyond raw accuracy. Columns such as gender, age_group, image_quality, detection_difficulty, confidence_score, and fake_method make it possible to measure fairness, robustness, calibration, and generalization across generative methods.
- Generalization across generators: split fake images by
fake_methodto test whether a detector overfits to StyleGAN3 artifacts or transfers to other GAN, diffusion, or future synthetic-face methods. - Robustness to image quality and compression: compare high-quality and medium-quality subsets, then add augmentations for JPEG compression, resizing, blur, and lower-quality uploads.
- Difficulty-aware detection: use
detection_difficultyto analyze easy, medium, and hard samples, benchmark human-level versus model performance, or experiment with curriculum learning and hard example mining. - Fairness and demographic bias: compute per-group accuracy, precision, recall, false positive rate, and F1 across
genderandage_group. - Confidence calibration: use
confidence_scoreand model probabilities to decide when predictions are reliable enough for high-risk workflows. - Semi-supervised learning: use confidence scores as weak supervision or as filters for pseudo-labeling unlabeled real-world images.
- Out-of-distribution detection: treat unknown synthetic generators as open-set or anomaly-detection cases instead of only closed-set
REAL/FAKEclassification. - Explainability and artifact localization: add Grad-CAM, saliency maps, attention heatmaps, or frequency-domain analysis to identify why an image was flagged.
- Transfer learning and domain adaptation: fine-tune pretrained vision or face-recognition models, then test transfer to datasets such as Celeb-DF or FaceForensics++.
- Real-world pipeline integration: use
image_urlto simulate an upload pipeline that downloads, preprocesses, scores, and flags images.
- Beginner: train a small CNN for binary
REAL/FAKEclassification. - Intermediate: fine-tune ResNet, EfficientNet, or ConvNeXt with transfer learning.
- Advanced: compare CNNs against Vision Transformers and add explainability.
- Expert: deploy a FastAPI or Flask service that returns a deepfake probability for uploaded images.
- Research prompt: train a lightweight model, then analyze why it fails on hard samples, especially for the
50+age group.
- Fake account prevention for banking, dating, job, freelance, and social platforms.
- Misinformation detection for synthetic political or media campaigns.
- Trust and safety tooling for marketplaces and consumer platforms.
- Research benchmarking for students, ML engineers, and computer vision researchers.
- Moderate class imbalance: the dataset is about 57% fake and 43% real, so class weights, oversampling, focal loss, or threshold tuning may be useful.
- Overfitting to generator-specific artifacts.
- Dataset and subgroup bias.
- Robustness to compression and lower-quality uploads.
- Real-time inference speed.
- Explainability and confidence calibration.
reports/dataset_summary.json: row counts, columns, and metadata distributionsreports/*_distribution.png: basic EDA plotsdata/processed/metadata_with_paths.csv: source metadata plus local image paths and download statusmodels/best_resnet18.pt: best validation F1 checkpointmodels/training_history.json: epoch-level train and validation metricsreports/test_metrics.json: final evaluation metrics and confusion matrix
After a checkpoint exists at models/best_resnet18.pt, use the Streamlit app to test a real image at runtime:
python -m streamlit run app.pyThe app accepts JPG, PNG, and WebP uploads and returns a REAL or FAKE label with confidence, real probability, and fake probability. You can also score one image from the command line:
python -m deepfake_detection.predict path\to\image.jpg --config configs/default.yamlThis repository is open source under the MIT License. Stars, issues, and pull requests are welcome — they help others discover the project and improve it for the community.
| Topic | Document |
|---|---|
| Full OSS inventory (CI/CD, security, community) | docs/OPEN_SOURCE.md |
| How to contribute | CONTRIBUTING.md |
| Security policy | SECURITY.md |
| Compliance and data governance | docs/COMPLIANCE.md |
| Code of conduct | CODE_OF_CONDUCT.md |
- Star the repo if you find it useful — it helps visibility on GitHub Explore and search.
- Open an issue for bugs, ideas, or questions.
- Submit a pull request with a focused change and a clear description.
- Share the project with students, colleagues, or anyone learning computer vision.
Maintained by Akhil Vydyula as part of the Skills Marathon ML portfolio.
Application code is released under the MIT License.
The Kaggle dataset is listed as CC0: Public Domain. Check the source dataset page for the latest license and usage notes.