prithivMLmods commited on
Commit
e96dcc6
Β·
verified Β·
1 Parent(s): 2804d49

Update README.md

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