Image Classification
Transformers
Safetensors
English
siglip
SigLIP2
ImageShield
90M
Guardrail
File size: 4,298 Bytes
454324d
 
a84b894
 
6e40e78
5827451
 
 
 
 
 
 
 
345ae24
 
 
055ff88
 
 
6e40e78
 
 
 
 
048b4be
 
 
6e40e78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
license: apache-2.0
base_model:
- google/siglip2-base-patch16-224
library_name: transformers
tags:
- SigLIP2
- ImageShield
- 90M
- Guardrail
language:
- en
pipeline_tag: image-classification
datasets:
- prithivMLmods/ImageShield-Guardrail-80K
- prithivMLmods/ImageShield-Guardrail-Realism-60K
---

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

# **ImageShield-SUPER-90M**

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

> [!IMPORTANT]
> This model is experimental. Expert multimodal models are available here: [ImageShield Multimodal SFT Collection](https://huggingface.co/collections/prithivMLmods/imageshield-multimodal-sft).

> [!note]
> *SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features*
> [https://arxiv.org/pdf/2502.14786](https://arxiv.org/pdf/2502.14786)

## **Label Space: 2 Classes**

The model classifies each image into one of the following content categories:

```text
Class 0: "Safe"
Class 1: "Unsafe"
```

## **Install Dependencies**

```bash
pip install transformers torch torchvision pillow gradio
```

## **Inference Code**

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

# Load model and processor
model_name = "prithivMLmods/ImageShield-SUPER-90M"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# ID to Label mapping
id2label = {
    "0": "Safe",
    "1": "Unsafe"
}

def classify_image(image):
    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()

    prediction = {
        id2label[str(i)]: round(probs[i], 3)
        for i in range(len(probs))
    }

    return prediction

# Gradio Interface
iface = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(
        num_top_classes=2,
        label="Predicted Content Type"
    ),
    title="ImageShield-SUPER-90M",
    description="Classifies images as Safe or Unsafe."
)

if __name__ == "__main__":
    iface.launch()
```

## **Intended Use**

This model is intended for applications such as:

* **Content Moderation:** Identify unsafe visual content.
* **Parental Controls:** Support AI-based media filtering.
* **Dataset Preprocessing:** Categorize and filter safe and unsafe images.
* **Online Platforms:** Assist with content safety and upload moderation.
* **AI Image Applications:** Provide an additional safety layer for image generation and editing workflows.

## **Classification Report**

### Training vs Evaluation Loss / Accuracy

![Training vs Evaluation Loss and Accuracy](assets/training_eval_graph.png)

### Precision / Recall / F1-score per Class

![Per-Class Precision, Recall, and F1-score](assets/classification_report_bar.png)

### Confusion Matrix

![Confusion Matrix](assets/confusion_matrix.png)

### Test Set Class Distribution

![Test Set Class Distribution](assets/class_distribution_pie.png)

### Overall Prediction Accuracy

![Overall Prediction Accuracy](assets/prediction_accuracy_pie.png)

### Misalignment Distribution by True Class

![Misalignment Distribution by True Class](assets/misalignment_distribution_pie.png)

## **Acknowledgements**

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

* **[SigLIP 2](https://huggingface.co/papers/2502.14786)**: Multilingual vision-language encoders with improved semantic understanding, localization, and dense feature representations.