Views
No views yet

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.
1Classification Report:
2 precision recall f1-score support
3
4 Deepfake 0.9990 0.9972 0.9981 4000
5 Real one 0.9973 0.9990 0.9981 4000
6
7 accuracy 0.9981 8000
8 macro avg 0.9981 0.9981 0.9981 8000
9weighted avg 0.9981 0.9981 0.9981 8000
!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-vs-Real-8000"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def deepfake_classification(image):
14 """Predicts whether an image is a Deepfake or Real."""
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 = {
24 "0": "Deepfake", "1": "Real one"
25 }
26 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
27
28 return predictions
29
30# Create Gradio interface
31iface = gr.Interface(
32 fn=deepfake_classification,
33 inputs=gr.Image(type="numpy"),
34 outputs=gr.Label(label="Prediction Scores"),
35 title="Deepfake vs. Real Image Classification",
36 description="Upload an image to determine if it's a Deepfake or a Real one."
37)
38
39# Launch the app
40if __name__ == "__main__":
41 iface.launch()