A JavaScript library for client-side NSFW image detection using TensorFlow.js.
NSFWJS is a JavaScript library that detects Not Safe For Work (NSFW) images directly in the browser or Node.js using TensorFlow.js. It classifies images into categories like 'Drawing', 'Hentai', 'Neutral', 'Porn', and 'Sexy' to help filter inappropriate content without server-side processing.
Frontend and full-stack developers building applications that require client-side content moderation, such as social platforms, chat apps, or image upload systems where user privacy is a priority.
Developers choose NSFWJS because it offers accurate (~90-93%) NSFW detection entirely on the client side, eliminating the need to send sensitive images to external servers, reducing latency, and enhancing user privacy.
NSFW detection on the client-side via TensorFlow.js
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Processes images entirely in the browser using TensorFlow.js, ensuring user data never leaves the device, which is ideal for privacy-sensitive applications like chat apps or social platforms.
Offers multiple pre-trained models (MobileNetV2, InceptionV3) with accuracy up to 93%, allowing developers to trade off between model size and performance based on their needs.
Works in browsers, React Native, and Node.js with support for various backends like WebGL, WebGPU, and WASM, making it versatile for different deployment environments.
Includes model caching via IndexedDB and tree-shaking for selective bundling, reducing app size and improving load times as demonstrated in the README examples.
The README admits it's 'not perfect' with ~90-93% accuracy, which can lead to false positives/negatives unsuitable for critical moderation tasks like legal compliance or high-stakes filtering.
Default hosted models are unreliable (noted in the 'NOTE' section), forcing self-hosting and increasing bundle size—e.g., MobileNetV2 is 3.5MB when bundled, impacting initial load times.
Requires managing TensorFlow.js as a peer dependency and backend selection (WebGL, WASM, etc.), adding setup complexity and performance tuning challenges, especially for beginners.