Update README.md
Browse files
README.md
CHANGED
@@ -9,4 +9,69 @@ library_name: transformers
|
|
9 |
tags:
|
10 |
- deepfake
|
11 |
- detection
|
12 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
tags:
|
10 |
- deepfake
|
11 |
- detection
|
12 |
+
---
|
13 |
+
# **Deepfake-Detect-Siglip2**
|
14 |
+
|
15 |
+
**Deepfake-Detect-Siglip2** is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a single-label classification task. It is designed to detect whether an image is real or a deepfake using the SiglipForImageClassification architecture.
|
16 |
+
|
17 |
+
The model categorizes images into two classes:
|
18 |
+
- **Class 0:** "Fake" – The image is detected as a deepfake or manipulated.
|
19 |
+
- **Class 1:** "Real" – The image is classified as authentic and unaltered.
|
20 |
+
|
21 |
+
# **Run with Transformers🤗**
|
22 |
+
|
23 |
+
```python
|
24 |
+
!pip install -q transformers torch pillow gradio
|
25 |
+
```
|
26 |
+
|
27 |
+
```python
|
28 |
+
import gradio as gr
|
29 |
+
from transformers import AutoImageProcessor
|
30 |
+
from transformers import SiglipForImageClassification
|
31 |
+
from transformers.image_utils import load_image
|
32 |
+
from PIL import Image
|
33 |
+
import torch
|
34 |
+
|
35 |
+
# Load model and processor
|
36 |
+
model_name = "prithivMLmods/Deepfake-Detect-Siglip2"
|
37 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
38 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
39 |
+
|
40 |
+
def deepfake_detection(image):
|
41 |
+
"""Classifies an image as Fake or Real."""
|
42 |
+
image = Image.fromarray(image).convert("RGB")
|
43 |
+
inputs = processor(images=image, return_tensors="pt")
|
44 |
+
|
45 |
+
with torch.no_grad():
|
46 |
+
outputs = model(**inputs)
|
47 |
+
logits = outputs.logits
|
48 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
49 |
+
|
50 |
+
labels = model.config.id2label
|
51 |
+
predictions = {labels[i]: round(probs[i], 3) for i in range(len(probs))}
|
52 |
+
|
53 |
+
return predictions
|
54 |
+
|
55 |
+
# Create Gradio interface
|
56 |
+
iface = gr.Interface(
|
57 |
+
fn=deepfake_detection,
|
58 |
+
inputs=gr.Image(type="numpy"),
|
59 |
+
outputs=gr.Label(label="Detection Result"),
|
60 |
+
title="Deepfake Detection Model",
|
61 |
+
description="Upload an image to determine if it is Fake or Real."
|
62 |
+
)
|
63 |
+
|
64 |
+
# Launch the app
|
65 |
+
if __name__ == "__main__":
|
66 |
+
iface.launch()
|
67 |
+
```
|
68 |
+
|
69 |
+
# **Intended Use:**
|
70 |
+
|
71 |
+
The **Deepfake-Detect-Siglip2** model is designed to distinguish between **real and fake (deepfake) images**. It is useful for identifying AI-generated or manipulated content.
|
72 |
+
|
73 |
+
### Potential Use Cases:
|
74 |
+
- **Deepfake Detection:** Identifying AI-generated fake images.
|
75 |
+
- **Content Verification:** Assisting social media platforms in filtering manipulated content.
|
76 |
+
- **Forensic Analysis:** Supporting cybersecurity and investigative research on fake media.
|
77 |
+
- **Media Authenticity Checks:** Helping journalists and fact-checkers verify image credibility.
|