Tags:
tag this topic
create new tag
view all tags
---+ The tinyML Hello World example ---+++ How does tinyML hello world work? The program takes a value between 0 and 2Π and outputs the corresponding sine value. Of course, this could be simply done passing through the sin function of the mathematics library. For demo purposes a neural network is created and trained by feeding it 1000 angle and sin(angle) pairs training it what the sin function is supposed to do. The trained model is converted from !TensorFlow to !TensorFlow Lite format and finally 'quantized' replacing the float values of the output model by int8 values thus drastically reducing the size of the model. The final model is transformed into a char array within a C++ source file. This source file can finally easily be included into a C++ program running on the target processor (ESP32). ---+++ Model Creation The model creation process is described in https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples. In order for this to work he build tool [[https://bazel.build/docs][bazel ]]must be installed. In order to do this I used the [[https://bazel.build/install/ubuntu#binary-installer][binary installer]]. To get started with bazel, use the [[https://bazel.build/start/cpp][bazel tutorial]]. Unfortunately the process of !TensorFlow model creation has been changed with respect to the description in the book and the jupyter notebook *create_sine_model.ipynb* creating the model cannot be found any longer in the github repository. It has been replaced by the Python script *train.py.* ---++ The hello_world example for the ESP32 The tinyML examples for the ESP32 are available for [[https://github.com/espressif/esp-tflite-micro][builds with esp-idf ]] and for the [[https://www.arduino.cc/reference/en/libraries/tensorflowlite_esp32/][Arduino SDK]]. Unfortunately the Arduino version uses a rather old version of !TensorFlow Lite Micro (TFLM), while the esp-idf version runs on the latest version of TFLM. The code for the example programs are slightly different according to the versions of TFLM used. I upgraded the Arduiino library and modified the output_handler in such a way that the results from model invocation are displayed as light intensity on the ws2812 LED installed on the !WeMos !ESP32S3 WROOM and the values are compatible with the Arduino Plotter. The upgraded Arduino TFLM Arduino library can be found at https://github.com/uraich/TinyML/tree/main/Arduino/TFLM_ESP32. In the plot below, the blue values correspond to the input for the model (values 0 .. 2 Π) and the red values are the output from invocation. <img alt="hello_world_plot.png" height="555" src="%ATTACHURL%/hello_world_plot.png" title="hello_world_plot.png" width="820" /> -- %USERSIG{UliRaich - 2023-09-01}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
hello_world_plot.png
r1
manage
44.3 K
2023-11-04 - 14:24
UliRaich
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r3 - 2023-11-19
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 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