npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@safekids-ai/nlp-js-react-native

v0.0.4

Published

Safekids NLP Node

Downloads

4

Readme

Machine Learning Models to Detect Hate Speech and Adult/Weapon Images and User Intent

These are local models (12MB/5MB) that detect hate speech and more and vision models that detect adult images and images of weapons.

The models can be run on node or on the browser. SDK's are available for Python, JAVA, Node and in-the-browser that can be leverage by a chrome extension.

Install

npm install

Build/Test

npx nx run-many -t test,build

Release Management

npm run release

Publish

npx nx run-many --target=publish --projects=nlp-js-common,nlp-js-node,nlp-js-react-native,vision-js-common,vision-js-node,vision-js-web,ml-demo --parallel=false

NLP and Vision Classification

| NLP Classification | Vision Classification | | ------------------ |-----------------------| | bullying_hate | porn | | porn | weapons | | proxy | clean ß | | self_harm | | | weapons | | | clean | |

Model Accuracy

| Label | Training Data Count | Test Data Count | f1 score | precision | recall | |---|---|---|---|---|---| | bullying_hate | 96,523 | 7,500 | 0.97 | 0.991 | 0.949 | | clean | 1,351,563 | 20,000 | 0.98 | 0.99 | 0.9702 | | porn | 300,082 | 6,500 | 0.97 | 0.993 | 0.948 | | proxy | 8,038 | 200 | 0.94 | 0.988 | 0.896 | | self_harm | 180,826 | 5,000 | 0.96 | 0.984 | 0.937 | | weapons | 74,802 | 4,000 | 0.96 | 0.989 | 0.932 |

Glossary of Terms

API Reference

Run the text classification model in node

//initialize the model
import {NLPNode} from '@safekids-ai/nlp-js-node'

nlp = new NLPNode("nlp.onnx");
await nlp.init();

//run the hate classifier
expect(await nlp.findHate("I love samosa. Mike is an asshole. Safekids is awesome!"))
    .toEqual({flag: true, label: 'hate_bullying', flaggedText: 'Mike is an asshole.'});

//text classification
expect(await nlp.classifyText("Darrell Brooks' mother wants to 'curl up and die' after verdict | FOX6 News Milwaukee"))
    .toEqual("clean");

expect(await nlp.classifyText("I want to kill myself | Samaritans"))
    .toEqual("self_harm");

expect(await nlp.classifyText("Milf Porn Videos: Mature Mom Sex Videos - RedTube.com"))
    .toEqual("porn");

Run the image classification model in node

import {VisionNode} from '@safekids-ai/vision-js-node'
vision = new VisionNode("vision.onnx");
await vision.init();
const buffer: ImageData = getSync(qa_path + "gun1.jpg");
const pred = await vision.classifyImageData(buffer);
expect(pred).toEqual("weapons");

Run the text classification directly in the browser!

import {NLPWeb} from '@safekids-ai/nlp-js-react-native'
//initialize the model
nlp = new NLPWeb("nlp.onnx");
await nlp.init();

Run the image classification model directly in the browser or used in chrome extension

import {VisionWeb} from '@safekids-ai/vision-js-web'
vision = new VisionWeb("vision.onnx");
await vision.init();

Run the text and image classification model in Python

from safekids import SafeText
safe_text_classifier = SafeText()
safe_text_classifier.classify("text to classify")
from safekids import SafeImage
safe_image_classifier = SafeImage
safe_image_classifier.classify("path_to_image")

License

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en