Views
No views yet

Mirage-Photo-Classifier is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a binary image authenticity classification task. It is designed to determine whether an image is real or AI-generated (fake) using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 Real 0.9781 0.9132 0.9446 5000
5 Fake 0.9186 0.9796 0.9481 5000
6
7 accuracy 0.9464 10000
8 macro avg 0.9484 0.9464 0.9463 10000
9weighted avg 0.9484 0.9464 0.9463 10000
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from PIL import Image
5import torch
6
7# Load model and processor
8model_name = "prithivMLmods/Mirage-Photo-Classifier"
9model = SiglipForImageClassification.from_pretrained(model_name)
10processor = AutoImageProcessor.from_pretrained(model_name)
11
12# Label mapping
13labels = {
14 "0": "Real",
15 "1": "Fake"
16}
17
18def classify_image_authenticity(image):
19 """Predicts whether the image is real or AI-generated (fake)."""
20 image = Image.fromarray(image).convert("RGB")
21 inputs = processor(images=image, return_tensors="pt")
22
23 with torch.no_grad():
24 outputs = model(**inputs)
25 logits = outputs.logits
26 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
27
28 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
29
30 return predictions
31
32# Gradio interface
33iface = gr.Interface(
34 fn=classify_image_authenticity,
35 inputs=gr.Image(type="numpy"),
36 outputs=gr.Label(label="Prediction Scores"),
37 title="Mirage Photo Classifier",
38 description="Upload an image to determine if it's Real or AI-generated (Fake)."
39)
40
41# Launch the app
42if __name__ == "__main__":
43 iface.launch()