prithivMLmods commited on
Commit
b96b26f
·
verified ·
1 Parent(s): e86b968

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md CHANGED
@@ -2,7 +2,25 @@
2
  license: apache-2.0
3
  datasets:
4
  - anson-huang/mirage-news
 
 
 
 
 
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
6
  ```py
7
  Classification Report:
8
  precision recall f1-score support
@@ -16,3 +34,73 @@ weighted avg 0.9484 0.9464 0.9463 10000
16
  ```
17
 
18
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/FwEjat-T3wv1v1Idiu8Qm.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - anson-huang/mirage-news
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-224
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - Fake
13
+ - Real
14
+ - SigLIP2
15
+ - Mirage
16
  ---
17
+
18
+ ![zdfgsdfz.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/jlEXmQDn1tBgBCHjO3ytD.png)
19
+
20
+ # **Mirage-Photo-Classifier**
21
+
22
+ > **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.
23
+
24
  ```py
25
  Classification Report:
26
  precision recall f1-score support
 
34
  ```
35
 
36
  ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/FwEjat-T3wv1v1Idiu8Qm.png)
37
+
38
+ The model categorizes images into two classes:
39
+
40
+ - **Class 0:** Real
41
+ - **Class 1:** Fake
42
+
43
+ ---
44
+
45
+ # **Run with Transformers 🤗**
46
+
47
+ ```python
48
+ !pip install -q transformers torch pillow gradio
49
+ ```
50
+
51
+ ```python
52
+ import gradio as gr
53
+ from transformers import AutoImageProcessor
54
+ from transformers import SiglipForImageClassification
55
+ from PIL import Image
56
+ import torch
57
+
58
+ # Load model and processor
59
+ model_name = "prithivMLmods/Mirage-Photo-Classifier"
60
+ model = SiglipForImageClassification.from_pretrained(model_name)
61
+ processor = AutoImageProcessor.from_pretrained(model_name)
62
+
63
+ # Label mapping
64
+ labels = {
65
+ "0": "Real",
66
+ "1": "Fake"
67
+ }
68
+
69
+ def classify_image_authenticity(image):
70
+ """Predicts whether the image is real or AI-generated (fake)."""
71
+ image = Image.fromarray(image).convert("RGB")
72
+ inputs = processor(images=image, return_tensors="pt")
73
+
74
+ with torch.no_grad():
75
+ outputs = model(**inputs)
76
+ logits = outputs.logits
77
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
78
+
79
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
80
+
81
+ return predictions
82
+
83
+ # Gradio interface
84
+ iface = gr.Interface(
85
+ fn=classify_image_authenticity,
86
+ inputs=gr.Image(type="numpy"),
87
+ outputs=gr.Label(label="Prediction Scores"),
88
+ title="Mirage Photo Classifier",
89
+ description="Upload an image to determine if it's Real or AI-generated (Fake)."
90
+ )
91
+
92
+ # Launch the app
93
+ if __name__ == "__main__":
94
+ iface.launch()
95
+ ```
96
+
97
+ ---
98
+
99
+ # **Intended Use**
100
+
101
+ The **Mirage-Photo-Classifier** model is designed to detect whether an image is genuine (photograph) or synthetically generated. Use cases include:
102
+
103
+ - **AI Image Detection:** Identifying AI-generated images in social media, news, or datasets.
104
+ - **Digital Forensics:** Helping professionals detect image authenticity in investigations.
105
+ - **Platform Moderation:** Assisting content platforms in labeling generated content.
106
+ - **Dataset Validation:** Cleaning and verifying training data for other AI models.