visit
Development Environment
The development process is based on the STM32H743ZI-Nucleo board and the STM32CubeMX.AI tool is used, as it supports automatically generating various embedded projects (including but not limited to MDK, STM32CubeIDE, etc.) based on a trained AI Model (Keras/TF-Lite only). The tool is easy to get started and is suitable for embedded AI start-up development.The STM32Cube may cause the following errors in the ubuntu environment:
After installation, When running the executable files under the ‘bin’ folder in the terminal, an error is reported: the main class “com.st.app.Main” cannot be found or loaded, so you need to change Ubuntu’s default Open-JDK into Oracle JDK, as shown below:
1# sudo tar zxvf jdk-8u172-linux-x64.tar.gz -C /usr/lib/jvm
2# sudo update-alternatives — install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_172/bin/java 300
3# sudo update-alternatives — config java
4# java -version
Start by cloning the following open source repositories to the local:
tf2_linear_regression.ipynb
contains three different ways to construct the networktf2_Linear Regressions 'Extended.ipynb
contains different ways to train models1INVALID MODEL: Couldn't load Keras model /home/lebhoryi/RT-Thread/Edge_AI/Project1/keras_model.h5,
2error: Unknown layer: Functional
Sequence
, and the trained AI Model is saved as Keras format, with a suffix of .h5, such as keras_model.h5.The sample model I have saved, you can directly download the model for experiments, Here’s the linkThe neural network model structure trained in this example is as follows:Open
Help
in the menu bar, select Embedded Software Packages Manager
, and then select the latest version of the X-CUBE-AI
plug-in in the STMicroelectronicSTs
column, and click Close
in the lower right corner after installation.Import
X-CUBE-AI
plug-in in your project:
1(base) #( 07/03/20@10:51 am )( lebhoryi@RT-AI ):~/RT-Thread/Edge_AI@master✗✗✗
2 tree -L 2 ./Project1
3./Project1
4├── DNN # CubeMX Generate Project Path
5│ ├── DNN.ioc # CubeMX file
6│ ├── Drivers
7│ ├── Inc
8│ ├── Middlewares
9│ ├── network_generate_report.txt
10│ ├── Src
11│ ├── Startup
12│ ├── STM32CubeIDE
13│ ├── STM32H743ZITX_FLASH.ld
14│ └── STM32H743ZITX_RAM.ld
15├── image # Related picture save folder
16│ ├── mymodel1.png # model
17│ └── STM32H743.jpg # H743
18├── model # model Save path
19│ └── keras_model.h5
20├── Readme.md
21├── tf2_linear_regression.ipynb
22└── tf2_ Regressions_Extended.ipynb
To get to know STM32CubeIDE, please refer to this link .
Open
STM32CubeProgramming
, click connect
in the upper right corner, then select Open file
and select the .bin
file we want to open.In the ubuntu system, we can use the serial tool
cutecom
to view the running results of the final program, as follows:
RT-Thread Information: