Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- deepfake-detection
|
| 6 |
+
- image-classification
|
| 7 |
+
- efficientnetv2
|
| 8 |
+
- pytorch
|
| 9 |
+
- timm
|
| 10 |
+
- huggingface
|
| 11 |
+
- colab
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Deepfake Image Detector
|
| 15 |
+
|
| 16 |
+
Model repository: https://huggingface.co/Arko007/deepfake-image-detector
|
| 17 |
+
|
| 18 |
+
This repository contains a pretrained deepfake image detector intended for research and experimentation. The model was provided as a PyTorch checkpoint and a small Colab-friendly inference script. The original training code and full training logs are not available; the best available evaluation result from the retained artifacts is included below.
|
| 19 |
+
|
| 20 |
+
## Model Summary
|
| 21 |
+
|
| 22 |
+
- Model name: Deepfake Image Detector (EfficientNetV2-S backbone)
|
| 23 |
+
- HF repo id: Arko007/deepfake-image-detector
|
| 24 |
+
- Framework: PyTorch (+ timm)
|
| 25 |
+
- Backbone: tf_efficientnetv2_s (timm)
|
| 26 |
+
- Input size: 380 × 380 RGB
|
| 27 |
+
- Output: single logit for binary fake/real classification (sigmoid applied at inference)
|
| 28 |
+
- Checkpoint file: pytorch_model.bin
|
| 29 |
+
- Config file: config.json
|
| 30 |
+
- License: Apache-2.0
|
| 31 |
+
|
| 32 |
+
## Reported Evaluation (available artifact)
|
| 33 |
+
|
| 34 |
+
- Reported snapshot evaluation: Epoch 6 | AUC: 0.9986
|
| 35 |
+
- Note: This is the only retained per-epoch metric available from the artifacts. Full training logs, dataset split details, and other epoch metrics were not provided and appear to be lost.
|
| 36 |
+
|
| 37 |
+
## Intended Use
|
| 38 |
+
|
| 39 |
+
This model predicts whether an input face/image is likely a manipulated/deepfake (label = FAKE) or a real image (label = REAL). Intended uses include:
|
| 40 |
+
|
| 41 |
+
- Research and benchmarking of image-level deepfake detection.
|
| 42 |
+
- Prototyping content-moderation pipelines (with human-in-the-loop review).
|
| 43 |
+
|
| 44 |
+
Not intended for:
|
| 45 |
+
- High-stakes automated decisions without human review.
|
| 46 |
+
- Medical, legal, or forensic conclusions without expert validation.
|
| 47 |
+
|
| 48 |
+
## Limitations & Known Issues
|
| 49 |
+
|
| 50 |
+
- Training code and dataset provenance are not available in this repository. Use caution when interpreting metrics and generalization claims.
|
| 51 |
+
- The model was trained on a dataset that is not provided here; distributional shift to other datasets, domains, or manipulated types may significantly degrade performance.
|
| 52 |
+
- The only retained evaluation metric is Epoch 6 AUC = 0.9986; other performance numbers, class breakdowns, and training curves are not available.
|
| 53 |
+
- Model assumes centered face or face-like crop. Performance may drop on full-frame images or unseen camera artifacts.
|
| 54 |
+
|
| 55 |
+
## Model Files
|
| 56 |
+
|
| 57 |
+
- pytorch_model.bin — PyTorch checkpoint (state_dict)
|
| 58 |
+
- config.json — Minimal config used by the inference script (contains model_name, epoch, and other metadata)
|
| 59 |
+
- deepfake_detector.py — Colab-ready inference script (example usage)
|
| 60 |
+
- README.md — This model card
|
| 61 |
+
|
| 62 |
+
## Example config.json (expected fields)
|
| 63 |
+
A minimal example of the config.json that pairs with pytorch_model.bin:
|
| 64 |
+
|
| 65 |
+
{
|
| 66 |
+
"model_name": "tf_efficientnetv2_s",
|
| 67 |
+
"image_size": 380,
|
| 68 |
+
"epoch": 6,
|
| 69 |
+
"notes": "Only a single evaluation snapshot remains. Training artifacts incomplete."
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
## Inference (Colab / local)
|
| 73 |
+
|
| 74 |
+
The repository includes a simple Colab-ready script deepfake_detector.py which implements:
|
| 75 |
+
- Download of checkpoint and config from the HF hub
|
| 76 |
+
- Initialization of a timm EfficientNetV2-S backbone with a custom classifier head
|
| 77 |
+
- Image preprocessing via albumentations (Resize → Normalize → ToTensorV2)
|
| 78 |
+
- Sigmoid on the model logit to produce a probability of "fake"
|
| 79 |
+
|
| 80 |
+
High-level steps to run inference:
|
| 81 |
+
|
| 82 |
+
1. Install dependencies (example):
|
| 83 |
+
pip install torch torchvision timm albumentations pillow huggingface-hub matplotlib
|
| 84 |
+
|
| 85 |
+
2. Download the model files from the Hub (the script calls huggingface_hub.hf_hub_download).
|
| 86 |
+
|
| 87 |
+
3. Run the included script in Colab or locally:
|
| 88 |
+
- Upload an image (PNG/JPG)
|
| 89 |
+
- The script resizes to 380×380, normalizes, and runs the model.
|
| 90 |
+
- Output: probability (0..1) of the image being FAKE. Threshold 0.5 by default.
|
| 91 |
+
|
| 92 |
+
Example minimal inference snippet (matches the repository script):
|
| 93 |
+
|
| 94 |
+
```python
|
| 95 |
+
import torch
|
| 96 |
+
import cv2
|
| 97 |
+
from PIL import Image
|
| 98 |
+
from deepfake_detector import DeepfakeDetector, TestConfig, get_inference_transform, load_model, predict_deepfake
|
| 99 |
+
|
| 100 |
+
# load model (downloads checkpoint via hf_hub_download inside)
|
| 101 |
+
model = load_model() # returns a model already set to eval on TestConfig.DEVICE
|
| 102 |
+
transform = get_inference_transform(TestConfig.IMAGE_SIZE)
|
| 103 |
+
|
| 104 |
+
is_fake, prob, confidence = predict_deepfake(model, "example.jpg", transform)
|
| 105 |
+
print(f"Prediction: {'FAKE' if is_fake else 'REAL'}")
|
| 106 |
+
print(f"Probability (fake): {prob:.4f}, Confidence: {confidence:.4f}")
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
## Reproducibility Notes
|
| 110 |
+
|
| 111 |
+
- The repository does not contain the original training script or dataset. The inference script is intended for running the provided checkpoint only.
|
| 112 |
+
- If you require retraining or further experiments, replace the placeholder classifier with the same architecture used in training and retrain using your own dataset, ensuring appropriate splits and class balance.
|
| 113 |
+
|
| 114 |
+
## Responsible Use & Ethics
|
| 115 |
+
|
| 116 |
+
Deepfake detection models have social impact. Use responsibly:
|
| 117 |
+
- Disclose limitations to stakeholders.
|
| 118 |
+
- Avoid over-reliance on model outputs for high-stakes decisions.
|
| 119 |
+
- Combine with manual verification and multi-modal signals when possible.
|
| 120 |
+
|
| 121 |
+
## Contact / Attribution
|
| 122 |
+
|
| 123 |
+
Model owner: Arko007
|
| 124 |
+
HF model page: https://huggingface.co/Arko007/deepfake-image-detector
|
| 125 |
+
|
| 126 |
+
If you have additional training artifacts (logs, dataset details, training script), please add them to the repository to improve reproducibility and transparency.
|