Update README.md
Browse files
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/
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
---
|
26 |
|
27 |
## Label Space: 2 Classes
|
28 |
|
29 |
-
The model classifies an image as
|
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
|
51 |
from PIL import Image
|
52 |
import torch
|
53 |
|
54 |
# Load model and processor
|
55 |
-
model_name = "prithivMLmods/deepfake-detector-model"
|
56 |
-
model =
|
57 |
-
processor =
|
58 |
|
59 |
# Updated label mapping
|
60 |
-
|
|
|
|
|
|
|
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 |
-
|
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
|
82 |
title="deepfake-detector-model",
|
83 |
-
description="Upload an image to
|
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** β
|
97 |
-
* **
|
98 |
-
* **
|
99 |
-
* **
|
100 |
-
* **
|
|
|
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 |
+

|
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.
|