Downloads · 30 days
0
n4xtan/nsfw-classification
nsfw-classification is a machine learning model from n4xtan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
A CLIP-based image classification API that categorizes images into three classes: Safe, NSFW Mild, and NSFW Explicit.
Downloads · 30 days
0
Access
Public
Updated Dec 27, 2025
Repo size
2.4 GB
Likes
1
Public
Click a slice to open those files.
.onnx1.2 GB · 100%
From the Hugging Face model README
A CLIP-based image classification API that categorizes images into three classes: Safe, NSFW Mild, and NSFW Explicit.
openai/clip-vit-large-patch14)GET /health
Returns model status and configuration.
POST /predict
Content-Type: multipart/form-data
Form field: image (file)
Response:
{
"filename": "image.jpg",
"predicted_class": "Safe",
"predicted_index": 0,
"is_nsfw": false,
"confidence": 0.95,
"all_scores": {
"Safe": 0.95,
"NSFW Mild": 0.03,
"NSFW Explicit": 0.02
},
"status": "success"
}
POST /predict/batch
Content-Type: multipart/form-data
Form field: images (multiple files)
Images are preprocessed with CLIP-specific normalization:
[0.481, 0.458, 0.408] and std [0.269, 0.261, 0.276]# Install dependencies
pip install -r requirements.txt
# Run the API
python app.py
The API runs on port 7860 by default. Override with the PORT environment variable.
docker build -t nsfw-classifier .
docker run -p 7860:7860 nsfw-classifier
The model is automatically downloaded from Hugging Face Hub on startup.
import requests
with open("image.jpg", "rb") as f:
response = requests.post(
"http://localhost:7860/predict",
files={"image": f}
)
print(response.json())
See Hugging Face Spaces Config Reference for deployment options.