Edge Impulse: Wrapper

The Edge Impulse wrapper sample demonstrates the functionality of the Edge Impulse wrapper. It shows how to use the wrapper to run a custom Edge Impulse machine learning model when Using Edge Impulse with nRF Connect SDK.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160ns

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

Overview

The sample:

  1. Initializes the Edge Impulse wrapper.

  2. Provides input data to the wrapper.

  3. Starts predictions using the machine learning model.

  4. Displays the prediction results to the user.

Configuration

See Configuring your application for information about how to permanently or temporarily change the configuration.

Setup

Before running the sample, you must complete the following setup:

  1. Configure the Edge Impulse wrapper by completing the following steps:

    1. Prepare your own machine learning model using Edge Impulse studio.

    2. Set the CONFIG_EDGE_IMPULSE_URI to URI of your machine learning model.

    See the Edge Impulse wrapper page for detailed configuration steps.

  2. Define the input data for the machine learning model in samples/ei_wrapper/src/include/input_data.h.

  3. Check the example input data in your Edge Impulse studio project:

    1. Go to the Live classification tab.

    2. In the Classifying existing test sample panel, select one of the test samples.

    3. Press Load sample to display the raw data preview.

      Loading test sample input data in Edge Impulse studio

      Loading test sample input data in Edge Impulse studio

      The classification results will be displayed, with raw data preview.

      Raw data preview in Edge Impulse studio

      Raw data preview in Edge Impulse studio

  4. Copy information from the Raw features list into an array defined in the input_data.h file.

Note

If you provide more input data than a single input window can hold, the prediction will be triggered multiple times. The input window will be shifted by one input frame between subsequent predictions. The prediction will be retriggered until there is no more input data.

Building and running

This sample can be found under samples/ei_wrapper in the nRF Connect SDK folder structure.

See Building and programming a sample application for information about how to build and program the application.

Testing

After programming the sample to your development kit, test it by performing the following steps:

  1. Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

  2. Reset the kit.

  3. Observe that output similar to the following is logged on UART:

    * Booting Zephyr OS build v2.4.0-ncs1-3484-g21046b8cdb4e  *
    Prediction started...
    
    Classification results
    ======================
    Label: updown
    Value: 1.00
    Anomaly: 0.47

The observed classification results depend on machine learning model and input data.

Dependencies

This sample uses the following nRF Connect SDK subsystems: