Downloads · 30 days
53
22% of all-time downloads
onnx-community/vit-Large-nsfw-detector-ONNX
vit-Large-nsfw-detector-ONNX is a image classification model from onnx-community. Use it when you need a label for an image. It is set up for transformers.js. The card lists the license as mit.
This is an ONNX version of theusamaaslam/vit-Large-nsfw-detector. It was automatically converted and uploaded using this Hugging Face Space.
Downloads · 30 days
53
22% of all-time downloads
All-time downloads
246
Public
Repo size
2.8 GB
Likes
0
Public
Click a slice to open those files.
.onnx3.3 GB · 100%
From the Hugging Face model README
This is an ONNX version of theusamaaslam/vit-Large-nsfw-detector. It was automatically converted and uploaded using this Hugging Face Space.
See the pipeline documentation for image-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ImageClassificationPipeline
This model is a fine-tuned Vision Transformer (ViT-Large, Patch16-224) developed by the Nayatel AI & DevOps Team to classify images into NSFW or Safe categories.
It is designed for high-recall NSFW detection, making it suitable for content moderation, filtering pipelines, and safety-critical applications.
Evaluation was performed on a held-out validation set derived from a self-curated dataset. The model demonstrates strong generalization and robustness across diverse NSFW and safe image categories.
| Metric | Value |
|---|---|
| Accuracy | 95.38% |
| Precision | 90.53% |
| Recall | 93.28% |
| F1 Score | 91.88% |
| ROC AUC | ≈ 0.98 |
google/vit-large-patch16-224nsfw, safe0 → nsfw1 → safeViT splits an image into fixed-size patches and processes them using multi-head self-attention across 24 transformer layers, enabling strong global context understanding.
The model was trained on a self-curated, large-scale dataset compiled from multiple sources and internal filtering pipelines.
| Split | Number of Images |
|---|---|
| Train | 96,085 |
| Validation | 19,283 |
| Test | 12,884 |
from transformers import pipeline
from PIL import Image
predict = pipeline(
"image-classification",
model="theusamaaslam/vit-Large-nsfw-detector",
device=0 # GPU
)
img = Image.open("<path_to_image_file>").convert("RGB")
result = predict(img)
print(result)
Usage for a distant image:
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import requests
import torch
# URL of the image to test
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
# Load image from URL
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
# Load Processor and Model from your Hub repo
repo_id = "theusamaaslam/vit-Large-nsfw-detector"
processor = AutoImageProcessor.from_pretrained(repo_id)
model = AutoModelForImageClassification.from_pretrained(repo_id)
# Process image and inference
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
# Get probabilities and predicted label
logits = outputs.logits
probs = logits.softmax(dim=1)
predicted_class_idx = logits.argmax(-1).item()
predicted_label = model.config.id2label[predicted_class_idx]
print(f"Predicted class: {predicted_label}")
print(f"Probabilities: {probs}")
Author: @theusamaaslam
Email: [[email protected]]
Organization: Nayatel (Pvt Ltd) AI & DevOps Team