nsfw_image_detection
230
1
license:apache-2.0
by
acaciabengo
Image Model
OTHER
224B params
New
230 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
501GB+ RAM
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Device Compatibility
Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
209GB+ RAM
Code Examples
Confusion Matrixpythontransformers
from transformers import ViTImageProcessor, ViTForImageClassification
from PIL import Image
import requests
import torch
# Load the model and processor
model_name = "acaciabengo/nsfw_image_detection"
processor = ViTImageProcessor.from_pretrained(model_name)
model = ViTForImageClassification.from_pretrained(model_name)
# Mapping IDs to human-readable labels
labels = {'drawings': 0, 'hentai': 1, 'neutral': 2, 'porn': 3, 'sexy': 4}
id_to_label = {v: k for k, v in labels.items()}
# Load an image from a URL or local path
url = "https://example.com/sample_image.jpg"
image = Image.open(requests.get(url, stream=True).raw)
# Preprocess image and perform inference
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
# Calculate probabilities and get the top prediction
probabilities = logits.softmax(dim=-1).squeeze().tolist()
predicted_class_idx = logits.argmax(-1).item()
print(f"Predicted label: {id_to_label[predicted_class_idx]}")
print("\nProbabilities:")
for i, prob in enumerate(probabilities):
print(f"- {id_to_label[i]}: {prob:.2%}")Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.