Update README.md
Browse files
README.md
CHANGED
@@ -16,6 +16,18 @@ tags:
|
|
16 |
- Anime
|
17 |
---
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
```py
|
20 |
Classification Report:
|
21 |
precision recall f1-score support
|
@@ -32,3 +44,70 @@ Enticing or Sensual 0.7699 0.8979 0.8290 5600
|
|
32 |
```
|
33 |
|
34 |

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
- Anime
|
17 |
---
|
18 |
|
19 |
+
# **Mature-Content-Detection**
|
20 |
+
|
21 |
+
> **Mature-Content-Detection** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify images into various mature or neutral content categories using the **SiglipForImageClassification** architecture.
|
22 |
+
|
23 |
+
The model categorizes images into five classes:
|
24 |
+
|
25 |
+
- **Class 0:** Anime Picture
|
26 |
+
- **Class 1:** Hentai
|
27 |
+
- **Class 2:** Neutral
|
28 |
+
- **Class 3:** Pornography
|
29 |
+
- **Class 4:** Enticing or Sensual
|
30 |
+
|
31 |
```py
|
32 |
Classification Report:
|
33 |
precision recall f1-score support
|
|
|
44 |
```
|
45 |
|
46 |

|
47 |
+
|
48 |
+
# **Run with Transformers 🤗**
|
49 |
+
|
50 |
+
```python
|
51 |
+
!pip install -q transformers torch pillow gradio
|
52 |
+
```
|
53 |
+
|
54 |
+
```python
|
55 |
+
import gradio as gr
|
56 |
+
from transformers import AutoImageProcessor
|
57 |
+
from transformers import SiglipForImageClassification
|
58 |
+
from transformers.image_utils import load_image
|
59 |
+
from PIL import Image
|
60 |
+
import torch
|
61 |
+
|
62 |
+
# Load model and processor
|
63 |
+
model_name = "prithivMLmods/Mature-Content-Detection"
|
64 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
65 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
66 |
+
|
67 |
+
# Updated labels
|
68 |
+
labels = {
|
69 |
+
"0": "Anime Picture",
|
70 |
+
"1": "Hentai",
|
71 |
+
"2": "Neutral",
|
72 |
+
"3": "Pornography",
|
73 |
+
"4": "Enticing or Sensual"
|
74 |
+
}
|
75 |
+
|
76 |
+
def mature_content_detection(image):
|
77 |
+
"""Predicts the type of content in the image."""
|
78 |
+
image = Image.fromarray(image).convert("RGB")
|
79 |
+
inputs = processor(images=image, return_tensors="pt")
|
80 |
+
|
81 |
+
with torch.no_grad():
|
82 |
+
outputs = model(**inputs)
|
83 |
+
logits = outputs.logits
|
84 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
85 |
+
|
86 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
87 |
+
|
88 |
+
return predictions
|
89 |
+
|
90 |
+
# Create Gradio interface
|
91 |
+
iface = gr.Interface(
|
92 |
+
fn=mature_content_detection,
|
93 |
+
inputs=gr.Image(type="numpy"),
|
94 |
+
outputs=gr.Label(label="Prediction Scores"),
|
95 |
+
title="Mature Content Detection",
|
96 |
+
description="Upload an image to classify whether it contains anime, hentai, neutral, pornographic, or enticing/sensual content."
|
97 |
+
)
|
98 |
+
|
99 |
+
# Launch the app
|
100 |
+
if __name__ == "__main__":
|
101 |
+
iface.launch()
|
102 |
+
```
|
103 |
+
|
104 |
+
---
|
105 |
+
|
106 |
+
# **Intended Use:**
|
107 |
+
|
108 |
+
The **Mature-Content-Detection** model is designed to classify visual content for moderation and filtering purposes. Potential use cases include:
|
109 |
+
|
110 |
+
- **Content Moderation:** Automatically flagging explicit or sensitive content on platforms.
|
111 |
+
- **Parental Control Systems:** Filtering inappropriate material for child-safe environments.
|
112 |
+
- **Search Engine Filtering:** Improving search results by categorizing Un-Safe content.
|
113 |
+
- **Dataset Cleaning:** Assisting in curation of safe training datasets for other AI models.
|