New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

image-classifier

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-classifier

Machine Learning Image Classifier for NodeJS

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-48.15%
Maintainers
1
Weekly downloads
 
Created
Source

Image Classifier NodeJS Package

Machine Learning Image Classifier for NodeJS

Installation

Library : npm install image-classifier

CLI : npm install -g image-classifier


ImageClassifier

Get Started

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', false);
ParameterDescriptionTypeMandatory
datasetPath to datasetStringTrue
autosaveAutosave dataset after adding a example (default: True)BooleanFalse

Load (Async)

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 (Async)

Add example data for training a new model

    // Add Toyota Exampless
    await MyClassifier.addExample('Toyota', './toyota0.png');
    await MyClassifier.addExample('Toyota', './toyota1.png');
    await MyClassifier.addExample('Toyota', './toyota2.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 */
ParameterDescriptionTypeMandatory
labelCategory label for what the image isStringTrue
imagePath to image to add as an example for labelStringTrue

Predict (Async)

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>
            }
        }
    */
ParameterDescriptionTypeMandatory
imagePath to image for evaluating a prediction with your ImageClassifierStringTrue

Drop Classifier (Sync)

Remove all examples of specified label

    MyClassifier.dropClassifier('Honda');
ParameterDescriptionTypeMandatory
labelLabel for classifier you would like to remove from ImageClassifier. Drops all examples of specified label.StringTrue

Save (Async)

Save dataset manually to dataset path passed from the constructor

    await MyClassifier.save();

train

WARNING: STILL IN BETA v1.0.0

Save

Save a dataset

train -s <someurl|somefile> <title.json>

Export

Export a dataset

train -e <somedataset.json> <newlocation.json>

Delete

Delete a dataset in your saved datasets

train -d <somedataset.json>

List

List all saved datasets

train -l

Identify

Identify an image with a saved dataset

train -i <someimage.png> <somedataset.json>

Help

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

Contributions

Keywords

FAQs

Package last updated on 04 Mar 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc