Instructions to use prithivMLmods/ImageShield-SUPER-90M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/ImageShield-SUPER-90M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="prithivMLmods/ImageShield-SUPER-90M") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained("prithivMLmods/ImageShield-SUPER-90M") model = AutoModelForImageClassification.from_pretrained("prithivMLmods/ImageShield-SUPER-90M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,6 +2,123 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- google/siglip2-base-patch16-224
|
|
|
|
| 5 |
---
|
| 6 |
|
| 7 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
base_model:
|
| 4 |
- google/siglip2-base-patch16-224
|
| 5 |
+
library_name: transformers
|
| 6 |
---
|
| 7 |
|
| 8 |

|
| 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 |
+

|
| 99 |
+
|
| 100 |
+
### Precision / Recall / F1-score per Class
|
| 101 |
+
|
| 102 |
+

|
| 103 |
+
|
| 104 |
+
### Confusion Matrix
|
| 105 |
+
|
| 106 |
+

|
| 107 |
+
|
| 108 |
+
### Test Set Class Distribution
|
| 109 |
+
|
| 110 |
+

|
| 111 |
+
|
| 112 |
+
### Overall Prediction Accuracy
|
| 113 |
+
|
| 114 |
+

|
| 115 |
+
|
| 116 |
+
### Misalignment Distribution by True Class
|
| 117 |
+
|
| 118 |
+

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