You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
treewide: Add documentation for hello_ei sample and Edge Impulse
- Add README for edge_impulse/hello_ei sample.
- Make changes in doc/integrations/edge_impulse.rst related to
change of form of deployment EI models (use of EI SDK module).
- Add section about usage of EI west extension commands.
Jira: NCSDK-37082
Signed-off-by: Bartosz Meus <bartosz.meus@nordicsemi.no>
Copy file name to clipboardExpand all lines: doc/integrations/edge_impulse.rst
+93-20Lines changed: 93 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Edge Impulse integration
8
8
:depth: 2
9
9
10
10
`Edge Impulse`_ is a development platform that can be used to enable `embedded machine learning`_ on |NCS| devices.
11
-
You can use this platform to collect data from sensors, train machine learning model, and then deploy it to your Nordic Semiconductor's device.
11
+
You can use this platform to collect data from sensors, train a machine learning model, and then deploy it to your Nordic Semiconductor's device.
12
12
13
13
Integration prerequisites
14
14
*************************
@@ -19,16 +19,25 @@ Before you start the |EAI| integration with Edge Impulse, make sure that the fol
19
19
* Setup of the required Development Kit (DK).
20
20
* Creation of an `Edge Impulse studio account <Edge Impulse studio signup_>`_ and an Edge Impulse project.
21
21
22
+
Solution architecture
23
+
*********************
24
+
25
+
The usage of `Edge Impulse`_ SDK is demonstrated by the :ref:`hello_ei_sample`.
26
+
22
27
Integration overview
23
28
********************
24
29
25
30
Before integrating the Edge Impulse machine learning model into an |EAI| application, you must prepare and deploy the machine learning model for your embedded device.
26
31
This model is prepared using the `Edge Impulse studio`_ external web tool.
27
32
It relies on sensor data that can be provided by different sources, for example data forwarder.
28
-
Check the :ref:`ei_data_forwarder_sample` sample for a demonstration of how you can send sensor data to Edge Impulse studio using `Edge Impulse's data forwarder`_.
29
33
30
-
The machine learning model is distributed as a single :file:`zip` archive that includes C++ library sources.
31
-
This file is used by the |NCS| build system to build the Edge Impulse library.
34
+
.. note::
35
+
You can use one of the development boards supported directly by Edge Impulse or your mobile phone to collect the data.
36
+
You can also modify the :ref:`ei_data_forwarder_sample` sample and use it to forward data from a sensor that is connected to any board available in the |NCS|.
37
+
38
+
The machine learning model is distributed as a single :file:`zip` archive that includes C/C++ machine learning model sources.
39
+
These files have to be included to an |EAI| application.
40
+
Apart from that, the application must also enable the `Edge Impulse`_ SDK (see: :ref:`ug_edge_impulse_building`).
32
41
33
42
Integration steps
34
43
*****************
@@ -45,46 +54,110 @@ Complete the following steps to generate the archive and add it to the build sys
45
54
Preparing the machine learning model
46
55
====================================
47
56
48
-
To prepare the machine learning model, use `Edge Impulse studio`_ and follow one of the tutorials described in `Edge Impulse getting started guide`_.
49
-
For example, you can try the `Continuous motion recognition tutorial`_.
50
-
This tutorial will guide you through the following steps:
57
+
1. Prepare your own machine learning model.
51
58
52
-
1. Collecting data from sensors and uploading the data to Edge Impulse studio.
59
+
To prepare a machine learning model, use `Edge Impulse studio`_ and follow one of the tutorials described in `Edge Impulse getting started guide`_.
60
+
For example, you can try the `Continuous motion recognition tutorial`_.
61
+
This tutorial will guide you through the following steps:
53
62
54
-
.. note::
55
-
You can use one of the development boards supported directly by Edge Impulse or your mobile phone to collect the data.
56
-
You can also modify the :ref:`ei_data_forwarder_sample` application and use it to forward data from a sensor that is connected to any board available in the |NCS|.
63
+
* Collecting data from sensors and uploading the data to Edge Impulse studio.
64
+
65
+
* Designing your machine learning model (an *impulse*).
66
+
67
+
#. Deploy your machine learning model to use it on an embedded device.
68
+
69
+
You can obtain a library in two ways:
70
+
71
+
.. tabs::
72
+
73
+
.. group-tab:: Using |EIS| web interface
74
+
75
+
Go to the :guilabel:`Deployment` tab and select **Zephyr library** to generate a :file:`zip` file that contains source files defining the |EI| ML model.
76
+
The download of the :file:`zip` archive will start automatically.
77
+
78
+
.. figure:: ./images/ei_deploy.png
79
+
:scale:50 %
80
+
:alt:Model deployment in |EIS| dashboard
81
+
82
+
Model deployment in |EIS| dashboard
83
+
84
+
.. note::
85
+
There are different forms of deployment available, which can also be compatible with |NCS| applications, but this instruction focuses on presenting the Zephyr library form of deployment.
86
+
87
+
.. group-tab:: Using |EI| west extensions
88
+
89
+
|EI| provides west command extensions which can be used to build and deploy the machine learning model from |EIS| using the command line instead of the web interface.
90
+
The commands are already configured in the |EAI| west manifest and ready to use.
91
+
There are two commands available:
92
+
93
+
* ``west ei-build`` - builds the machine learning model in |EIS|,
94
+
* ``west ei-deploy`` - deploys a model in the form of a zip file and downloads it from |EIS|.
57
95
58
-
#. Designing your machine learning model (an *impulse*).
59
-
#. Deploying the machine learning model to use it on an embedded device.
60
-
As part of this step, you must select the :guilabel:`C++ library` to generate the required :file:`zip` file that contains the source files for building the Edge Impulse library in |EAI|.
96
+
Follow these steps to use the commands:
97
+
98
+
1. Find two parameters that are required by the commands:
99
+
100
+
* **Project ID** - You can find it in the **Project info** panel under :guilabel:`Dashboard`.
101
+
102
+
.. figure:: ./images/ei_project_id.png
103
+
:scale:50 %
104
+
:alt:Project ID in |EIS| dashboard
105
+
106
+
Project ID in |EIS| dashboard
107
+
108
+
* **API key** - You can find it under the :guilabel:`Keys` tab in the |EI| project dashboard.
109
+
110
+
.. figure:: ./images/ei_api_key.png
111
+
:scale:50 %
112
+
:alt:API key under the Keys tab in |EIS|
113
+
114
+
API key under the Keys tab in |EIS|
115
+
116
+
#. Build the machine learning model by running the following command:
117
+
118
+
.. code-block:: console
119
+
120
+
west ei-build -p <PROJECT_ID> -k <API_KEY>
121
+
122
+
#. Deploy the machine learning model by running the following command:
123
+
124
+
.. code-block:: console
125
+
126
+
west ei-deploy -p <PROJECT_ID> -k <API_KEY>
127
+
128
+
As a result, file :file:`ei_model.zip` is downloaded to the current working directory.
129
+
130
+
More details about usage of these commands are described in `Automated Deployment with West Commands`_.
61
131
62
132
.. _ug_edge_impulse_adding_building:
63
133
64
134
.. rst-class:: numbered-step
65
135
66
-
Building the machine learning model in |EAI|
67
-
============================================
136
+
Building an application with machine learning model
.. _`Automated Deployment with West Commands`: https://docs.edgeimpulse.com/hardware/deployments/run-zephyr-module#automated-deployment-with-west-commands-early-access-preview
The Hello Edge Impulse sample demonstrates usage of `Edge Impulse`_ SDK and custom machine learning model when :ref:`integrating Edge Impulse with the nRF Connect SDK <edge_impulse_integration>`.
11
+
12
+
Requirements
13
+
************
14
+
15
+
The sample supports the following development kits:
16
+
17
+
.. table-from-sample-yaml::
18
+
19
+
Overview
20
+
********
21
+
22
+
The sample:
23
+
24
+
1. Provides input data to the `Edge Impulse`_ model.
25
+
#. Starts predictions using the machine learning model.
26
+
#. Displays the prediction results and time measurements to the user.
27
+
28
+
By default, the sample uses a pre-trained machine learning model and 2 input data series representing a sine wave and a triangle wave with some noise added.
29
+
30
+
Configuration
31
+
*************
32
+
33
+
|config|
34
+
35
+
The sample can be configured using the following Kconfig options:
36
+
37
+
.. options-from-kconfig::
38
+
:show-type:
39
+
40
+
Using your own machine learning model
41
+
=====================================
42
+
43
+
To run the sample using a custom machine learning model, you must complete the following setup:
44
+
45
+
1. :ref:`Train and deploy your own machine learning model <ug_edge_impulse_adding_preparing>`.
46
+
Use a **Zephyr library** form of deployment described in the instructions.
47
+
48
+
#. Select the Edge Impulse model.
49
+
50
+
Set the ``CONFIG_EDGE_IMPULSE_PATH`` to an absolute or relative path to a file in the local filesystem.
51
+
The file must be a :file:`zip` archive generated by |EIS| containing the source files defining the Edge Impulse ML model.
52
+
The relative path is tracked from the application source directory (``APPLICATION_SOURCE_DIR``).
53
+
CMake variables that are part of the path are expanded.
54
+
55
+
#. Define input data for the machine learning model in :file:`samples/edge_impulse/hello_ei/src/include/input_data.h`.
56
+
#. Check the example input data in your |EIS| project:
57
+
58
+
a. Go to the :guilabel:`Live classification` tab.
59
+
#. In the **Classify existing test sample** panel, select one of the test samples.
60
+
#. Click :guilabel:`Load sample` to display the raw data preview.
61
+
62
+
.. figure:: ./doc/images/ei_load_test_sample.png
63
+
:scale:50 %
64
+
:alt:Loading test sample input data in |EIS|
65
+
66
+
Loading test sample input data in |EIS|
67
+
68
+
The classification results will be displayed, with raw data preview.
69
+
70
+
.. figure:: ./doc/images/ei_raw_features.png
71
+
:scale:50 %
72
+
:alt:Raw data preview in |EIS|
73
+
74
+
Raw data preview in |EIS|
75
+
76
+
#. Copy information from the **Raw features** list into an array defined in the :file:`input_data.h` file.
77
+
78
+
.. note::
79
+
If you provide more input data than a single input window can hold, the prediction will be triggered multiple times.
80
+
The input window will be shifted by one input frame between subsequent predictions.
81
+
The prediction will be retriggered until there is no more input data available.
0 commit comments