Difference: CExamples (1 vs. 6)

Revision 62023-11-08 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

Line: 17 to 17
  tflite_examples_arduino.png
Changed:
<
<
Attention: When using Serial.print on the LoLin ESP32S3 mini, you must set the option USB CDC on boot to enabled! Oherwise you will not see any output on the Serial monitor.
>
>
Attention: When using Serial.print on the LoLin ESP32S3 mini, you must set the option USB CDC on boot to enabled! The option is found in the Tools menu. Oherwise you will not see any output on the Serial monitor.
 

The Hello World test programs

Three test programs are available:

Revision 52023-11-08 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

Line: 16 to 16
 
  • ... and even some older version of magic wand, which is not available elsewhere

tflite_examples_arduino.png

Added:
>
>
Attention: When using Serial.print on the LoLin ESP32S3 mini, you must set the option USB CDC on boot to enabled! Oherwise you will not see any output on the Serial monitor.
 

The Hello World test programs

Three test programs are available:

Revision 42023-09-08 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

Line: 6 to 6
 
  • use thee Espressif esp-idf build system
  • use the Arduino IDE
  • use the MicroPython interface to TensorFlow MicroPython Examples
Added:
>
>
The test programs allowing to test the model before deploying it to the target processor can be found in the TensorFlow Lite Micro repository.
 

Arduino

For the Arduino SDK (Software Development Kit) you can install the TensorFlowLite_ESP32 library, which does not only contain the TensforFlowLite library but also the examples

Line: 15 to 16
 
  • ... and even some older version of magic wand, which is not available elsewhere

tflite_examples_arduino.png

Added:
>
>

The Hello World test programs

Three test programs are available:

  • hello_world_test.cc
  • evaluate.py
  • evaluate_test.py
These programs are built using the bazel build tool. In order tto build hello_world_test.cc, got to the base directory of TensorFlow Lite Micro directory and enter the commands. First the hello_world_test binary must be built from its source:

hello_world_test_build.png

before the program can be run:

hello_world_test_run.png

For a detailed analysis of the test program please set analysis cc test

 

The Hello World application with esp-idf

Let's start with the hello_world example. This example uses a pre-built model that has gone through the training process and it has been quantized to reduce its size such that it can be loaded into the small micro-controller memory. Building, training and quantization is described at https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world.

Line: 51 to 72
 
META FILEATTACHMENT attachment="results.png" attr="" comment="" date="1693664894" name="results.png" path="results.png" size="24817" user="UliRaich" version="1"
META FILEATTACHMENT attachment="tflite_examples_arduino.png" attr="" comment="" date="1694091942" name="tflite_examples_arduino.png" path="tflite_examples_arduino.png" size="183028" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="hello_world_test_build.png" attr="" comment="" date="1694158216" name="hello_world_test_build.png" path="hello_world_test_build.png" size="53463" user="UliRaich" version="1"
META FILEATTACHMENT attachment="hello_world_test_run.png" attr="" comment="" date="1694158217" name="hello_world_test_run.png" path="hello_world_test_run.png" size="156067" user="UliRaich" version="1"

Revision 32023-09-07 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

Changed:
<
<
The TinyML examples in C++, ported to the ESP32 can be found at https://github.com/espressif/tflite-micro-esp-examples/tree/master/examples

The Hello World application

>
>
The TinyML examples in C++, ported to the ESP32 can be found at https://github.com/espressif/tflite-micro-esp-examples/tree/master/examples. There you also find the procedures to actually build the programs. In fact there are two methods of building:
  • use thee Espressif esp-idf build system
  • use the Arduino IDE
  • use the MicroPython interface to TensorFlow MicroPython Examples

Arduino

For the Arduino SDK (Software Development Kit) you can install the TensorFlowLite_ESP32 library, which does not only contain the TensforFlowLite library but also the examples

  • hello_world
  • wake word detection
  • person detection
  • ... and even some older version of magic wand, which is not available elsewhere
 
Changed:
<
<
There you can also find procedure to get the examples compiled. Let's start with the hello_world example. This example uses a pre-built model that has gone through the training process and it has been quantized to reduce its size such that it can be loaded into the small micro-controller memory. Building, training and quantization is described at https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world.
>
>
tflite_examples_arduino.png

The Hello World application with esp-idf

 
Changed:
<
<
We must first tell the idf.py that we are using an ESP32S3 chip:
>
>
Let's start with the hello_world example. This example uses a pre-built model that has gone through the training process and it has been quantized to reduce its size such that it can be loaded into the small micro-controller memory. Building, training and quantization is described at https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world.
 
Added:
>
>
We must first tell the idf.py that we are using an ESP32S3 chip:
 
idf.py set-target esp32s3

After that we may have to clean previous builds:

Line: 43 to 50
 
<--/commentPlugin-->

META FILEATTACHMENT attachment="results.png" attr="" comment="" date="1693664894" name="results.png" path="results.png" size="24817" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="tflite_examples_arduino.png" attr="" comment="" date="1694091942" name="tflite_examples_arduino.png" path="tflite_examples_arduino.png" size="183028" user="UliRaich" version="1"

Revision 22023-09-03 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

The TinyML examples in C++, ported to the ESP32 can be found at https://github.com/espressif/tflite-micro-esp-examples/tree/master/examples

Changed:
<
<

Hello World

>
>

The Hello World application

 
Changed:
<
<
There you can also find procedure to get the examples compiled. Let's start with the hello_world example.
>
>
There you can also find procedure to get the examples compiled. Let's start with the hello_world example. This example uses a pre-built model that has gone through the training process and it has been quantized to reduce its size such that it can be loaded into the small micro-controller memory. Building, training and quantization is described at https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world.
  We must first tell the idf.py that we are using an ESP32S3 chip:
Added:
>
>
 
idf.py set-target esp32s3

After that we may have to clean previous builds:

Line: 20 to 24
 
idf.py flash monitor

The program repeatedly runs the induction for 20 angle values between 0 and 2Π. These values can easily be captured by redirecting the output to a file. I then used an editor to prepare the data to be plotted with gnuplot.

Added:
>
>
 
idf.py flash monitor | tee results.txt

Finally I wrote a simple Python program calculating the correct 20 sine values, which allows to compare them to the results from TinyML.

results.png

Added:
>
>

Creating the model and training it

When working with Machine Learning, data play a primordal role because data are used to train the model and therefore influence the opaque algorithm within the model.

The model for the hello world example is created with the Python script train.py.

  -- Uli Raich - 2023-09-02

Comments

Changed:
<
<
<--/commentPlugin-->
>
>

<--/commentPlugin-->
 
META FILEATTACHMENT attachment="results.png" attr="" comment="" date="1693664894" name="results.png" path="results.png" size="24817" user="UliRaich" version="1"

Revision 12023-09-02 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="TinyML"

The TinyML examples written in C++

The TinyML examples in C++, ported to the ESP32 can be found at https://github.com/espressif/tflite-micro-esp-examples/tree/master/examples

Hello World

There you can also find procedure to get the examples compiled. Let's start with the hello_world example.

We must first tell the idf.py that we are using an ESP32S3 chip:

idf.py set-target esp32s3

After that we may have to clean previous builds:

idf.py fullclean

and finally we can build the hello_world program:

idf.py build

Once the program is built we can flash it and connect the serial monitor to see the results:

idf.py flash monitor

The program repeatedly runs the induction for 20 angle values between 0 and 2Π. These values can easily be captured by redirecting the output to a file. I then used an editor to prepare the data to be plotted with gnuplot.

idf.py flash monitor | tee results.txt

Finally I wrote a simple Python program calculating the correct 20 sine values, which allows to compare them to the results from TinyML.

results.png

-- Uli Raich - 2023-09-02

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="results.png" attr="" comment="" date="1693664894" name="results.png" path="results.png" size="24817" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback