基于 ONNX Runtime 的图片 NSFW 分类程序。
优势:使用GO语言开发,更省内存,更快,更轻量级,更易于部署
安装VC库
32位
https://aka.ms/vs/17/release/vc_redist.x86.exe
64位
https://aka.ms/vs/17/release/vc_redist.x64.exe
帮助:nsfw-ent.exe -h
用法: nsfw-ent [选项]
nsfw-ent -addr :8800 启动 HTTP 服务(测试页 + API)
-addr string
HTTP 服务监听地址 (default "127.0.0.1:80")
-license string
授权证书路径(留空则进入 300 秒试用模式)
-log-level string
日志级别: debug/info/warn/error (default "debug")
-max-concurrency int
最大并发HTTP API请求数(0 表示不限制,会排队到超时)
-max-image-size int
最大图片大小(MB) (default 20)
-model string
ONNX 模型路径 (default "best-cls.onnx")
-size int
模型输入尺寸(单边像素) (default 416)
-threads int
ONNX Runtime 推理线程数(intra-op) (default 4)
启动 Web 服务(内置测试页 + API):
nsfw-ent.exe
测试页:浏览器打开 http://localhost/,支持拖拽/点击上传图片
API:`POST /api/classify`
# 1. multipart 文件上传
curl -X POST -F "image=@photo.jpg" http://localhost/api/classify
# 2. raw body 直接传图片二进制
curl -X POST --data-binary "@photo.jpg" -H "Content-Type: image/jpeg" http://localhost/api/classify
# 3. base64
curl -X POST -H "Content-Type: application/json" -d '{"image":"<base64>"}' http://localhost/api/classify
输出
{"drawing": 0.01, "hentai": 0.05, "normal": 0.1, "porn": 0.2, "sexy": 0.64}
本程序仅供测试,请不要用于商业用途
联系客服
手机版
返回顶部