prithivMLmods commited on
Commit
ff531bc
·
verified ·
1 Parent(s): 5dbe7fc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -1
README.md CHANGED
@@ -1,6 +1,11 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
4
  ```py
5
  Classification Report:
6
  precision recall f1-score support
@@ -15,4 +20,69 @@ weighted avg 0.9981 0.9981 0.9981 8000
15
 
16
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/MqyYUuGb-gZDsCtusIQOr.png)
17
 
18
- ![Classification Report Analysis - visual selection(1).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/aR6g335It_LH9L81UPzLs.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ # **Deepfake-vs-Real-8000**
5
+
6
+ > **Deepfake-vs-Real-8000** 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 a deepfake or a real one using the **SiglipForImageClassification** architecture.
7
+
8
+
9
  ```py
10
  Classification Report:
11
  precision recall f1-score support
 
20
 
21
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/MqyYUuGb-gZDsCtusIQOr.png)
22
 
23
+ The model categorizes images into two classes:
24
+ - **Class 0:** "Deepfake"
25
+ - **Class 1:** "Real one"
26
+
27
+ ---
28
+
29
+ # **Run with Transformers🤗**
30
+
31
+ ```python
32
+ !pip install -q transformers torch pillow gradio
33
+ ```
34
+
35
+ ```python
36
+ import gradio as gr
37
+ from transformers import AutoImageProcessor
38
+ from transformers import SiglipForImageClassification
39
+ from transformers.image_utils import load_image
40
+ from PIL import Image
41
+ import torch
42
+
43
+ # Load model and processor
44
+ model_name = "prithivMLmods/Deepfake-vs-Real-8000"
45
+ model = SiglipForImageClassification.from_pretrained(model_name)
46
+ processor = AutoImageProcessor.from_pretrained(model_name)
47
+
48
+ def deepfake_classification(image):
49
+ """Predicts whether an image is a Deepfake or Real."""
50
+ image = Image.fromarray(image).convert("RGB")
51
+ inputs = processor(images=image, return_tensors="pt")
52
+
53
+ with torch.no_grad():
54
+ outputs = model(**inputs)
55
+ logits = outputs.logits
56
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
57
+
58
+ labels = {
59
+ "0": "Deepfake", "1": "Real one"
60
+ }
61
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
62
+
63
+ return predictions
64
+
65
+ # Create Gradio interface
66
+ iface = gr.Interface(
67
+ fn=deepfake_classification,
68
+ inputs=gr.Image(type="numpy"),
69
+ outputs=gr.Label(label="Prediction Scores"),
70
+ title="Deepfake vs. Real Image Classification",
71
+ description="Upload an image to determine if it's a Deepfake or a Real one."
72
+ )
73
+
74
+ # Launch the app
75
+ if __name__ == "__main__":
76
+ iface.launch()
77
+ ```
78
+
79
+ ---
80
+
81
+ # **Intended Use:**
82
+
83
+ The **Deepfake-vs-Real-8000** model is designed to detect deepfake images from real ones. Potential use cases include:
84
+
85
+ - **Deepfake Detection:** Assisting cybersecurity experts and forensic teams in detecting synthetic media.
86
+ - **Media Verification:** Helping journalists and fact-checkers verify the authenticity of images.
87
+ - **AI Ethics & Research:** Contributing to studies on AI-generated content detection.
88
+ - **Social Media Moderation:** Enhancing tools to prevent misinformation and digital deception.