Edge Impulse Docs

Edge Impulse Documentation

Welcome to the Edge Impulse documentation. You'll find comprehensive guides and documentation to help you start working with Edge Impulse as quickly as possible, as well as support if you get stuck. Let's jump right in!

Through WebAssembly (other programming languages)

Impulses can be deployed as a WebAssembly library. This packages all your signal processing blocks, configuration and learning blocks up into a single package. You can include this package in web pages, or as part of your Node.js application. In this tutorial you'll export an impulse as a C++ library, build a standalone WebAssembly package to classify sensor data and load it with the programming language of your choice thanks to Wasmer.


Make sure you followed the Continuous motion recognition tutorial, and have a trained impulse. Also install the following software:

  • Wasienv. Wasienv currently supports Linux and macOS, Windows users can use the Docker image instead.
  • Wasmer standalone runtime to execute the WebAssembly package.

Cloning the base repository

We created an example repository which contains a Makefile and a small CLI example application, which takes the raw features as an argument, and prints out the final classification. Clone or download this repository at example-standalone-inferencing-wasm.

Deploying your impulse

Head over to your Edge Impulse project, and go to Deployment. From here you can create the full library which contains the impulse and all external required libraries. Select C++ library and then click Build to create the library.

Download the .zip file and place the contents in the 'example-standalone-inferencing-wasm' folder (which you downloaded above). Your final folder structure should look like this:

|_ Makefile
|_ README.md
|_ build.sh
|_ edge-impulse-sdk
|_ model-parameters
|_ source
|_ tflite-model

Then, open a terminal or command prompt, and build the project:

$ sh build.sh

This will first build the inferencing engine, and then build the complete application. After building succeeded you should have a WebAssembly file in build/edge-impulse-standalone.wasm.

Running the impulse

With the project ready it's time to verify that the application works. Head back to the studio and click on Live classification. Then load a validation sample, and click on a row under 'Detailed result'.

Selecting the row with timestamp '240' under 'Detailed result'.

To verify that the local application classifies the same, we need the raw features for this timestamp. To do so click on the 'Copy to clipboard' button next to 'Raw features'. This will copy the raw values from this validation file, before any signal processing or inferencing happened.

Copying the raw features

Then invoke wasmer to execute the WebAssembly package by passing these features as an argument to the application. Open a terminal or command prompt and run:

wasmer build/edge-impulse-standalone.wasm -- "3.7649, 0.4960, 4.4436, 1.9841, 1.2292, 4.4643, ..."

This will run the signal processing pipeline, and then classify the output:

Running neural network...
Predictions (time: 0 ms.):
idle:   0.000000
snake:  0.925105
updown: 0.027744
wave:   0.047151
Anomaly score (time: 0 ms.): 0.037895
run_classifier returned: 0
Begin output
[0.00000, 0.92510, 0.02774, 0.04715, 0.038]
End output

Which matches the values we just saw in the studio.

Language integration

Wasmer has integrations with several programming languages such as Rust, Python or Go. Below is an example Python application to run your WebAssembly package.

First install wasmer libraries:

pip3 install wasmer wasmer_compiler_cranelift

Then copy the following code:

from wasmer import engine, wasi, Store, Module, Instance
from wasmer_compiler_cranelift import Compiler

# copy your raw features here
raw_features = '7.0969, -9.4332, -3.8981, 9.6361, ...'

# Let's define the store, that holds the engine, that holds the compiler.
store = Store(engine.JIT(Compiler))

# Let's compile the module to be able to execute it!
module = Module(store, open('build/edge-impulse-standalone.wasm', 'rb').read())

wasi_version = wasi.get_version(module, strict=True)

wasi_env = wasi.StateBuilder('wasi-impulse'). \
        argument(raw_features). \

# From the WASI environment, we generate a custom import object.
import_object = wasi_env.generate_import_object(store, wasi_version)

# Now we can instantiate the module.
instance = Instance(module, import_object)


Finally run the Python script:

python3 wasm-example.py

It outputs the same classification results as with wasmer command line:

Running neural network...
Predictions (time: 0 ms.):
idle:   0.000000
snake:  0.925105
updown: 0.027744
wave:   0.047151
Anomaly score (time: 0 ms.): 0.037895
run_classifier returned: 0
Begin output
[0.00000, 0.92510, 0.02774, 0.04715, 0.038]
End output

You now have your impulse running locally using your favorite programming language!

Updated about a month ago

Through WebAssembly (other programming languages)

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.