Views
No views yet

deepfake-detector-model-v1is a vision-language encoder model fine-tuned from google/siglip-base-patch16-512 for binary deepfake image classification. It is trained to detect whether an image is real or generated using synthetic media techniques. The model uses theSiglipForImageClassificationarchitecture.
[!warning] Experimental
1Classification Report:
2 precision recall f1-score support
3
4 Fake 0.9718 0.9155 0.9428 10000
5 Real 0.9201 0.9734 0.9460 9999
6
7 accuracy 0.9444 19999
8 macro avg 0.9459 0.9444 0.9444 19999
9weighted avg 0.9459 0.9444 0.9444 19999
Class 0: fake
Class 1: realpip install -q transformers torch pillow gradio hf_xet1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/deepfake-detector-model-v1"
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# Updated label mapping
12id2label = {
13 "0": "fake",
14 "1": "real"
15}
16
17def classify_image(image):
18 image = Image.fromarray(image).convert("RGB")
19 inputs = processor(images=image, return_tensors="pt")
20
21 with torch.no_grad():
22 outputs = model(**inputs)
23 logits = outputs.logits
24 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
25
26 prediction = {
27 id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
28 }
29
30 return prediction
31
32# Gradio Interface
33iface = gr.Interface(
34 fn=classify_image,
35 inputs=gr.Image(type="numpy"),
36 outputs=gr.Label(num_top_classes=2, label="Deepfake Classification"),
37 title="deepfake-detector-model",
38 description="Upload an image to classify whether it is real or fake using a deepfake detection model."
39)
40
41if __name__ == "__main__":
42 iface.launch()deepfake-detector-model is designed for: