Update README.md
Browse files
README.md
CHANGED
|
@@ -54,47 +54,8 @@ The model is designed to classify single images as either **REAL** or **FAKE**.
|
|
| 54 |
- **Video Analysis:** While it can analyze individual frames, it does not currently leverage temporal coherence in videos (frame-by-frame analysis only).
|
| 55 |
- **Audio Deepfakes:** This model is strictly for visual content.
|
| 56 |
- **Legal Proof:** The model provides a probabilistic assessment and should not be the sole basis for legal judgments.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
```python
|
| 61 |
-
import torch
|
| 62 |
-
import torch.nn as nn
|
| 63 |
-
from torchvision import models
|
| 64 |
-
from safetensors.torch import load_file
|
| 65 |
-
import cv2
|
| 66 |
-
|
| 67 |
-
# Define Model Architecture
|
| 68 |
-
class DeepfakeDetector(nn.Module):
|
| 69 |
-
def __init__(self, pretrained=False):
|
| 70 |
-
super(DeepfakeDetector, self).__init__()
|
| 71 |
-
self.efficientnet = models.efficientnet_v2_s(weights='DEFAULT' if pretrained else None)
|
| 72 |
-
self.swin = models.swin_v2_t(weights='DEFAULT' if pretrained else None)
|
| 73 |
-
|
| 74 |
-
self.efficientnet.classifier = nn.Identity()
|
| 75 |
-
self.swin.head = nn.Identity()
|
| 76 |
-
|
| 77 |
-
self.classifier = nn.Sequential(
|
| 78 |
-
nn.Linear(1280 + 768, 512),
|
| 79 |
-
nn.BatchNorm1d(512),
|
| 80 |
-
nn.ReLU(),
|
| 81 |
-
nn.Dropout(0.4),
|
| 82 |
-
nn.Linear(512, 1)
|
| 83 |
-
)
|
| 84 |
-
|
| 85 |
-
def forward(self, x):
|
| 86 |
-
f1 = self.efficientnet(x)
|
| 87 |
-
f2 = self.swin(x)
|
| 88 |
-
combined = torch.cat((f1, f2), dim=1)
|
| 89 |
-
return self.classifier(combined)
|
| 90 |
-
|
| 91 |
-
# Load Model
|
| 92 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 93 |
-
model = DeepfakeDetector(pretrained=False).to(device)
|
| 94 |
-
state_dict = load_file("best_model.safetensors")
|
| 95 |
-
model.load_state_dict(state_dict)
|
| 96 |
-
model.eval()
|
| 97 |
-
```
|
| 98 |
|
| 99 |
## Training Details
|
| 100 |
|
|
|
|
| 54 |
- **Video Analysis:** While it can analyze individual frames, it does not currently leverage temporal coherence in videos (frame-by-frame analysis only).
|
| 55 |
- **Audio Deepfakes:** This model is strictly for visual content.
|
| 56 |
- **Legal Proof:** The model provides a probabilistic assessment and should not be the sole basis for legal judgments.
|
| 57 |
+
|
| 58 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
## Training Details
|
| 61 |
|