Linux Node.js SDK

This library lets you run machine learning models and collect sensor data on Linux machines using Node.js. The SDK is open source and hosted on GitHub: edgeimpulse/edge-impulse-linux-cli.

Installation guide

Add the library to your application via:

$ npm install edge-impulse-linux

Configuration

To setup the parameters of the Edge Impulse CLI, have a look at the helper:

edge-impulse-linux --help     
Usage: edge-impulse-linux [options]

Edge Impulse Linux client 1.4.3

Options:
  -V, --version         output the version number
  --api-key <key>       API key to authenticate with Edge Impulse (overrides current credentials)
  --hmac-key <key>      HMAC key to sign new data with (overrides current credentials)
  --disable-camera      Don't prompt for camera
  --disable-microphone  Don't prompt for microphone
  --width <px>          Desired width of the camera stream
  --height <px>         Desired height of the camera stream
  --clean               Clear credentials
  --silent              Run in silent mode, don't prompt for credentials
  --dev                 List development servers, alternatively you can use the EI_HOST environmental variable to specify the Edge Impulse instance.
  --verbose             Enable debug logs
  -h, --help            output usage information

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

To collect data from the camera or microphone, follow the getting started guide for your development board.

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.

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. 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.

  • Camera - grabs data from a webcam and classifies it in realtime.

  • Custom data - classifies custom sensor data.

edge-impulse-linux-runner --help
Usage: edge-impulse-linux-runner [options]

Edge Impulse Linux runner 1.3.12

Options:
  -V, --version            output the version number
  --model-file <file>      Specify model file (either path to .eim, or the socket on which
                           the model is running), if not provided the model will be fetched
                           from Edge Impulse
  --api-key <key>          API key to authenticate with Edge Impulse (overrides current
                           credentials)
  --download <file>        Just download the model and store it on the file system
  --force-target <target>  Do not auto detect the target system, but set it by hand
  --clean                  Clear credentials
  --silent                 Run in silent mode, don't prompt for credentials
  --quantized              Download int8 quantized neural networks, rather than the float32
                           neural networks. These might run faster on some architectures,
                           but have reduced accuracy.
  --enable-camera          Always enable the camera. This flag needs to be used to get data
                           from the microphone on some USB webcams.
  --dev                    List development servers, alternatively you can use the EI_HOST
                           environmental variable to specify the Edge Impulse instance.
  --verbose                Enable debug logs
  -h, --help               output usage information

Last updated