Skip to content

About

A fast on device AI image safety detector for React Native / Expo using a CoreML model to detect nudity and unsafe visual content in images.

Topics

Resources

Stars

39 stars

Watchers

0 watching

Forks

Repository files navigation

example

React Native NSFW Detector

A fast on device AI image safety detector for React Native / Expo using a CoreML model
to detect nudity and unsafe visual content in images.

npm version

react-native-nsfw-detector on Nick Launches

Need help building your React Native app? Connect with Adrian on X

Requirements

  • React Native 0.70+
  • iOS 13+
  • CoreML enabled environment
  • Xcode 10+ Because the model was trained with CreateML, you need Xcode 10 and above to compile the project
  • Physical iOS device strongly recommended for accurate inference (Simulator results are unreliable)

Features

  • On device inference using CoreML
  • Detects NSFW and safe for work content
  • Fast and lightweight
  • No network calls required
  • Works with React Native and Expo native modules
  • Simple promise based API

⚠️ Important: Running on the iOS Simulator results in significantly reduced accuracy. For reliable results, always test on a physical device.

Installation

Using npm

npm install react-native-nsfw-detector

Using yarn

yarn add react-native-nsfw-detector

Usage

import { checkNSFW } from 'react-native-nsfw-detector';

/**
 * IMPORTANT:
 * Simulator runs will produce significantly reduced accuracy.
 * Always test on a physical iOS device for reliable results.
 */

async function checkImage(imageUri: string) {
  const confidence = await checkNSFW(imageUri);

  if(confidence > 0.9) {
    console.log("Not safe for work 🤦‍♂️🤦‍♀️")
  } else {
    console.log("Safe! ✅")
  }
}

See the full working example Expo app here:

  • /example directory in this repo
  • Run it locally to test real CoreML inference on device

License

MIT

Author

Feel free to ask me questions on Twitter @icookandcode!

Credits

Work is based on the amazing work of NSFWDetector by the LOVOO org. See copyright notices in LICENSE.

Built with create expo module.

Contributors

Submit a PR to contribute :)

Release

We use release-it, to release do the following:

yarn run release:dry
yarn run release

Ready to build a React Native app or CoreML model?

⭐ Star this repo • 💬 Contact Adrian to Build It

Built with ❤️ by Adrian


Keywords: react-native, react, CoreML, AI, nsfw, inference, typescript, react-native-nsfw-detector, swift

About

A fast on device AI image safety detector for React Native / Expo using a CoreML model to detect nudity and unsafe visual content in images.

Topics

Resources

Stars

39 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages