How to use nsfwjs - 3 common examples

To help you get started, we’ve selected a few nsfwjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infinitered / nsfwjs / example / nsfw_demo / src / App.js View on Github external
componentDidMount() {
    // Load model from public
    nsfwjs.load('/model/').then(model => {
      this.setState({
        model,
        titleMessage: dragMessage,
        message: 'Ready to Classify',
        loading: false
      })
    })
  }
github CleanDC / CleanDC / src / background.js View on Github external
async function nsfw () {
  const model = await require('nsfwjs').load(chrome.extension.getURL('assets/nsfw/'))
  Message.listen('nsfw', async (pl, sdr, res) => {
    const image = new Image()
    image.src = pl
    try {
      await new Promise((onload, onerror) => Object.assign(image, { onload, onerror })) // eslint-disable-line promise/param-names
      res(await model.classify(image))
    } catch (e) {
      res(null)
    }
  })
}
nsfw()

nsfwjs

Detect NSFW content client-side

MIT
Latest version published 10 days ago

Package Health Score

84 / 100
Full package analysis

Popular nsfwjs functions