[post url="https://github.com/infinitered/nsfwjs" title="NsfwJS" intro="项目地址:https://github.com/infinitered/nsfwjs" cover="https://minio-api.open.yantao.wiki:16666/blog-image/2024/10/07/6703e48c4f9ec.jpg" /]
Demo
官方Demo
const express = require('express')
const multer = require('multer')
const jpeg = require('jpeg-js')
const tf = require('@tensorflow/tfjs-node')
const nsfw = require('../../dist')
const app = express()
const upload = multer()
...
//以下省略
现成的轮子
https://registry.hub.docker.com/r/eugencepoi/nsfw_api
注意映射下80端口,比如5050:80
测试
Axios
const axios = require('axios').default
const FormData = require('form-data');
const fs = require('fs')
let config = {
headers:{'Content-Type':'multipart/form-data'}
};
let params = new FormData() ; //创建一个form对象
params.append('image',fs.createReadStream('./logo_li.png')); //append 向form表单添加数据
// 自行替换API地址
axios.post('http://127.0.0.1:5050/classify', params, config)
.then( res => {
console.log(res.data)
})Response
{
neutral: 0.9659328460693359,
porn: 0.022903073579072952,
drawing: 0.007416481617838144,
hentai: 0.0021803502459079027,
sexy: 0.0015672814333811402
}官方释义
The library categorizes image probabilities in the following 5 classes:
Drawing - safe for work drawings (including anime)
Hentai - hentai and pornographic drawings
Neutral - safe for work neutral images
Porn - pornographic images, sexual acts
Sexy - sexually explicit images, not pornography数值越高,越接近
如果在lsky图床使用nsfwjs,接口处填入http://127.0.0.1:5050/classify
免费服务
在家里的NAS上新建了一个服务,给大家免费使用:https://nsfw.open.yantao.wiki:16666/
?哲理类评语?