prithivMLmods commited on
Commit
1b84216
Β·
verified Β·
1 Parent(s): e135329

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -15
README.md CHANGED
@@ -19,14 +19,27 @@ language:
19
 
20
  # deepfake-detector-model
21
 
22
- > deepfake-detector-model is a vision-language model fine-tuned from `google/vit-base-patch16-224-in21k` for binary image classification. It is trained to detect whether an image is fake or real using the *OpenDeepfake-Preview* dataset. The model uses the `ViTForImageClassification` architecture.
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ---
26
 
27
  ## Label Space: 2 Classes
28
 
29
- The model classifies an image as either:
30
 
31
  ```
32
  Class 0: fake
@@ -47,17 +60,20 @@ pip install -q transformers torch pillow gradio hf_xet
47
 
48
  ```python
49
  import gradio as gr
50
- from transformers import ViTImageProcessor, ViTForImageClassification
51
  from PIL import Image
52
  import torch
53
 
54
  # Load model and processor
55
- model_name = "prithivMLmods/deepfake-detector-model"
56
- model = ViTForImageClassification.from_pretrained(model_name)
57
- processor = ViTImageProcessor.from_pretrained(model_name)
58
 
59
  # Updated label mapping
60
- labels_list = ['fake', 'real']
 
 
 
61
 
62
  def classify_image(image):
63
  image = Image.fromarray(image).convert("RGB")
@@ -69,7 +85,7 @@ def classify_image(image):
69
  probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
70
 
71
  prediction = {
72
- labels_list[i]: round(probs[i], 3) for i in range(len(probs))
73
  }
74
 
75
  return prediction
@@ -78,9 +94,9 @@ def classify_image(image):
78
  iface = gr.Interface(
79
  fn=classify_image,
80
  inputs=gr.Image(type="numpy"),
81
- outputs=gr.Label(num_top_classes=2, label="Deepfake Detection"),
82
  title="deepfake-detector-model",
83
- description="Upload an image to detect whether it is AI-generated (fake) or a real photograph (real), using the OpenDeepfake-Preview dataset."
84
  )
85
 
86
  if __name__ == "__main__":
@@ -93,8 +109,8 @@ if __name__ == "__main__":
93
 
94
  `deepfake-detector-model` is designed for:
95
 
96
- * **Deepfake Detection** – Identify AI-generated or manipulated images.
97
- * **Content Moderation** – Flag synthetic or fake visual content.
98
- * **Dataset Curation** – Remove synthetic samples from mixed datasets.
99
- * **Visual Authenticity Verification** – Check the integrity of visual media.
100
- * **Digital Forensics** – Support image source verification and traceability.
 
19
 
20
  # deepfake-detector-model
21
 
22
+ > `deepfake-detector-model` is a vision-language encoder model fine-tuned from [`siglip2-base-patch16-512`](https://huggingface.co/google/siglip-base-patch16-512) for binary deepfake image classification. It is trained to detect whether an image is real or generated using synthetic media techniques. The model uses the `SiglipForImageClassification` architecture.
23
 
24
+ ```py
25
+ Classification Report:
26
+ precision recall f1-score support
27
+
28
+ fake 0.9916 0.9971 0.9944 10000
29
+ real 0.9971 0.9916 0.9943 9999
30
+
31
+ accuracy 0.9943 19999
32
+ macro avg 0.9944 0.9943 0.9943 19999
33
+ weighted avg 0.9944 0.9943 0.9943 19999
34
+ ```
35
+
36
+ ![download (1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/-vgymp8TqWhaLiIYH0vDk.png)
37
 
38
  ---
39
 
40
  ## Label Space: 2 Classes
41
 
42
+ The model classifies an image as one of the following:
43
 
44
  ```
45
  Class 0: fake
 
60
 
61
  ```python
62
  import gradio as gr
63
+ from transformers import AutoImageProcessor, SiglipForImageClassification
64
  from PIL import Image
65
  import torch
66
 
67
  # Load model and processor
68
+ model_name = "prithivMLmods/deepfake-detector-model" # Updated model name
69
+ model = SiglipForImageClassification.from_pretrained(model_name)
70
+ processor = AutoImageProcessor.from_pretrained(model_name)
71
 
72
  # Updated label mapping
73
+ id2label = {
74
+ "0": "fake",
75
+ "1": "real"
76
+ }
77
 
78
  def classify_image(image):
79
  image = Image.fromarray(image).convert("RGB")
 
85
  probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
86
 
87
  prediction = {
88
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
89
  }
90
 
91
  return prediction
 
94
  iface = gr.Interface(
95
  fn=classify_image,
96
  inputs=gr.Image(type="numpy"),
97
+ outputs=gr.Label(num_top_classes=2, label="Deepfake Classification"),
98
  title="deepfake-detector-model",
99
+ description="Upload an image to classify whether it is real or fake using a deepfake detection model."
100
  )
101
 
102
  if __name__ == "__main__":
 
109
 
110
  `deepfake-detector-model` is designed for:
111
 
112
+ * **Deepfake Detection** – Accurately identify fake images generated by AI.
113
+ * **Media Authentication** – Verify the authenticity of digital visual content.
114
+ * **Content Moderation** – Assist in filtering synthetic media in online platforms.
115
+ * **Forensic Analysis** – Support digital forensics by detecting manipulated visual data.
116
+ * **Security Applications** – Integrate into surveillance systems for authenticity verification.