prithivMLmods commited on
Commit
b5217bb
·
verified ·
1 Parent(s): 98931ed

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -2
README.md CHANGED
@@ -4,8 +4,54 @@ language:
4
  - en
5
  base_model:
6
  - google/siglip2-base-patch16-224
7
- pipeline_tag: image-text-to-text
8
  library_name: transformers
9
  tags:
10
  - deepfake
11
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ---
12
+
13
+ ```python
14
+ !pip install -q transformers torch pillow gradio
15
+ ```
16
+
17
+ ```python
18
+ import gradio as gr
19
+ from transformers import AutoImageProcessor
20
+ from transformers import SiglipForImageClassification
21
+ from transformers.image_utils import load_image
22
+ from PIL import Image
23
+ import torch
24
+
25
+ # Load model and processor
26
+ model_name = "prithivMLmods/Deepfake-Quality-Assess-Siglip2"
27
+ model = SiglipForImageClassification.from_pretrained(model_name)
28
+ processor = AutoImageProcessor.from_pretrained(model_name)
29
+
30
+ def deepfake_detection(image):
31
+ """Predicts deepfake probability scores for an image."""
32
+ image = Image.fromarray(image).convert("RGB")
33
+ inputs = processor(images=image, return_tensors="pt")
34
+
35
+ with torch.no_grad():
36
+ outputs = model(**inputs)
37
+ logits = outputs.logits
38
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
39
+
40
+ labels = model.config.id2label
41
+ predictions = {labels[i]: round(probs[i], 3) for i in range(len(probs))}
42
+
43
+ return predictions
44
+
45
+ # Create Gradio interface
46
+ iface = gr.Interface(
47
+ fn=deepfake_detection,
48
+ inputs=gr.Image(type="numpy"),
49
+ outputs=gr.Label(label="Prediction Scores"),
50
+ title="Deepfake Quality Detection",
51
+ description="Upload an image to check its deepfake probability scores."
52
+ )
53
+
54
+ # Launch the app
55
+ if __name__ == "__main__":
56
+ iface.launch()
57
+ ```