Downloads · 30 days
509
16% of all-time downloads
viddexa/nsfw-detection-mini
nsfw-detection-mini is a image classification model from viddexa. Use it when you need a label for an image. It is set up for transformers. The card lists the license as apache-2.0.
A mobile-friendly visual content moderation model, based on the work of F. C. Akyon obtained by fine-tuning EfficientNet-b4 on nsfw images to detect nudity and sexual content in images or video frames with high accuracy.
Downloads · 30 days
509
16% of all-time downloads
All-time downloads
3.1K
Public
Parameters
17.7M
70.8 MB on disk
Likes
11
Public
Click a slice to open those files.
.safetensors70.8 MB · 100%
From the Hugging Face model README
A mobile-friendly visual content moderation model, based on the work of F. C. Akyon obtained by fine-tuning EfficientNet-b4 on nsfw images to detect nudity and sexual content in images or video frames with high accuracy.
For a Demo, see: [viddexa/moderators]
Nsfw image detection performance of nsfw-detector-mini compared with Azure Content Safety AI and Falconsai nsfw image detection model.
F_safe and F_nsfw below are class-wise F1 scores for safe and nsfw classes, respectively.
Results show that nsfw-detector-mini performs better than Falconsai and Azure AI with fewer parameters.
| Model | F_safe | F_nsfw | Params |
|---|---|---|---|
| nsfw-detector-nano | 96.91% | 96.87% | 4M |
| <b><span style="color:turquoise">nsfw-detector-mini</span></b> | <b><span style="color:turquoise">97.90%</span></b> | <b><span style="color:turquoise">97.89%</span></b> | <b><span style="color:turquoise">17M</span></b> |
| Azure AI | 96.79% | 96.57% | N/A |
| Falconsai | 89.52% | 89.32% | 85M |
Install with pip install moderators then run:
from moderators import AutoModerator
model = AutoModerator.from_pretrained("viddexa/nsfw-detection-mini")
results = model("<path-to-image-file>")
probs = {k: v for r in results for k, v in r.classifications.items()}
predicted_label = max(probs, key=probs.get)
Install with pip install transformers then run:
from transformers import (
AutoImageProcessor,
AutoModelForImageClassification)
from PIL import Image
import torch
img = Image.open("<path-to-image-file>")
processor = AutoImageProcessor.from_pretrained("viddexa/nsfw-detection-mini", use_fast = False)
model= AutoModelForImageClassification.from_pretrained("viddexa/nsfw-detection-mini")
with torch.no_grad():
inputs = processor(images=img, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
probs = torch.softmax(logits, dim=-1)
pred_id = int(probs.argmax())
print(model.config.id2label[pred_id])
A binary nudity and sexual content classification model that classifies images either as Safe or NSFW. Model is obtained by fine-tuning google's Efficientnet-b4.
This model is designed to detect explicit nudity alone. For instance, an image containing suggestive nudity or risqué clothing is labeled as safe if there is no explicit nudity in the image.
Appropriate Use Cases:
In these settings, the model acts as an initial screening tool to help reduce moderator workload. A human review step is recommended for final decisions.
This model is not intended for:
@article{akyon2023nudity,
title={State-of-the-art in nudity classification: A comparative analysis},
author={Akyon, Fatih Cagatay and Temizel, Alptekin},
booktitle={2023 IEEE International Conference on Acoustics, Speech, and Signal Processing Workshops (ICASSPW)},
pages={1--5},
year={2023},
organization={IEEE}
}