Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- prithivMLmods/Deepfake-vs-Real
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
pipeline_tag: image-classification
|
8 |
+
library_name: transformers
|
9 |
+
tags:
|
10 |
+
- Deepfake
|
11 |
+
base_model:
|
12 |
+
- prithivMLmods/Deepfake-Detection-Exp-02-22
|
13 |
+
---
|
14 |
+
# **Deepfake-Detection-Exp-02-22-ONNX**
|
15 |
+
|
16 |
+
Deepfake-Detection-Exp-02-22 is a minimalist, high-quality dataset trained on a ViT-based model for image classification, distinguishing between deepfake and real images. The model is based on Google's **`google/vit-base-patch32-224-in21k`**.
|
17 |
+
|
18 |
+
```bitex
|
19 |
+
Mapping of IDs to Labels: {0: 'Deepfake', 1: 'Real'}
|
20 |
+
|
21 |
+
Mapping of Labels to IDs: {'Deepfake': 0, 'Real': 1}
|
22 |
+
```
|
23 |
+
|
24 |
+
```python
|
25 |
+
Classification report:
|
26 |
+
|
27 |
+
precision recall f1-score support
|
28 |
+
|
29 |
+
Deepfake 0.9833 0.9187 0.9499 1600
|
30 |
+
Real 0.9238 0.9844 0.9531 1600
|
31 |
+
|
32 |
+
accuracy 0.9516 3200
|
33 |
+
macro avg 0.9535 0.9516 0.9515 3200
|
34 |
+
weighted avg 0.9535 0.9516 0.9515 3200
|
35 |
+
```
|
36 |
+
|
37 |
+
|
38 |
+

|
39 |
+
|
40 |
+
# **Inference with Hugging Face Pipeline**
|
41 |
+
```python
|
42 |
+
from transformers import pipeline
|
43 |
+
|
44 |
+
# Load the model
|
45 |
+
pipe = pipeline('image-classification', model="prithivMLmods/Deepfake-Detection-Exp-02-22", device=0)
|
46 |
+
|
47 |
+
# Predict on an image
|
48 |
+
result = pipe("path_to_image.jpg")
|
49 |
+
print(result)
|
50 |
+
```
|
51 |
+
|
52 |
+
# **Inference with PyTorch**
|
53 |
+
```python
|
54 |
+
from transformers import ViTForImageClassification, ViTImageProcessor
|
55 |
+
from PIL import Image
|
56 |
+
import torch
|
57 |
+
|
58 |
+
# Load the model and processor
|
59 |
+
model = ViTForImageClassification.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-22")
|
60 |
+
processor = ViTImageProcessor.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-22")
|
61 |
+
|
62 |
+
# Load and preprocess the image
|
63 |
+
image = Image.open("path_to_image.jpg").convert("RGB")
|
64 |
+
inputs = processor(images=image, return_tensors="pt")
|
65 |
+
|
66 |
+
# Perform inference
|
67 |
+
with torch.no_grad():
|
68 |
+
outputs = model(**inputs)
|
69 |
+
logits = outputs.logits
|
70 |
+
predicted_class = torch.argmax(logits, dim=1).item()
|
71 |
+
|
72 |
+
# Map class index to label
|
73 |
+
label = model.config.id2label[predicted_class]
|
74 |
+
print(f"Predicted Label: {label}")
|
75 |
+
```
|
76 |
+
|
77 |
+
# **Limitations**
|
78 |
+
1. **Generalization Issues** β The model may not perform well on deepfake images generated by unseen or novel deepfake techniques.
|
79 |
+
2. **Dataset Bias** β The training data might not cover all variations of real and fake images, leading to biased predictions.
|
80 |
+
3. **Resolution Constraints** β Since the model is based on `vit-base-patch32-224-in21k`, it is optimized for 224x224 image resolution, which may limit its effectiveness on high-resolution images.
|
81 |
+
4. **Adversarial Vulnerabilities** β The model may be susceptible to adversarial attacks designed to fool vision transformers.
|
82 |
+
5. **False Positives & False Negatives** β The model may occasionally misclassify real images as deepfake and vice versa, requiring human validation in critical applications.
|
83 |
+
|
84 |
+
# **Intended Use**
|
85 |
+
1. **Deepfake Detection** β Designed for identifying deepfake images in media, social platforms, and forensic analysis.
|
86 |
+
2. **Research & Development** β Useful for researchers studying deepfake detection and improving ViT-based classification models.
|
87 |
+
3. **Content Moderation** β Can be integrated into platforms to detect and flag manipulated images.
|
88 |
+
4. **Security & Forensics** β Assists in cybersecurity applications where verifying the authenticity of images is crucial.
|
89 |
+
5. **Educational Purposes** β Can be used in training AI practitioners and students in the field of computer vision and deepfake detection.
|