Views
No views yet

AI-vs-Deepfake-vs-Real-9999 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 AI-generated, a deepfake, or a real one using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 Artificial 0.9994 0.9979 0.9986 3333
5 Deepfake 0.9979 0.9994 0.9987 3333
6 Real one 0.9994 0.9994 0.9994 3333
7
8 accuracy 0.9989 9999
9 macro avg 0.9989 0.9989 0.9989 9999
10weighted avg 0.9989 0.9989 0.9989 9999
!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/AI-vs-Deepfake-vs-Real-9999"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def classify_image(image):
14 """Predicts whether an image is Artificial, 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": "Artificial", "1": "Deepfake", "2": "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=classify_image,
33 inputs=gr.Image(type="numpy"),
34 outputs=gr.Label(label="Prediction Scores"),
35 title="AI vs. Deepfake vs. Real Image Classification",
36 description="Upload an image to determine if it's AI-generated, a Deepfake, or a Real one."
37)
38
39# Launch the app
40if __name__ == "__main__":
41 iface.launch()