SkillAgentSearch skills...

Nsfwjs Docker

High-performance, self-hosted NSFW detection API powered by NSFWJS.

Install / Use

npx skills add andresribeiro/nsfwjs-docker

Installs into whichever agent you are using.

README

nsfwjs-docker

Docker Pulls License GitHub Stars

High-performance, self-hosted NSFW detection API powered by NSFWJS.

  • Accuracy: ~93%;
  • Latency: ~100ms per prediction;
  • Input: JPEG, PNG, WebP, AVIF, TIFF, GIF (first frame), raw pixel data;
  • Output: 5-class classification — Neutral, Drawing, Sexy, Hentai, Porn;
  • Multi-architecture: Supports both x64 and arm64.
  • Lightweight: Runs under 350 MB of RAM.

Table of Contents

Installation

docker run -p 3333:3333 -d --name nsfwjs andresribeiroo/nsfwjs

Usage

POST the raw image bytes to /classify with Content-Type: application/octet-stream.

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
  "prediction": [
    { "className": "Neutral", "probability": 0.637 },
    { "className": "Drawing", "probability": 0.360 },
    { "className": "Hentai", "probability": 0.002 },
    { "className": "Sexy", "probability": 0.000 },
    { "className": "Porn", "probability": 0.000 }
  ]
}

The probability of each category ranges from 0 (lowest) to 1 (highest).

Examples

Node.js / Browser

const res = await fetch("http://localhost:3333/classify", {
  method: "POST",
  headers: { "Content-Type": "application/octet-stream" },
  body: imageBlobOrBuffer,
});
const { prediction } = await res.json();

Python

import requests

with open("image.jpg", "rb") as f:
    resp = requests.post(
        "http://localhost:3333/classify",
        data=f,
        headers={"Content-Type": "application/octet-stream"},
    )
print(resp.json()["prediction"])
# [{ className: "Neutral", probability: 0.637 }, ...]

httpie

http POST localhost:3333/classify Content-Type:application/octet-stream @image.jpg

curl

curl -X POST \
  -H "Content-Type: application/octet-stream" \
  --data-binary @image.jpg \
  http://localhost:3333/classify

Performance

This container is built for speed:

  • SIMD-accelerated image processingsharp (powered by libvips) handles image decoding and resizing to 224×224 before inference, taking advantage of SIMD instructions on compatible CPUs.
  • jemalloc allocator — The Docker image links against jemalloc, which reduces fragmentation and improves memory usage under concurrent workloads compared to the glibc allocator.
  • Model failure safety — If an error occurs during model inference, the underlying TensorFlow tensors are immediately disposed of. This architectural fallback completely prevents CPU memory leaks under any failure condition.
  • Raw binary transport — The API accepts application/octet-stream instead of multipart form data or base64-encoded JSON. This avoids the overhead of multipart parsing and base64 expansion, resulting in faster decoding and lower network transfer times.

Build from source

docker build -t nsfwjs .
docker run -p 3333:3333 nsfwjs

Local development

Requires Deno and NodeJS.

deno install                                               # install dependencies
npm rebuild @tensorflow/tfjs-node --build-from-source      # rebuild TensorFlow, required on arm64
deno task dev                                              # watch mode (restarts on file changes)
deno task start                                            # production mode

The server listens on port 3333.

Related Skills

View on GitHub
GitHub Stars97
CategoryDevelopment
Updated1mo ago
Forks20

Languages

TypeScript

Security Score

100/100

Audited on Jun 14, 2026

No findings