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

edge-impulse-linux

v1.11.0

Published

Node.js SDK and tools for Edge Impulse for Linux

Downloads

504

Readme

Edge Impulse Linux SDK for Node.js

This library lets you run machine learning models and collect sensor data on Linux machines using Node.js. This SDK is part of Edge Impulse where we enable developers to create the next generation of intelligent device solutions with embedded machine learning. Start here to learn more and train your first model.

Installation guide

Add the library to your application via:

$ npm install edge-impulse-linux

Collecting data

Before you can classify data you'll first need to collect it. If you want to collect data from the camera or microphone on your system you can use the Edge Impulse CLI, and if you want to collect data from different sensors (like accelerometers or proprietary control systems) you can do so in a few lines of code.

Collecting data from the camera or microphone

  1. Install the Edge Impulse CLI for Linux:

    $ npm install edge-impulse-linux -g --unsafe-perm
  2. Start the CLI and follow the instructions:

    $ edge-impulse-linux
  3. That's it. Your device is now connected to Edge Impulse and you can capture data from the camera and microphone.

Collecting data from other sensors

To collect data from other sensors you'll need to write some code where you instantiate a DataForwarder object, write data samples, and finally call finalize() which uploads the data to Edge Impulse. Here's an end-to-end example.

CLI Options

You can pass in options to the CLI. Here are the key ones:

  • --disable-camera - disables the camera.
  • --disable-microphone - disable the microphone.
  • --clean - clear credentials, and re-authenticate. Use this to switch projects or devices.
  • --api-key <apikey> - set an API key, useful for automatic authentication with a new project.
  • --greengrass - utilize the AWS IoT Greengrass authentication context and AWS Secrets Manager to authenticate with a new project. See additional Greegrass notes below.
  • --help - see all options.

Greengrass Integration Note

edge-impulse-linux and edge-impulse-linux-runner can be run as a service via a custom AWS IoT Greengrass component(s). When provided with the "--greengrass" option, both services will utilize the AWS IoT Greengrass authentication context (ONLY present when launched as a AWS IoT Greengrass custom component) as well as AWS Secrets Manager to extract the api key to be used to authenticate to a new project. If the authentication context is abscent and/or incorrect, both services will simply ignore the "--greengrass" option that was provided and continue with any of the other provided options normally.

Classifying data

To classify data (whether this is from the camera, the microphone, or a custom sensor) you'll need a model file. This model file contains all signal processing code, classical ML algorithms and neural networks - and typically contains hardware optimizations to run as fast as possible. To grab a model file:

  1. Train your model in Edge Impulse.

  2. Install the Edge Impulse CLI:

    $ npm install edge-impulse-linux -g --unsafe-perm
  3. Download the model file via:

    $ edge-impulse-linux-runner --download modelfile.eim

    This downloads the file into modelfile.eim. (Want to switch projects? Add --clean)

Then you can start classifying realtime sensor data. We have examples for:

  • Audio - grabs data from the microphone and classifies it in realtime.
  • Audio (moving average filter) - as above, but shows how to use the moving-average filter to smooth your data and reduce false positives.
  • Camera - grabs data from a webcam and classifies it in realtime.
  • Custom data - classifies custom sensor data.

Moving average filter

To smooth your results and reduce false positives there's an implementation of a moving-average filter in this library. To use it:

const { MovingAverageFilter } = require("edge-impulse-linux");

let movingAverageFilter = new MovingAverageFilter(
    4 /* filter size, smooths over X results */,
    model.modelParameters.labels);

// classify item
let res = await runner.classify(features);

// run the filter
let filteredRes = movingAverageFilter.run(res);

Development tips

Auto-reload the runner

If you're working on something in the runner, and want to auto-recompile on changes; start with:

npm run watch-runner -- "--model-file /Users/yourname/Downloads/yourmodel-v36.eim --run-http-server 1338"