Downloads · 30 days
42
3% of all-time downloads
viddexa/nsfw-detection-nano
nsfw-detection-nano 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.
Downloads · 30 days
42
3% of all-time downloads
All-time downloads
1.4K
Public
Parameters
4.1M
16.3 MB on disk
Likes
7
Public
Click a slice to open those files.
.safetensors16.3 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-b0 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-nano 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-nano performs better than Falconsai and is comparable to Azure AI with less number of parameters.
| Model | F_safe | F_nsfw | Params |
|---|---|---|---|
| <b><span style="color:turquoise">nsfw-detector-nano</span></b> | <b><span style="color:turquoise">96.91%</span></b> | <b><span style="color:turquoise">96.87%</span></b> | <b><span style="color:turquoise">4M</span></b> |
| nsfw-detector-mini | 97.90% | 97.89% | 17M |
| 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-nano")
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-nano", use_fast = False)
model= AutoModelForImageClassification.from_pretrained("viddexa/nsfw-detection-nano")
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-b0.
This model is designed to detect explicit nudity alone. 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}
}