Views
No views yet

siglip2-mini-explicit-content is an image classification vision-language encoder model fine-tuned fromsiglip2-base-patch16-512for a single-label classification task. It is designed to classify images into categories related to explicit, sensual, or safe-for-work content using the SiglipForImageClassification architecture.
[!Note] This model is intended to promote positive, safe, and respectful digital environments. Misuse is strongly discouraged and may violate platform or regional guidelines. As a classification model, it does not generate unsafe content and is suitable for moderation purposes.
[!note] SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
[!Important] Note: Explicit, sensual, and pornographic content may appear in the results; however, all of them are considered not safe for work.
1Classification Report:
2 precision recall f1-score support
3
4 Anime Picture 0.8897 0.8296 0.8586 5600
5Extincing & Sensual 0.8984 0.9477 0.9224 5618
6 Hentai 0.8993 0.9118 0.9055 5600
7 Pornography 0.9527 0.9285 0.9404 5970
8 Safe for Work 0.8957 0.9172 0.9063 6000
9
10 accuracy 0.9074 28788
11 macro avg 0.9072 0.9069 0.9066 28788
12 weighted avg 0.9076 0.9074 0.9071 28788
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from transformers.image_utils import load_image
4from PIL import Image
5import torch
6
7# Load model and processor
8model_name = "prithivMLmods/siglip2-mini-explicit-content"
9model = SiglipForImageClassification.from_pretrained(model_name)
10processor = AutoImageProcessor.from_pretrained(model_name)
11
12# Updated labels
13labels = {
14 "0": "Anime Picture",
15 "1": "Extincing & Sensual",
16 "2": "Hentai",
17 "3": "Pornography",
18 "4": "Safe for Work"
19}
20
21def detect_explicit_content(image):
22 """Predicts content category in an uploaded image."""
23 image = Image.fromarray(image).convert("RGB")
24 inputs = processor(images=image, return_tensors="pt")
25
26 with torch.no_grad():
27 outputs = model(**inputs)
28 logits = outputs.logits
29 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
30
31 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
32 return predictions
33
34# Gradio Interface
35iface = gr.Interface(
36 fn=detect_explicit_content,
37 inputs=gr.Image(type="numpy"),
38 outputs=gr.Label(label="Prediction Scores"),
39 title="siglip2-mini-explicit-content",
40 description="Upload an image to classify it as Anime, Hentai, Sensual, Pornographic, or Safe for Work."
41)
42
43if __name__ == "__main__":
44 iface.launch()[!warning] Anime Picture

[!warning] Extincing & Sensual


[!warning] Hentai

[!warning] Pornography

[!warning] Safe for Work
