Update README.md
Browse files
README.md
CHANGED
|
@@ -1,117 +1,141 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
#
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
model.
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
tags:
|
| 6 |
+
- deepfake-detection
|
| 7 |
+
- vision-transformer
|
| 8 |
+
- efficientnet
|
| 9 |
+
- multimodal
|
| 10 |
+
- pytorch
|
| 11 |
+
- computer-vision
|
| 12 |
+
- model
|
| 13 |
+
- image-classification
|
| 14 |
+
datasets:
|
| 15 |
+
- custom
|
| 16 |
+
metrics:
|
| 17 |
+
- accuracy
|
| 18 |
+
- f1
|
| 19 |
+
pipeline_tag: image-classification
|
| 20 |
+
library_name: pytorch
|
| 21 |
+
widget:
|
| 22 |
+
- text: "sample_video.mp4"
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# Deepfake Detection with Improved EfficientViT
|
| 26 |
+
|
| 27 |
+
## Model Architecture
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
|
| 31 |
+
## Inference Pipeline
|
| 32 |
+
|
| 33 |
+

|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
This repository contains a **PyTorch model for deepfake detection** based on an improved **EfficientViT** architecture, trained on video data.
|
| 37 |
+
|
| 38 |
+
The model predicts whether a video is **real (0)** or **fake (1)** using both visual information and temporal cues.
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## π§© Model Description
|
| 43 |
+
|
| 44 |
+
**Architecture:** Improved EfficientViT
|
| 45 |
+
**Backbone:** EfficientNet-B0 for feature extraction
|
| 46 |
+
**Head:** Transformer-based temporal modeling with classification head
|
| 47 |
+
**Input:** Video frames (224Γ224 RGB images)
|
| 48 |
+
**Output:** Binary label (0=Real, 1=Fake) and frame-level probabilities
|
| 49 |
+
|
| 50 |
+
**Key Features:**
|
| 51 |
+
|
| 52 |
+
- Extracts faces from frames using MTCNN
|
| 53 |
+
- Supports inference on raw video files
|
| 54 |
+
- Provides frame-level probabilities for fine-grained analysis
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## π Repository Structure
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
deepfake-efficientvit/
|
| 62 |
+
β
|
| 63 |
+
βββ model.py # ImprovedEfficientViT class
|
| 64 |
+
βββ inference.py # Functions to run inference on videos
|
| 65 |
+
βββ model.pth # Trained weights
|
| 66 |
+
βββ config.json # Optional model metadata
|
| 67 |
+
βββ requirements.txt # Required packages
|
| 68 |
+
βββ README.md
|
| 69 |
+
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## β‘ Installation
|
| 73 |
+
git clone https://huggingface.co/faisalishfaq2005/deepfake-detection-efficientnet-vit
|
| 74 |
+
|
| 75 |
+
cd deepfake-detection-efficientnet-vit
|
| 76 |
+
|
| 77 |
+
pip install -r requirements.txt
|
| 78 |
+
|
| 79 |
+
## π Usage
|
| 80 |
+
# 1.Programmatic Inference
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
|
| 84 |
+
from huggingface_hub import hf_hub_download
|
| 85 |
+
import torch
|
| 86 |
+
from model import ImprovedEfficientViT
|
| 87 |
+
from inference import predict_vedio # your inference function
|
| 88 |
+
|
| 89 |
+
# 1οΈβ£ Download the checkpoint from Hugging Face
|
| 90 |
+
checkpoint_path = hf_hub_download(
|
| 91 |
+
repo_id="faisalishfaq2005/deepfake-detection-efficientnet-vit",
|
| 92 |
+
filename="model.pth"
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
# 2οΈβ£ Load the model
|
| 96 |
+
model = ImprovedEfficientViT()
|
| 97 |
+
model.load_state_dict(torch.load(checkpoint_path, map_location="cpu"))
|
| 98 |
+
model.eval()
|
| 99 |
+
|
| 100 |
+
# 3οΈβ£ Run inference on a video
|
| 101 |
+
video_path = "sample_video.mp4"
|
| 102 |
+
result = predict_vedio(video_path, model)
|
| 103 |
+
print(result)
|
| 104 |
+
# Example Output: {'class': 1}
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
```
|
| 108 |
+
# 2. Manual Download
|
| 109 |
+
|
| 110 |
+
Go to the Hugging Face model page
|
| 111 |
+
|
| 112 |
+
Download:
|
| 113 |
+
|
| 114 |
+
model.pth
|
| 115 |
+
|
| 116 |
+
model.py
|
| 117 |
+
|
| 118 |
+
inference.py
|
| 119 |
+
|
| 120 |
+
Place them in the same folder locally.
|
| 121 |
+
|
| 122 |
+
Install requirements and run predict_video().
|
| 123 |
+
|
| 124 |
+
## π License
|
| 125 |
+
|
| 126 |
+
This model is released under the MIT License.
|
| 127 |
+
You are free to use, modify, and distribute it, with attribution.
|
| 128 |
+
|
| 129 |
+
## π Citation
|
| 130 |
+
|
| 131 |
+
If you use this model in your research, please cite:
|
| 132 |
+
|
| 133 |
+
```bibtex
|
| 134 |
+
@inproceedings{faisalishfaq2025efficientvit,
|
| 135 |
+
title={Deepfake Detection with Efficientnet and ViT},
|
| 136 |
+
author={Faisal Ishfaq},
|
| 137 |
+
year={2025}
|
| 138 |
+
}
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
|