Views
No views yet

SigLIP2-ImageShield-90M-256 is a vision-language encoder model fine-tuned from google/siglip2-base-patch16-256 for multi-class image classification. Built on the SiglipForImageClassification architecture, the model is designed to identify and categorize visual content for explicit, suggestive, and safe media filtering.
[!IMPORTANT] This model is experimental. Expert multimodal models are available here: ImageShield Multimodal SFT Collection.
[!note] SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
1Class 0: "Anime"
2Class 1: "Hentai"
3Class 2: "Normal"
4Class 3: "Pornography"
5Class 4: "Sensual"pip install transformers torch torchvision pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/SigLIP2-ImageShield-90M-256" # Replace with your model path if needed
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# ID to Label mapping
12id2label = {
13 "0": "Anime",
14 "1": "Hentai",
15 "2": "Normal",
16 "3": "Pornography",
17 "4": "Sensual"
18}
19
20def classify_image(image):
21 image = Image.fromarray(image).convert("RGB")
22 inputs = processor(images=image, return_tensors="pt")
23
24 with torch.no_grad():
25 outputs = model(**inputs)
26 logits = outputs.logits
27 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
28
29 prediction = {
30 id2label[str(i)]: round(probs[i], 3)
31 for i in range(len(probs))
32 }
33
34 return prediction
35
36# Gradio Interface
37iface = gr.Interface(
38 fn=classify_image,
39 inputs=gr.Image(type="numpy"),
40 outputs=gr.Label(
41 num_top_classes=5,
42 label="Predicted Content Type"
43 ),
44 title="SigLIP2-ImageShield-90M-256",
45 description="Classifies images into Anime, Hentai, Normal, Pornography, and Sensual categories."
46)
47
48if __name__ == "__main__":
49 iface.launch()




