Skip to content

rishik18/NSFW_detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NudeNet NSFW Tagging API

A simple REST API built with Flask and NudeNet for detecting and tagging NSFW content in images.
Supports file uploads and remote image URLs (single or multiple).


Features

  • 🔥 Fast inference — NudeNet model preloaded at container startup
  • 🖼️ Flexible input — Upload files or pass one/many image URLs
  • Production-ready — Gunicorn + Dockerfile included
  • 🛡️ Safe defaults — File type validation, download timeouts
  • Health check/health endpoint for container orchestration

API Endpoints

Health check

GET /health

Returns:

{ "status": "ok" }

Detect NSFW (single file)

POST /detect
Content-Type: multipart/form-data
Form field: file=@/path/to/image.jpg

Example:

curl -X POST http://localhost:8080/detect \
  -F "file=@/path/to/image.jpg"

Detect NSFW (single URL)

POST /detect
Content-Type: application/json
Body:
{
  "image_url": "https://example.com/image.jpg"
}

Responses

{
  "ok": true,
  "mode": "urls",
  "count": 2,
  "results": [
    {
      "source": "https://example.com/a.jpg",
      "detections": [
        { "class": "EXPOSED_ANUS", "score": 0.98, "box": [0.2, 0.3, 0.5, 0.7] }
      ]
    },
    {
      "source": "https://example.com/b.png",
      "error": "HTTP 404"
    }
  ]
}
  • detections: each detection contains class (NSFW label), score (confidence), and box (normalized bounding box [x_min, y_min, x_max, y_max]).
  • error: returned if the file/URL failed.

Local Development

1️⃣ Clone & install

git clone https://github.com/yourusername/nsfw-tagging-api.git
cd nsfw-tagging-api
pip install -r requirements.txt

2️⃣ Run (dev mode)

python app.py
# or specify port:
python app.py --port 8080

Server runs at http://127.0.0.1:8080.


Docker

Build

docker build -t nsfw-tagging-api .

Run

docker run --rm -p 8080:8080 nsfw-tagging-api

Test

curl -X POST http://127.0.0.1:8080/detect \
  -F "file=@/path/to/image.jpg"

Environment

  • Python 3.11+
  • Flask + Flask-RESTful
  • NudeNet (downloads pretrained models)
  • Requests

Ensure your container/machine has enough memory (>=512 MB recommended).


License

MIT © 2025 [Hrishikesh Kanade]

About

Container for for NSFW detection with nudenet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published