prithivMLmods commited on
Commit
f4e6a28
·
verified ·
1 Parent(s): 15ca218

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -0
README.md CHANGED
@@ -5,8 +5,25 @@ datasets:
5
  language:
6
  - en
7
  library_name: transformers
 
 
 
 
 
 
 
8
  ---
9
 
 
 
 
 
 
 
 
 
 
 
10
  ```py
11
  Classification Report:
12
  precision recall f1-score support
@@ -21,3 +38,81 @@ weighted avg 0.9151 0.9149 0.9147 18618
21
 
22
  ![download (2).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/AtUeLO-22whnmrN-mJZDr.png)
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  language:
6
  - en
7
  library_name: transformers
8
+ base_model:
9
+ - google/siglip2-base-patch16-224
10
+ pipeline_tag: image-classification
11
+ tags:
12
+ - SigLIP2
13
+ - AI-vs-Real
14
+ - art
15
  ---
16
 
17
+ ![1.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/KhTM3MJls_zbF4q2EqxUO.png)
18
+
19
+ # AIorNot-SigLIP2
20
+
21
+ > AIorNot-SigLIP2 is a vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for binary image classification. It is trained to detect whether an image is generated by AI or is a real photograph using the SiglipForImageClassification architecture.
22
+
23
+ > [!note]
24
+ *SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features* https://arxiv.org/pdf/2502.14786
25
+
26
+
27
  ```py
28
  Classification Report:
29
  precision recall f1-score support
 
38
 
39
  ![download (2).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/AtUeLO-22whnmrN-mJZDr.png)
40
 
41
+ ---
42
+
43
+ ## Label Space: 2 Classes
44
+
45
+ The model classifies an image as either:
46
+
47
+ ```
48
+ Class 0: Real
49
+ Class 1: AI
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Install Dependencies
55
+
56
+ ```bash
57
+ pip install -q transformers torch pillow gradio hf_xet
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Inference Code
63
+
64
+ ```python
65
+ import gradio as gr
66
+ from transformers import AutoImageProcessor, SiglipForImageClassification
67
+ from PIL import Image
68
+ import torch
69
+
70
+ # Load model and processor
71
+ model_name = "prithivMLmods/AIorNot-SigLIP2" # Replace with your model path
72
+ model = SiglipForImageClassification.from_pretrained(model_name)
73
+ processor = AutoImageProcessor.from_pretrained(model_name)
74
+
75
+ # Label mapping
76
+ id2label = {
77
+ "0": "Real",
78
+ "1": "AI"
79
+ }
80
+
81
+ def classify_image(image):
82
+ image = Image.fromarray(image).convert("RGB")
83
+ inputs = processor(images=image, return_tensors="pt")
84
+
85
+ with torch.no_grad():
86
+ outputs = model(**inputs)
87
+ logits = outputs.logits
88
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
89
+
90
+ prediction = {
91
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
92
+ }
93
+
94
+ return prediction
95
+
96
+ # Gradio Interface
97
+ iface = gr.Interface(
98
+ fn=classify_image,
99
+ inputs=gr.Image(type="numpy"),
100
+ outputs=gr.Label(num_top_classes=2, label="AI or Real Detection"),
101
+ title="AIorNot-SigLIP2",
102
+ description="Upload an image to classify whether it is AI-generated or Real."
103
+ )
104
+
105
+ if __name__ == "__main__":
106
+ iface.launch()
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Intended Use
112
+
113
+ AIorNot-SigLIP2 is useful in scenarios such as:
114
+
115
+ * AI Content Detection – Identify AI-generated images for social platforms or media verification.
116
+ * Digital Media Forensics – Assist in distinguishing synthetic from real-world imagery.
117
+ * Dataset Filtering – Clean datasets by separating real photographs from AI-synthesized ones.
118
+ * Research & Development – Benchmark performance of image authenticity detectors.