Update README.md
Browse files
README.md
CHANGED
|
@@ -13,6 +13,10 @@ tags:
|
|
| 13 |
- SigLIP2
|
| 14 |
---
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
```python
|
| 17 |
Classification Report:
|
| 18 |
precision recall f1-score support
|
|
@@ -23,4 +27,67 @@ High Quality Deepfake 0.8025 0.8500 0.8257 3750
|
|
| 23 |
accuracy 0.8185 7500
|
| 24 |
macro avg 0.8188 0.8185 0.8180 7500
|
| 25 |
weighted avg 0.8188 0.8185 0.8180 7500
|
| 26 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
- SigLIP2
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# **Deepfake-Quality-Classifier-SigLIP2**
|
| 17 |
+
|
| 18 |
+
> **Deepfake-Quality-Classifier-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 assess the quality of deepfake images using the **SiglipForImageClassification** architecture.
|
| 19 |
+
|
| 20 |
```python
|
| 21 |
Classification Report:
|
| 22 |
precision recall f1-score support
|
|
|
|
| 27 |
accuracy 0.8185 7500
|
| 28 |
macro avg 0.8188 0.8185 0.8180 7500
|
| 29 |
weighted avg 0.8188 0.8185 0.8180 7500
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
The model categorizes images into two classes:
|
| 33 |
+
- **Class 0:** "Issue In Deepfake" – indicating that the deepfake image has noticeable flaws or inconsistencies.
|
| 34 |
+
- **Class 1:** "High Quality Deepfake" – indicating that the deepfake image is of high quality and appears more realistic.
|
| 35 |
+
|
| 36 |
+
# **Run with Transformers🤗**
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
!pip install -q transformers torch pillow gradio
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
import gradio as gr
|
| 44 |
+
from transformers import AutoImageProcessor
|
| 45 |
+
from transformers import SiglipForImageClassification
|
| 46 |
+
from transformers.image_utils import load_image
|
| 47 |
+
from PIL import Image
|
| 48 |
+
import torch
|
| 49 |
+
|
| 50 |
+
# Load model and processor
|
| 51 |
+
model_name = "prithivMLmods/Deepfake-Quality-Classifier-SigLIP2"
|
| 52 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 53 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 54 |
+
|
| 55 |
+
def deepfake_detection(image):
|
| 56 |
+
"""Predicts deepfake probability scores for an image."""
|
| 57 |
+
image = Image.fromarray(image).convert("RGB")
|
| 58 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 59 |
+
|
| 60 |
+
with torch.no_grad():
|
| 61 |
+
outputs = model(**inputs)
|
| 62 |
+
logits = outputs.logits
|
| 63 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
| 64 |
+
|
| 65 |
+
labels = {0: "Issue In Deepfake", 1: "High Quality Deepfake"}
|
| 66 |
+
predictions = {labels[i]: round(probs[i], 3) for i in range(len(probs))}
|
| 67 |
+
|
| 68 |
+
return predictions
|
| 69 |
+
|
| 70 |
+
# Create Gradio interface
|
| 71 |
+
iface = gr.Interface(
|
| 72 |
+
fn=deepfake_detection,
|
| 73 |
+
inputs=gr.Image(type="numpy"),
|
| 74 |
+
outputs=gr.Label(label="Prediction Scores"),
|
| 75 |
+
title="Deepfake Quality Detection",
|
| 76 |
+
description="Upload an image to check its deepfake probability scores."
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
# Launch the app
|
| 80 |
+
if __name__ == "__main__":
|
| 81 |
+
iface.launch()
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
# **Intended Use:**
|
| 85 |
+
|
| 86 |
+
The **Deepfake-Quality-Classifier-SigLIP2** model is designed to evaluate the quality of deepfake images. It helps distinguish between high-quality deepfakes and those with noticeable issues. Potential use cases include:
|
| 87 |
+
|
| 88 |
+
- **Deepfake Quality Assessment:** Identifying whether a generated deepfake meets high-quality standards or contains artifacts and inconsistencies.
|
| 89 |
+
- **Content Moderation:** Assisting in filtering low-quality deepfake images in digital media platforms.
|
| 90 |
+
- **Forensic Analysis:** Supporting researchers and analysts in assessing the credibility of synthetic images.
|
| 91 |
+
- **Deepfake Model Benchmarking:** Helping developers compare and improve deepfake generation models.
|
| 92 |
+
|
| 93 |
+
|