Image Classification
Transformers
Safetensors
English
siglip
SigLIP2
ImageShield
90M
Guardrail
prithivMLmods commited on
Commit
6e40e78
·
verified ·
1 Parent(s): ee806e6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +117 -0
README.md CHANGED
@@ -2,6 +2,123 @@
2
  license: apache-2.0
3
  base_model:
4
  - google/siglip2-base-patch16-224
 
5
  ---
6
 
7
  ![1](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/PxMC3xQE3LdbpfWzv4MBD.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  base_model:
4
  - google/siglip2-base-patch16-224
5
+ library_name: transformers
6
  ---
7
 
8
  ![1](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/PxMC3xQE3LdbpfWzv4MBD.png)
9
+
10
+ # **ImageShield-SUPER-90M**
11
+
12
+ > **ImageShield-SUPER-90M** is a vision-language image classification model based on **google/siglip2-base-patch16-224**, trained on **100K samples from the ImageShield-Guardrail Safe and Unsafe Images dataset**. Built on the **SiglipForImageClassification** architecture, the model is designed to classify visual content as **Safe** or **Unsafe** for content moderation and media filtering.
13
+
14
+ > [!note]
15
+ > *SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features*
16
+ > [https://arxiv.org/pdf/2502.14786](https://arxiv.org/pdf/2502.14786)
17
+
18
+ ## **Label Space: 2 Classes**
19
+
20
+ The model classifies each image into one of the following content categories:
21
+
22
+ ```text
23
+ Class 0: "Safe"
24
+ Class 1: "Unsafe"
25
+ ```
26
+
27
+ ## **Install Dependencies**
28
+
29
+ ```bash
30
+ pip install transformers torch torchvision pillow gradio
31
+ ```
32
+
33
+ ## **Inference Code**
34
+
35
+ ```python
36
+ import gradio as gr
37
+ from transformers import AutoImageProcessor, SiglipForImageClassification
38
+ from PIL import Image
39
+ import torch
40
+
41
+ # Load model and processor
42
+ model_name = "prithivMLmods/ImageShield-SUPER-90M"
43
+ model = SiglipForImageClassification.from_pretrained(model_name)
44
+ processor = AutoImageProcessor.from_pretrained(model_name)
45
+
46
+ # ID to Label mapping
47
+ id2label = {
48
+ "0": "Safe",
49
+ "1": "Unsafe"
50
+ }
51
+
52
+ def classify_image(image):
53
+ image = Image.fromarray(image).convert("RGB")
54
+ inputs = processor(images=image, return_tensors="pt")
55
+
56
+ with torch.no_grad():
57
+ outputs = model(**inputs)
58
+ logits = outputs.logits
59
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
60
+
61
+ prediction = {
62
+ id2label[str(i)]: round(probs[i], 3)
63
+ for i in range(len(probs))
64
+ }
65
+
66
+ return prediction
67
+
68
+ # Gradio Interface
69
+ iface = gr.Interface(
70
+ fn=classify_image,
71
+ inputs=gr.Image(type="numpy"),
72
+ outputs=gr.Label(
73
+ num_top_classes=2,
74
+ label="Predicted Content Type"
75
+ ),
76
+ title="ImageShield-SUPER-90M",
77
+ description="Classifies images as Safe or Unsafe."
78
+ )
79
+
80
+ if __name__ == "__main__":
81
+ iface.launch()
82
+ ```
83
+
84
+ ## **Intended Use**
85
+
86
+ This model is intended for applications such as:
87
+
88
+ * **Content Moderation:** Identify unsafe visual content.
89
+ * **Parental Controls:** Support AI-based media filtering.
90
+ * **Dataset Preprocessing:** Categorize and filter safe and unsafe images.
91
+ * **Online Platforms:** Assist with content safety and upload moderation.
92
+ * **AI Image Applications:** Provide an additional safety layer for image generation and editing workflows.
93
+
94
+ ## **Classification Report**
95
+
96
+ ### Training vs Evaluation Loss / Accuracy
97
+
98
+ ![Training vs Evaluation Loss and Accuracy](assets/training_eval_graph.png)
99
+
100
+ ### Precision / Recall / F1-score per Class
101
+
102
+ ![Per-Class Precision, Recall, and F1-score](assets/classification_report_bar.png)
103
+
104
+ ### Confusion Matrix
105
+
106
+ ![Confusion Matrix](assets/confusion_matrix.png)
107
+
108
+ ### Test Set Class Distribution
109
+
110
+ ![Test Set Class Distribution](assets/class_distribution_pie.png)
111
+
112
+ ### Overall Prediction Accuracy
113
+
114
+ ![Overall Prediction Accuracy](assets/prediction_accuracy_pie.png)
115
+
116
+ ### Misalignment Distribution by True Class
117
+
118
+ ![Misalignment Distribution by True Class](assets/misalignment_distribution_pie.png)
119
+
120
+ ## **Acknowledgements**
121
+
122
+ * **[Transformers](https://huggingface.co/docs/transformers/en/index)**: Transformers provides state-of-the-art machine learning models for text, computer vision, audio, video, and multimodal tasks, supporting both inference and training.
123
+
124
+ * **[SigLIP 2](https://huggingface.co/papers/2502.14786)**: Multilingual vision-language encoders with improved semantic understanding, localization, and dense feature representations.