Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
image-classifier
Advanced tools
Machine Learning Image Classifier for NodeJS
Library : npm install image-classifier
CLI : npm install -g image-classifier
Create a new ImageClassifier with a dataset path for saving and loading your dataset. You can also specify to autosave to save every time you add a new example
const { ImageClassifier } = require('image-classifier');
const MyClassifier = new ImageClassifier('./mynewdataset.json', true);
Parameter | Description | Type | Mandatory |
---|---|---|---|
dataset | Path to dataset | String | True |
autosave | Autosave dataset after adding a example (default: True) | Boolean | False |
Load should always be called before any further implementation. Will attempt to load dataset if the dataset path already exists
MyClassifier.load().then(async function() {
/* Add Examples here */
});
Add example data for training a new model
// Add Toyota Exampless
await MyClassifier.addExample('Toyota', './toyota0.png');
await MyClassifier.addExample('Toyota', './toyota0.png');
await MyClassifier.addExample('Toyota', './toyota0.png');
/* ...Add more examples */
// Add Honda Examples
await MyClassifier.addExample('Honda', './honda0.png');
await MyClassifier.addExample('Honda', './honda1.png');
await MyClassifier.addExample('Honda', './honda2.png');
/* ...Add more examples */
Parameter | Description | Type | Mandatory |
---|---|---|---|
label | Category label for what the image is | String | True |
image | Path to image to add as an example for label | String | True |
Get a classification prediction of image passed in
const prediction = await MyClassifier.predict('./toyotaTest0.png');
/* Prediction
{
"classIndex": <Index of Label>,
"label": <Label>,
"confidences": {
"Toyota": <Percentile>,
"Honda": <Percentile>
}
}
*/
Parameter | Description | Type | Mandatory |
---|---|---|---|
image | Path to image for evaluating a prediction with your ImageClassifier | String | True |
Remove all examples of specified label
MyClassifier.dropClassifier('Honda');
Parameter | Description | Type | Mandatory |
---|---|---|---|
label | Label for classifier you would like to remove from ImageClassifier. Drops all examples of specified label. | String | True |
Save dataset manually to dataset path passed from the constructor
await MyClassifier.save();
WARNING: STILL IN BETA v1.0.0 |
---|
Save a dataset
train -s <someurl|somefile> <title.json>
Export a dataset
train -e <somedataset.json> <newlocation.json>
Delete a dataset in your saved datasets
train -d <somedataset.json>
List all saved datasets
train -l
Identify an image with a saved dataset
train -i <someimage.png> <somedataset.json>
Help menu will be brought up if none of the above flags are included
Usage: train [options] <values>
Options:
-s, --save : Save a dataset
-e, --export : Export a dataset
-d, --delete : Delete a dataset
-l, --list : List all saved datasets
-i, --identify : Identify an image with a dataset
-h, --help : Open help menu
Examples:
train -s https://dataset.example.com/dataset.json example-dataset.json
train -e example-dataset.json ./testing/new-example-dataset.json
train -i cat.png example-dataset.json
train -d example-dataset.json
FAQs
Machine Learning Image Classifier for NodeJS
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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.