Nsfw
轻量级NSFW识别方案,支持私有部署和HTTP API调用。
Install / Use
npx skills add helloxz/nsfwInstalls into whichever agent you are using.
README
中文说明 | English
helloxz/nsfw

关于
此项目基于AdamCodd/vit-base-nsfw-detector/ 实现,并封装为HTTP API调用,可用于识别网络色情图像(nsfw识别),适合纯CPU机器推理,轻量级实现方案。
AdamCodd/vit-base-nsfw-detector是基于ViT架构的保守型NSFW检测模型,能识别真实图片和绘画中的敏感内容,但对AI生成图片准确率较低。
备注:xiaoz亲测能识别大多数色情图像,个人主观感觉识别准确度高于Open NSFW,但做不到100%精准(目前市面上不存在完全精准的识别方案,建议机器初审 + 人工复审)。
特点
- 纯CPU推理,适合大多数云服务器或VPS
- 支持的图片类型:jpg/png/bmp/webp/gif
- 支持HTTP API调用
- 支持鉴权访问
- 轻量级实现,资源占用相对较低
- 识别速度较快
- 支持Docker私有部署
私有部署
Docker部署
docker run -d \
--name nsfw \
-p 6086:6086 \
--restart always \
helloz/nsfw
使用Docker Compose部署(推荐)
新建docker-compose.yaml,内容如下:
services:
nsfw:
container_name: nsfw
image: helloz/nsfw
ports:
- "6086:6086"
# 环境变量
environment:
- TOKEN=your_token_here
- WORKERS=1
restart: always
然后启动:docker-compose up -d
环境变量
TOKEN:鉴权密钥(自行设置字符串),不设置则无需鉴权WORKERS:进程数量,默认1,多核CPU可增加此数值WEBUI:是否启用WEBUI,参数值为off/on,默认off不启用
HTTP API
传递URL检测
GET请求方式(不使用鉴权):
curl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png'
GET请求方式(启用鉴权):
curl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png' \
--header 'Authorization: Bearer your_token_here'
POST请求方式:
curl --location --request POST 'http://localhost:6086/api/url_check' \
--header 'Content-Type: application/json' \
--data-raw '{
"url":"https://www.imgurl.org/static/images/logo.png"
}'
如果图片URL中含有特殊字符或参数,建议使用POST请求方式。
通过上传图片文件进行检测
curl --location --request POST 'http://localhost:6086/api/upload_check' \
--header 'Authorization: Bearer xxx' \
--form 'file=@"/Users/zhangsan/Downloads/2660b27f2e5b24ac.jpeg"'
如果启用了鉴权,请求时请添加header头:
Authorization: Bearer your_token_here
返回值
{
"code": 200,
"msg": "success",
"data": {
"sfw": 0.0014,
"nsfw": 0.9986,
"is_nsfw": true
}
}
code:状态码,200视为成功,其余状态码视为失败msg:消息提示,错误时会显示具体原因data.sfw:安全系数[0.0-1.0],值越高表示图片越安全data.nsfw:风险系数[0.0-1.0],值越高表示风险越高is_nsfw:当nsfw>=0.8时判定为色情图像,也可以自行根据nsfw分险系数判断
Demo
测试地址存在限流设置,仅供测试使用,请勿用于其它用途!
注意
此项目仅供学习和测试使用,请勿用于商业用途和生产环境,相关风险和责任需要您自行承担!
其它项目
如果您有兴趣,还可以了解我们的其他产品。
Related Skills
node-connect
385.6kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.7kCommit, push, and open a PR
