新闻详情

新闻详情

首页 / 资讯中心 / 详情

node + nsfwjs 流程记录

发布时间:2026/9/12 9:30:49来源:尧图网络
node + nsfwjs 流程记录
nsfwjs是一个免费开源的图片鉴别插件本地打包尺寸过大不符合预期所以大多数人选择在服务端部署。下面是node版本部署流程笔记仅供参考node服务这里采用的是express框架Express - Node.js web application frameworknpm install express --savensfwjs代码库地址GitHub - infinitered/nsfwjs: NSFW detection on the client-side via TensorFlow.jshttps://github.com/infinitered/nsfwjs建议用管理员权限启动cmd第一步环境准备npm install --global windows-build-tools或npm install -g --production windows-build-tools以上环境准备我个人尝试了多次才执行成功若遇到失败可重试不要着急第二步依赖安装npm install nsfwjs注意下面这个安装需要翻墙里面部分引用资源在外网。大家遇到最多的问题就是这个包安装或者执行失败可尝试用cnpmnpm install tensorflow/tfjs-nodetensorflow/tfjs-node和tensorflow/tfjs两个包是互斥的删除node_modules后重试你可能会用到的包npm i tensorflow/tfjs-node-gpu相关文档tfjs/README.md at master · tensorflow/tfjs · GitHub快速删除庞大的node_modules指令rd /s /q node_modules扩展文档中推荐的另一个模式sharpOutput options - sharp - High performance Node.js image processing (pixelplumbing.com)const getMetadata async (img) { const image await sharp(img).jpeg().metadata(); const { data, info } await sharp(img) .toFormat(jpeg) .raw() .toBuffer({ resolveWithObject: true }); const numChannels 3 const numPixels image.width * image.height const values new Int32Array(numPixels * numChannels) for (let i 0; i numPixels; i) for (let c 0; c numChannels; c) values[i * numChannels c] data[i * 4 c] return tf.tensor3d(values, [image.height, image.width, numChannels], int32) } app.post(/nsfw, upload.single(image), async (req, res) { if (!req.file) res.status(400).send(Missing image multipart/form-data) else { try { const image await getMetadata(req.file.buffer) // const image await convert(req.file.buffer) const predictions await _model.classify(image) image.dispose() res.json(predictions) } catch (error) { res.status(400).send(error) } } })也可以将模型下载到项目中模型发布仓库GitHub - GantMan/nsfw_model: Keras model of NSFW detector
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

SpringBoot+Vue新农村展示平台开发与性能优化实践 2026/9/12 9:29:41

SpringBoot+Vue新农村展示平台开发与性能优化实践

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
AI科研绘图:提升效率与质量的新方案 2026/9/12 9:29:41

AI科研绘图:提升效率与质量的新方案

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
如何用 skills 的主流程 /grill-with-docs → /to-spec → /to-tickets → /implement → /code-review 完成多会话构建? 2026/9/12 9:29:41

如何用 skills 的主流程 /grill-with-docs → /to-spec → /to-tickets → /implement → /code-review 完成多会话构建?

如何用 skills 的主流程 /grill-with-docs → /to-spec → /to-tickets → /implement → /code-review 完成多会话构建? 【免费下载链接】skills Skills for Real Engineers. Straight from my .agents directory. 项目地址: https://gitcode.com/GitHub_Trendin…

阅读更多 →
AIRI 接入 LM Studio 本地模型:零 API Key 的聊天模型配置完整指南 2026/9/12 9:29:41

AIRI 接入 LM Studio 本地模型:零 API Key 的聊天模型配置完整指南

AIRI 接入 LM Studio 本地模型:零 API Key 的聊天模型配置完整指南 【免费下载链接】airi 💖🧸 Self hosted, you-owned Grok Companion, a container of souls of waifu, cyber livings to bring them into our worlds, wishing to achieve …

阅读更多 →
虚拟储能在智能楼宇中的优化应用与粒子群算法实践 2026/9/12 9:29:41

虚拟储能在智能楼宇中的优化应用与粒子群算法实践

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
STM32+RS485实战:MODBUS RTU稳定通信调试全指南 2026/9/12 9:26:41

STM32+RS485实战:MODBUS RTU稳定通信调试全指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞