Lightweight NSFW detection solution, supporting private deployment and HTTP API calls.
4.6K

This project is based on AdamCodd/vit-base-nsfw-detector/ and exposes an HTTP API for NSFW image detection. It is suitable for CPU-only inference and provides a lightweight implementation.
AdamCodd/vit-base-nsfw-detector is a conservative NSFW detection model based on the ViT architecture. It can recognize sensitive content in real photos and illustrations but is less accurate for AI-generated images.
Note: In practice, it can detect most pornographic images. Subjectively, its accuracy feels higher than Open NSFW, but it is not 100% precise (there is no perfectly accurate solution at present). It is recommended to combine machine pre-screening with human review.
docker run -d \
--name nsfw \
-p 6086:6086 \
--restart always \
helloz/nsfw
Create docker-compose.yaml with the following content:
services:
nsfw:
container_name: nsfw
image: helloz/nsfw
ports:
- "6086:6086"
# Environment variables
environment:
- TOKEN=your_token_here
- WORKERS=1
restart: always
Then start: docker-compose up -d
TOKEN: Authentication token (set your own string). If not set, authentication is disabled.WORKERS: Number of worker processes, default 1. Increase this for multi-core CPUs.WEBUI: Whether to enable the WEBUI, the parameter value is off/on, default is off (disabled).Without authentication:
curl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png'
With authentication:
curl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png' \
--header 'Authorization: Bearer your_token_here'
curl --location --request POST 'http://localhost:6086/api/upload_check' \
--header 'Authorization: Bearer xxx' \
--form 'file=@"/Users/zhangsan/Downloads/2660b27f2e5b24ac.jpeg"'
{
"code": 200,
"msg": "success",
"data": {
"sfw": 0.0014,
"nsfw": 0.9986,
"is_nsfw": true
}
}
The demo is rate limited and for testing only. Do not use it for other purposes.
This project is for learning and testing only. Do not use it for commercial or production environments. You assume all related risks and liabilities.
If you are interested, check out our other products:
Content type
Image
Digest
sha256:93faae8dd…
Size
358.6 MB
Last updated
8 months ago
docker pull helloz/nsfw