{"id":36952366,"url":"https://github.com/helloxz/nsfw","last_synced_at":"2026-01-20T08:07:25.497Z","repository":{"id":327834236,"uuid":"1110276042","full_name":"helloxz/nsfw","owner":"helloxz","description":"轻量级NSFW识别方案，支持私有部署和HTTP API调用。","archived":false,"fork":false,"pushed_at":"2025-12-08T02:16:53.000Z","size":52638,"stargazers_count":87,"open_issues_count":1,"forks_count":21,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-14T00:11:15.014Z","etag":null,"topics":["nsfw","nsfw-api","nsfw-classifier","nsfw-detection","nsfwjs"],"latest_commit_sha":null,"homepage":"https://nsfw.demo.mba","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helloxz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-05T00:46:51.000Z","updated_at":"2026-01-13T04:00:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/helloxz/nsfw","commit_stats":null,"previous_names":["helloxz/nsfw"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/helloxz/nsfw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloxz%2Fnsfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloxz%2Fnsfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloxz%2Fnsfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloxz%2Fnsfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloxz","download_url":"https://codeload.github.com/helloxz/nsfw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloxz%2Fnsfw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28598875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nsfw","nsfw-api","nsfw-classifier","nsfw-detection","nsfwjs"],"created_at":"2026-01-13T12:23:00.089Z","updated_at":"2026-01-20T08:07:25.490Z","avatar_url":"https://github.com/helloxz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"中文说明 | [English](README_en.md)\n\n# helloxz/nsfw\n\n![3953634eea02b6e7.png](https://img.rss.ink/imgs/2025/12/06/3953634eea02b6e7.png)\n\n## 关于\n\n此项目基于[AdamCodd/vit-base-nsfw-detector/](https://huggingface.co/AdamCodd/vit-base-nsfw-detector/) 实现，并封装为HTTP API调用，可用于识别网络色情图像（nsfw识别），适合纯CPU机器推理，轻量级实现方案。\n\n\u003e `AdamCodd/vit-base-nsfw-detector`是基于ViT架构的保守型NSFW检测模型，能识别真实图片和绘画中的敏感内容，但对AI生成图片准确率较低。\n\n备注：xiaoz亲测能识别大多数色情图像，个人主观感觉识别准确度高于Open NSFW，但做不到100%精准（目前市面上不存在完全精准的识别方案，建议机器初审 + 人工复审）。\n\n## 特点\n\n* 纯CPU推理，适合大多数云服务器或VPS\n* 支持的图片类型：jpg/png/bmp/webp/gif\n* 支持HTTP API调用\n* 支持鉴权访问\n* 轻量级实现，资源占用相对较低\n* 识别速度较快\n* 支持Docker私有部署\n\n## 私有部署\n\n### Docker部署\n\n```bash\ndocker run -d \\\n  --name nsfw \\\n  -p 6086:6086 \\\n  --restart always \\\n  helloz/nsfw\n```\n\n### 使用Docker Compose部署（推荐）\n\n新建`docker-compose.yaml`，内容如下：\n\n```yaml\nservices:\n  nsfw:\n    container_name: nsfw\n    image: helloz/nsfw\n    ports:\n      - \"6086:6086\"\n    # 环境变量\n    environment:\n      - TOKEN=your_token_here\n      - WORKERS=1\n    restart: always\n```\n\n然后启动：`docker-compose up -d`\n\n\n### 环境变量\n\n* `TOKEN`：鉴权密钥（自行设置字符串），不设置则无需鉴权\n* `WORKERS`：进程数量，默认1，多核CPU可增加此数值\n* `WEBUI`：是否启用WEBUI，参数值为`off/on`，默认`off`不启用 \n\n## HTTP API\n\n### 传递URL检测\n\nGET请求方式（不使用鉴权）：\n\n```\ncurl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png'\n```\n\nGET请求方式（启用鉴权）：\n\n```\ncurl 'http://localhost:6086/api/url_check?url=https://www.imgurl.org/static/images/logo.png' \\\n--header 'Authorization: Bearer your_token_here'\n```\n\nPOST请求方式：\n\n```\ncurl --location --request POST 'http://localhost:6086/api/url_check' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"url\":\"https://www.imgurl.org/static/images/logo.png\"\n}'\n```\n\n\u003e 如果图片URL中含有特殊字符或参数，建议使用POST请求方式。\n\n### 通过上传图片文件进行检测\n\n```\ncurl --location --request POST 'http://localhost:6086/api/upload_check' \\\n--header 'Authorization: Bearer xxx' \\\n--form 'file=@\"/Users/zhangsan/Downloads/2660b27f2e5b24ac.jpeg\"'\n```\n\n\u003e 如果启用了鉴权，请求时请添加header头：`Authorization: Bearer your_token_here`\n\n### 返回值\n\n```json\n{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": {\n        \"sfw\": 0.0014,\n        \"nsfw\": 0.9986,\n        \"is_nsfw\": true\n    }\n}\n```\n\n* `code`：状态码，200视为成功，其余状态码视为失败\n* `msg`：消息提示，错误时会显示具体原因\n* `data.sfw`：安全系数`[0.0-1.0]`，值越高表示图片越安全\n* `data.nsfw`：风险系数 `[0.0-1.0]`，值越高表示风险越高\n* `is_nsfw`：当`nsfw\u003e=0.8`时判定为色情图像，也可以自行根据`nsfw`分险系数判断\n\n### Demo\n\n* 测试地址：[https://nsfw.demo.mba](https://nsfw.demo.mba)\n\n\u003e 测试地址存在限流设置，仅供测试使用，请勿用于其它用途！\n\n## 注意\n\n此项目仅供学习和测试使用，请勿用于商业用途和生产环境，相关风险和责任需要您自行承担！\n\n## 其它项目\n\n如果您有兴趣，还可以了解我们的其他产品。\n\n* [Zdir](https://www.zdir.pro/zh/) - 一款轻量级、多功能的文件分享程序。\n* [OneNav](https://www.onenav.top/) - 高效的浏览器书签管理工具，将您的书签集中式管理。\n* [Zurl](https://github.com/helloxz/zurl) - Zurl 是一款简单且实用的短链接系统，可以快速生成短链接，方便分享和管理。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloxz%2Fnsfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloxz%2Fnsfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloxz%2Fnsfw/lists"}