nsfwjs-api
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Welcome to nsfwjs-api 👋

Version Documentation Maintenance License: MIT

nsfwjs-api 鉴别 jpg、png、gif 图片

🏠 Homepage

Install

npm i nsfwjs-api

Err

1、安装报错

err

在项目根目录下创建 .npmrc 文件

TFJS_NODE_CDN_STORAGE=https://cdn.npmmirror.com/binaries/

或者

npm config set TFJS_NODE_CDN_STORAGE https://cdn.npmmirror.com/binaries/

2、运行报错

alt text

复制node_modules\@tensorflow\tfjs-node\lib\napi-v9\tensorflow.dllnode_modules\@tensorflow\tfjs-node\lib\napi-v8\tensorflow.dll

Use

js

//commonjs
// const nsfwjsApi = require( 'nsfwjs-api')

// module
import nsfwjsApi from 'nsfwjs-api';

// 是否使用本地模型 默认false
nsfwjsApi.UseModel = true;

// 模型位置 默认运行文件夹下model, UseModel为false时无效
nsfwjsApi.model = './model/';

//   copy模型文件夹, UseModel为false时无效
// 模型文件 https://github.com/infinitered/nsfwjs/tree/master/models/inception_v3
nsfwjsApi.cpModel();

// 返回的结果数(默认全部为 5)
nsfwjsApi.topk=5

// 鉴图
//  图片地址 可以是 https | http | 图片路径 | Buffer
// 图片类型 为 jpg | png | gif
nsfwjsApi
  .identificationOfPictures('./QQ截图20221116221527.gif')
  .then(result => {
    // 成功
    if (result.code === 200) {
      console.log(result.msg);
    } else {
      // 失败
      console.log(result.msg);
    }
  })
  .catch(err => {
    console.log(err);
  });

ts

import nsfwjsApi from 'nsfwjs-api';

// 是否使用本地模型 默认false
nsfwjsApi.UseModel = true;

// 模型位置 默认运行文件夹下model, UseModel为false时无效
nsfwjsApi.model = './model/';

//   copy模型文件夹, UseModel为false时无效
// 模型文件 https://github.com/infinitered/nsfwjs/tree/master/models/inception_v3
nsfwjsApi.cpModel();

// 返回的结果数(默认全部为 5)
nsfwjsApi.topk=5

// 鉴图
//  图片地址 可以是 https | http | 图片路径 | Buffer
nsfwjsApi
  .identificationOfPictures('./QQ截图20221116221527.gif')
  .then(result => {
    // 成功
    if (result.code === 200) {
      console.log(result.msg);
    } else {
      // 失败
      console.log(result.msg);
    }
  })
  .catch(err => {
    console.log(err);
  });

Author

👤 空巷一人

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2024 空巷一人.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Readme

Keywords

Package Sidebar

Install

npm i nsfwjs-api

Weekly Downloads

4

Version

2.0.1

License

MIT

Unpacked Size

22.6 MB

Total Files

12

Last publish

Collaborators

  • feiyuhao