Views
No views yet

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.
1Classification Report:
2 precision recall f1-score support
3
4 Issue In Deepfake 0.8350 0.7870 0.8103 3750
5High Quality Deepfake 0.8025 0.8500 0.8257 3750
6
7 accuracy 0.8185 7500
8 macro avg 0.8188 0.8185 0.8180 7500
9 weighted avg 0.8188 0.8185 0.8180 7500!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from transformers.image_utils import load_image
5from PIL import Image
6import torch
7
8# Load model and processor
9model_name = "prithivMLmods/Deepfake-Quality-Classifier-SigLIP2"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def deepfake_detection(image):
14 """Predicts deepfake probability scores for an image."""
15 image = Image.fromarray(image).convert("RGB")
16 inputs = processor(images=image, return_tensors="pt")
17
18 with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
23 labels = {0: "Issue In Deepfake", 1: "High Quality Deepfake"}
24 predictions = {labels[i]: round(probs[i], 3) for i in range(len(probs))}
25
26 return predictions
27
28# Create Gradio interface
29iface = gr.Interface(
30 fn=deepfake_detection,
31 inputs=gr.Image(type="numpy"),
32 outputs=gr.Label(label="Prediction Scores"),
33 title="Deepfake Quality Detection",
34 description="Upload an image to check its deepfake probability scores."
35)
36
37# Launch the app
38if __name__ == "__main__":
39 iface.launch()