Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
image-classifier
Advanced tools
Machine Learning Image Classifier for NodeJS
npm install image-classifier
// CommonJS
const ImageClassifier = require('image-classifier');
// Or ES Modules
import ImageClassifier from "image-classifier/lib/ImageClassifier";
ImageClassifier
from scratchconst classifier = await ImageClassifier.create()
ImageClassifier
from a datasetParameter | Description | Type | Memory |
---|---|---|---|
datasetPath | Path to load the dataset | String | True |
const classifier = await ImageClassifier.load('./dataset.json');
Parameter | Description | Type | Memory |
---|---|---|---|
datasetPath | Path to save the dataset | String | True |
await classifier.save('./carset.json');
Parameter | Description | Type | Memory |
---|---|---|---|
label | Category label for what the image is | String | True |
image | Path to image or raw image data to add as an example for the label | String | True |
// Add Toyota Examples from path
await classifier.addExample('Toyota', './toyota0.png');
await classifier.addExample('Toyota', './toyota1.png');
await classifier.addExample('Toyota', './toyota2.png');
// Add Toyota Example from raw image
const toyotaRawImage = fs.readFileSync('./toyota3.png');
await classifier.addExample('Toyota', toyotaRawImage);
/* ...Add more examples */
// Add Honda Examples
await classifier.addExample('Honda', './honda0.png');
await classifier.addExample('Honda', './honda1.png');
await classifier.addExample('Honda', './honda2.png');
// Add Honda Example from raw image
const hondaRawImage = await fs.promises.readFile('./honda3.png');
await classifier.addExample('Honda', hondaRawImage);
/* ...Add more examples */
Parameter | Description | Type | Memory |
---|---|---|---|
label | Label for classifier you would like to remove from ImageClassifier. Drops all examples of specified label. | String | True |
classifier.dropClassifier('Honda');
Parameter | Description | Type | Memory |
---|---|---|---|
image | Path to image or raw image data for evaluating a prediction with your ImageClassifier | String | True |
// Predict by image path
const prediction1 = await classifier.predict('./toyotaTest0.png');
// Predict by raw image
const toyotaTestRawImage = fs.readFileSync('./toyotaTest1.png');
const prediction2 = await classifier.predict('./toyotaTest1.png');
{
"classIndex": "<Index of Label>",
"label": "<Label>",
"confidences": {
"Toyota": "<Percentile>",
"Honda": "<Percentile>"
}
}
FAQs
Machine Learning Image Classifier for NodeJS
The npm package image-classifier receives a total of 15 weekly downloads. As such, image-classifier popularity was classified as not popular.
We found that image-classifier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.