prithivMLmods commited on
Commit
0523875
·
verified ·
1 Parent(s): ce57976

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -3
README.md CHANGED
@@ -1,3 +1,95 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - google/siglip2-base-patch16-224
7
+ pipeline_tag: image-classification
8
+ library_name: transformers
9
+ tags:
10
+ - Deepfake
11
+ - Quality
12
+ - Classifier
13
+ - SigLIP2
14
+ ---
15
+ ![14.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/IgM9DtsT7Pn8IfELuXmta.png)
16
+
17
+ # **Deepfake-Quality-Classifier2-SigLIP2**
18
+ > **Deepfake-Quality-Classifier2-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
+
21
+ ```python
22
+ Classification Report:
23
+ precision recall f1-score support
24
+
25
+ Issue In Deepfake 0.8352 0.7800 0.8067 5000
26
+ High Quality Deepfake 0.7951 0.8500 0.8217 5000
27
+
28
+ accuracy 0.8245 10000
29
+ macro avg 0.8152 0.8245 0.8142 10000
30
+ weighted avg 0.8152 0.8245 0.8142 10000
31
+
32
+ ```
33
+
34
+ The model categorizes images into two classes:
35
+ - **Class 0:** "Issue In Deepfake" – indicating that the deepfake image has noticeable flaws or inconsistencies.
36
+ - **Class 1:** "High Quality Deepfake" – indicating that the deepfake image is of high quality and appears more realistic.
37
+
38
+ # **Run with Transformers🤗**
39
+
40
+ ```python
41
+ !pip install -q transformers torch pillow gradio
42
+ ```
43
+
44
+ ```python
45
+ import gradio as gr
46
+ from transformers import AutoImageProcessor
47
+ from transformers import SiglipForImageClassification
48
+ from transformers.image_utils import load_image
49
+ from PIL import Image
50
+ import torch
51
+
52
+ # Load model and processor
53
+ model_name = "prithivMLmods/Deepfake-Quality-Classifier2-SigLIP2"
54
+ model = SiglipForImageClassification.from_pretrained(model_name)
55
+ processor = AutoImageProcessor.from_pretrained(model_name)
56
+
57
+ def deepfake_detection(image):
58
+ """Predicts deepfake probability scores for an image."""
59
+ image = Image.fromarray(image).convert("RGB")
60
+ inputs = processor(images=image, return_tensors="pt")
61
+
62
+ with torch.no_grad():
63
+ outputs = model(**inputs)
64
+ logits = outputs.logits
65
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
66
+
67
+ labels = {"0": "Issue In Deepfake", "1": "High Quality Deepfake"}
68
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
69
+
70
+ return predictions
71
+
72
+ # Create Gradio interface
73
+ iface = gr.Interface(
74
+ fn=deepfake_detection,
75
+ inputs=gr.Image(type="numpy"),
76
+ outputs=gr.Label(label="Prediction Scores"),
77
+ title="Deepfake Quality Detection",
78
+ description="Upload an image to check its deepfake probability scores."
79
+ )
80
+
81
+ # Launch the app
82
+ if __name__ == "__main__":
83
+ iface.launch()
84
+ ```
85
+
86
+ # **Intended Use:**
87
+
88
+ The **Deepfake-Quality-Classifier2-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:
89
+
90
+ - **Deepfake Quality Assessment:** Identifying whether a generated deepfake meets high-quality standards or contains artifacts and inconsistencies.
91
+ - **Content Moderation:** Assisting in filtering low-quality deepfake images in digital media platforms.
92
+ - **Forensic Analysis:** Supporting researchers and analysts in assessing the credibility of synthetic images.
93
+ - **Deepfake Model Benchmarking:** Helping developers compare and improve deepfake generation models.
94
+
95
+