x-dr / nsfwjs-api

nsfw detector api with tensorflow + nsfwjs + express
MIT License
33 stars 16 forks source link
nsfwjs nsfwjs-api

1. 项目介绍

本项目是基于NSFWJS的图片鉴黄,使用了[NSFWJS]()提供的预训练模型。

本文由GitHub Copilot 生成

2. 项目部署

2.1. docker部署

  1. 下载docker镜像
docker pull gindex/nsfwjs-api:latest
  1. 运行容器
docker run -itd \
           --name nsfwjs \
            -p 3035:3035 \
           --restart=always \
           gindex/nsfwjs-api:latest
  1. 访问地址
http://ip:3035/

2.2. 本地部署

  1. 安装nodejs(如果已经安装过nodejs则跳过此步骤)

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt update -y
sudo apt-get install -y nodejs
  1. 安装git (如果已经安装过git则跳过此步骤)
sudo apt-get install git
  1. 下载项目
git clone https://github.com/x-dr/nsfw-api.git
  1. 安装依赖
npm install
npm rebuild @tensorflow/tfjs-node --build-from-source
  1. 运行项目
npm run start
  1. 进程守护
npm install -g pm2
npm start pm2.json

npm stop nsfw-api #暂停
npm restart nsfw-api #重启
  1. 访问地址
http://ip:3035/

2.3. vercel部署

The Serverless Function "index.js" is 111.7mb which exceeds the maximum size limit of 50mb.

2.4. heroku部署

Deploy

3. 响应

{
  "Neutral": 0.9852375388145447,  
  "Drawing": 0.007717587053775787,
  "Porn": 0.0043180412612855434,
  "Hentai": 0.002539177890866995,
  "Sexy": 0.00018772167095448822,
  "url": "url",
  "status": 200,
  "rating": 1
}