react-native-nsfw-detector
v1.0.1
Published
React Native module for detecting NSFW images using an on device AI model.
Maintainers
Readme
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-detectorUsing yarn
yarn add react-native-nsfw-detectorUsage
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
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 releaseReady 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
