prithivMLmods commited on
Commit
7915398
Β·
verified Β·
1 Parent(s): 9c3b0e6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -0
README.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - prithivMLmods/Deepfake-vs-Real
5
+ language:
6
+ - en
7
+ base_model:
8
+ - prithivMLmods/Deepfake-Detection-Exp-02-21
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - Deepfake
13
+ ---
14
+ # **Deepfake-Detection-Exp-02-21-ONNX**
15
+
16
+ Deepfake-Detection-Exp-02-21 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-patch16-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
+ ```py
24
+ Classification report:
25
+
26
+ precision recall f1-score support
27
+
28
+ Deepfake 0.9962 0.9806 0.9883 1600
29
+ Real 0.9809 0.9962 0.9885 1600
30
+
31
+ accuracy 0.9884 3200
32
+ macro avg 0.9886 0.9884 0.9884 3200
33
+ weighted avg 0.9886 0.9884 0.9884 3200
34
+ ```
35
+
36
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/6720824b15b6282a2464fc58/0ISoyjxLs-zpqt9Gv4YRo.png)
37
+
38
+ # **Inference with Hugging Face Pipeline**
39
+ ```python
40
+ from transformers import pipeline
41
+
42
+ # Load the model
43
+ pipe = pipeline('image-classification', model="prithivMLmods/Deepfake-Detection-Exp-02-21", device=0)
44
+
45
+ # Predict on an image
46
+ result = pipe("path_to_image.jpg")
47
+ print(result)
48
+ ```
49
+
50
+ # **Inference with PyTorch**
51
+ ```python
52
+ from transformers import ViTForImageClassification, ViTImageProcessor
53
+ from PIL import Image
54
+ import torch
55
+
56
+ # Load the model and processor
57
+ model = ViTForImageClassification.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-21")
58
+ processor = ViTImageProcessor.from_pretrained("prithivMLmods/Deepfake-Detection-Exp-02-21")
59
+
60
+ # Load and preprocess the image
61
+ image = Image.open("path_to_image.jpg").convert("RGB")
62
+ inputs = processor(images=image, return_tensors="pt")
63
+
64
+ # Perform inference
65
+ with torch.no_grad():
66
+ outputs = model(**inputs)
67
+ logits = outputs.logits
68
+ predicted_class = torch.argmax(logits, dim=1).item()
69
+
70
+ # Map class index to label
71
+ label = model.config.id2label[predicted_class]
72
+ print(f"Predicted Label: {label}")
73
+ ```
74
+ # **Limitations**
75
+ 1. **Generalization Issues** – The model may not perform well on deepfake images generated by unseen or novel deepfake techniques.
76
+ 2. **Dataset Bias** – The training data might not cover all variations of real and fake images, leading to biased predictions.
77
+ 3. **Resolution Constraints** – Since the model is based on `vit-base-patch16-224-in21k`, it is optimized for 224x224 image resolution, which may limit its effectiveness on high-resolution images.
78
+ 4. **Adversarial Vulnerabilities** – The model may be susceptible to adversarial attacks designed to fool vision transformers.
79
+ 5. **False Positives & False Negatives** – The model may occasionally misclassify real images as deepfake and vice versa, requiring human validation in critical applications.
80
+
81
+ # **Intended Use**
82
+ 1. **Deepfake Detection** – Designed for identifying deepfake images in media, social platforms, and forensic analysis.
83
+ 2. **Research & Development** – Useful for researchers studying deepfake detection and improving ViT-based classification models.
84
+ 3. **Content Moderation** – Can be integrated into platforms to detect and flag manipulated images.
85
+ 4. **Security & Forensics** – Assists in cybersecurity applications where verifying the authenticity of images is crucial.
86
+ 5. **Educational Purposes** – Can be used in training AI practitioners and students in the field of computer vision and deepfake detection.