File size: 4,328 Bytes
5bb82c7 28d680c 5bb82c7 28d680c 5bb82c7 28d680c 58dc4d4 14d2865 5bb82c7 28d680c 5bb82c7 14d2865 b2f966b 5bb82c7 28d680c b2f966b 28d680c |
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 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 118 119 120 121 122 123 124 125 126 127 128 |
---
tags:
- deepfake-detection
- computer-vision
- image-classification
- pytorch
- efficientnet
- swin-transformer
- security
library_name: pytorch
license: mit
metrics:
- accuracy
- f1
pipeline_tag: image-classification
inference: false
widgets:
- text: "Test the DeepGuard Model Live"
src: "https://harshasnade-deepfake-detection-system-v1.hf.space"
---
# DeepGuard - Deepfake Detection System
[](https://deepfakescan.vercel.app/)
[](https://github.com/Harshvardhan-Asnade/Deepfake-Model)
## Model Details
### Model Description
DeepGuard is a robust Deepfake Detection System designed to identify AI-generated images with high precision. It employs an ensemble architecture combining **EfficientNetV2-S** and **Swin Transformer V2-T** with a custom Convolutional Neural Network (CNN) head. This hybrid approach leverages both local feature extraction (CNN) and global context understanding (Transformers) to spot manipulation artifacts often invisible to the human eye.
- **Developed by:** Harshvardhan Asnade
- **Model type:** Ensemble (EfficientNetV2 + SwinV2 + Custom CNN)
- **Language(s):** Python, PyTorch
- **License:** MIT
- **Finetuned from model:** Torchvision pre-trained weights (ImageNet)
### Model Sources
- **Repository:** https://github.com/Harshvardhan-Asnade/Deepfake-Model
- **Demo:** https://deepfakescan.vercel.app/ (Live Web App)
## Uses
### Direct Use
The model is designed to classify single images as either **REAL** or **FAKE**. It outputs a probability score (0.0 - 1.0) and a confidence metric. It is suitable for:
- Content moderation
- Social media verification
- Digital forensics (preliminary analysis)
### Out-of-Scope Use
- **Video Analysis:** While it can analyze individual frames, it does not currently leverage temporal coherence in videos (frame-by-frame analysis only).
- **Audio Deepfakes:** This model is strictly for visual content.
- **Legal Proof:** The model provides a probabilistic assessment and should not be the sole basis for legal judgments.
## How to Get Started with the Model
```python
import torch
import torch.nn as nn
from torchvision import models
from safetensors.torch import load_file
import cv2
# Define Model Architecture
class DeepfakeDetector(nn.Module):
def __init__(self, pretrained=False):
super(DeepfakeDetector, self).__init__()
self.efficientnet = models.efficientnet_v2_s(weights='DEFAULT' if pretrained else None)
self.swin = models.swin_v2_t(weights='DEFAULT' if pretrained else None)
self.efficientnet.classifier = nn.Identity()
self.swin.head = nn.Identity()
self.classifier = nn.Sequential(
nn.Linear(1280 + 768, 512),
nn.BatchNorm1d(512),
nn.ReLU(),
nn.Dropout(0.4),
nn.Linear(512, 1)
)
def forward(self, x):
f1 = self.efficientnet(x)
f2 = self.swin(x)
combined = torch.cat((f1, f2), dim=1)
return self.classifier(combined)
# Load Model
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = DeepfakeDetector(pretrained=False).to(device)
state_dict = load_file("best_model.safetensors")
model.load_state_dict(state_dict)
model.eval()
```
## Training Details
### Training Data
The model was trained on a diverse dataset comprising:
- **Real Images:** FFHQ, CelebA-HQ
- **Deepfake Images:** Generated using StyleGAN2, Diffusion Models, and FaceSwap techniques.
- **Data Augmentation:** extensive augmentation (compression, noise, blur) was applied to robustify the model against social media re-compression artifacts.
## Evaluation
### Results
The model achieves high accuracy on standard benchmarks:
- **Test Accuracy:** ~92-95% (on unseen test split)
- **Generalization:** Shows strong resilience to JPEG compression compared to standard CNNs.
## Citation
```bibtex
@misc{deepguard2024,
author = {Asnade, Harshvardhan},
title = {DeepGuard: Ensemble Deepfake Detection System},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Harshasnade/Deepfake_Detection_System_V1}}
}
```
|