File size: 3,206 Bytes
44326fe
 
 
 
b96b26f
 
 
 
 
 
 
 
 
 
 
e86b968
b96b26f
 
 
 
 
 
 
e86b968
 
 
 
 
 
 
 
 
 
 
 
 
b96b26f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
license: apache-2.0
datasets:
- anson-huang/mirage-news
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- Fake
- Real
- SigLIP2
- Mirage
---

![zdfgsdfz.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/jlEXmQDn1tBgBCHjO3ytD.png)

# **Mirage-Photo-Classifier**

> **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.

```py
Classification Report:
              precision    recall  f1-score   support

        Real     0.9781    0.9132    0.9446      5000
        Fake     0.9186    0.9796    0.9481      5000

    accuracy                         0.9464     10000
   macro avg     0.9484    0.9464    0.9463     10000
weighted avg     0.9484    0.9464    0.9463     10000
```

![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/FwEjat-T3wv1v1Idiu8Qm.png)

The model categorizes images into two classes:

- **Class 0:** Real  
- **Class 1:** Fake  

---

# **Run with Transformers 🤗**

```python
!pip install -q transformers torch pillow gradio
```

```python
import gradio as gr
from transformers import AutoImageProcessor
from transformers import SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/Mirage-Photo-Classifier"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# Label mapping
labels = {
    "0": "Real",
    "1": "Fake"
}

def classify_image_authenticity(image):
    """Predicts whether the image is real or AI-generated (fake)."""
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
    
    return predictions

# Gradio interface
iface = gr.Interface(
    fn=classify_image_authenticity,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(label="Prediction Scores"),
    title="Mirage Photo Classifier",
    description="Upload an image to determine if it's Real or AI-generated (Fake)."
)

# Launch the app
if __name__ == "__main__":
    iface.launch()
```

---

# **Intended Use**

The **Mirage-Photo-Classifier** model is designed to detect whether an image is genuine (photograph) or synthetically generated. Use cases include:

- **AI Image Detection:** Identifying AI-generated images in social media, news, or datasets.  
- **Digital Forensics:** Helping professionals detect image authenticity in investigations.  
- **Platform Moderation:** Assisting content platforms in labeling generated content.  
- **Dataset Validation:** Cleaning and verifying training data for other AI models.