Loading... <div class="preview"> <div class="post-inser post box-shadow-wrap-normal"> <a href="https://github.com/infinitered/nsfwjs" target="_blank" class="post_inser_a no-external-link no-underline-link"> <div class="inner-image bg" style="background-image: url(https://minio-api.open.yantao.wiki:16666/blog-image/2024/10/07/6703e48c4f9ec.jpg);background-size: cover;"></div> <div class="inner-content" > <p class="inser-title">NsfwJS</p> <div class="inster-summary text-muted"> 项目地址:https://github.com/infinitered/nsfwjs </div> </div> </a> <!-- .inner-content #####--> </div> <!-- .post-inser ####--> </div> ## Demo ### 官方Demo ```javascript 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://minio-api.open.yantao.wiki:16666/blog-image/2024/10/07/6703e5a2ebd25.gif) ### 现成的轮子 https://registry.hub.docker.com/r/eugencepoi/nsfw_api 注意映射下80端口,比如`5050:80` ## 测试 ### Axios ```javascript 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/ 最后修改:2024 年 10 月 14 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏