Sign inSign up

penndu/nsfw-api

By penndu

•Updated 17 days ago

https://dusays.com/posts/495/

Image
3

5.6K

penndu/nsfw-api repository overview

⁠nsfw-api — NSFW 图像分类 API

NSFWJS 的 HTTP 封装:把图片丢进来,返回 porn / sexy / hentai / neutral / drawing 五类概率。

English

An HTTP wrapper around NSFWJS⁠. Post an image, get back probabilities across five categories: porn, sexy, hentai, neutral, drawing.

基于 TensorFlow.js 的图像内容分级服务,TypeScript 编写,镜像内已内置 NSFWJS 模型权重,开箱即用。


⁠特性 / Features

  • 模型内置 —— 镜像已打包 TensorFlowJS 299x299 图像模型,无需另行下载

  • 双架构 —— linux/amd64 与 linux/arm64 均可用(Apple Silicon 原生跑)

  • 两种精度 —— 完整模型与量化模型可按需选择

  • 单张 / 批量 —— /classify 与 /classify-many 两个接口

  • 纯 HTTP —— 标准 multipart 上传,任意语言都能调

  • Model bundled — the TensorFlowJS 299×299 image model ships inside the image

  • Multi-arch — linux/amd64 and linux/arm64 (native on Apple Silicon)

  • Two precisions — full model or quantized model

  • Single & batch — /classify and /classify-many

  • Plain HTTP — standard multipart upload, callable from any language


⁠快速开始 / Quick Start

docker run -d --name nsfw-api -p 3000:3000 --restart always \
  penndu/nsfw-api:latest
version: "3.9"

services:
  nsfw-api:
    image: "penndu/nsfw-api:latest"
    ports:
      - "3000:3000"
    restart: always

⁠API / 接口

⁠POST /classify

图片放在 image 字段:

POST /classify HTTP/1.1
Content-Type: multipart/form-data
{
  "porn": 0.59248286485672,
  "sexy": 0.39802199602127075,
  "hentai": 0.006243097595870495,
  "neutral": 0.0031403270550072193,
  "drawing": 0.00011181648733327165
}
⁠POST /classify-many

同一请求里传多张图片,批量返回分类结果。

⁠调用示例 / Client example
curl -X POST -F "image=@./sample.jpg" http://localhost:3000/classify

⁠标签 / Tags

Tag说明
latest完整 TensorFlowJS 模型(299x299),检测效果更好
latest-min量化模型,体积更小、速度更快

Tag summary

Content type

Image

Digest

sha256:b9ab511b1…

Size

900.7 MB

Last updated

17 days ago

docker pull penndu/nsfw-api