|
偶然看到一篇好文章,分享给大家。
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 使用STM32Cube.AI简化了人工神经网络映射 $ }; P, |' X6 i" R' a, J0 F1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU 提高您的工作效率 利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。 以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018 3 n/ @+ f! `/ }6 L那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1 然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
下载好后,CubeMx里的Artificial intelligent 激活Enable % ]$ a2 r3 j8 ?6 u! E7 ?
这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 \2 F" u4 V8 e
Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型
然后我们导入到工程里
这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 5 N( o E* y7 _& ?% ~; N
好了结果出来了, / G, O: F) M( f' S
经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里
这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 , o. c# n9 C2 D4 N. J
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 / X# L8 G8 i. ?2 p0 e) ?, y
! x+ A _) {- T# p' ~* { 选择好Validation 和打勾 AI core : X4 C, |, [6 @ b9 C
然后在cube 左下方可以看到下图箭头 提示的插件功能
我们需要打勾以下2个功能 1 g$ H! j" N$ Z# e
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 + \. E, Y% ]7 l0 l' A$ J
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache
然后配置MCU主频为216Mhz
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
然后在 AI扩展功能里选择通讯端口为串口3 5 x1 W ~9 G0 m: C; a, g& Y) x/ m
$ O5 s7 Y E9 s) [6 p
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 $ i, d. N) X) U5 \" b$ U
这里可以看到,基于AI训练好的模型数据列表。。。 9 Q W+ I* R0 k! N7 k4 B
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target 0 j ~/ m1 A; b" O- J* R
选择手动,然后选择对应的串口端口 * |# ]2 k3 L: s
这里可以看到验证已经开始了‘ ’
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
STM32在边缘AI的布局及能力版图
从家电到机器人:STM32边缘AI应用案例拆解
STM32F746G-DISCO移植lvgl9.0性能基准测试
STM32U3B5/U3C5:为超低功耗设计带来高性能 DSP 与边缘 AI
【NUCLEO-U3C5ZI 测评】+ 手写数字识别
【STM32U3 评测】MNIST 数字识别
STM32F745 USART1 Bootloader启动失败排查与解决的流程分析
AI玩具爆发前夜:技术拐点、体验鸿沟与破局路径
STM32 AI Model Zoo,现支持PyTorch的最大规模MCU AI模型集合
经验分享 | STM32 AFCI 方案 TensorBoard 使用指南:AI 模型调优可视化终极方案
微信公众号
手机版
assembling startup_stm32f767xx.s...
compiling main.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory Q2 E( Q# l0 K2 R
#include "network.h"; L+ d B% y+ R( D9 M; L
../Src/main.c: 0 warnings, 1 error
compiling app_x-cube-ai.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory8 |2 E. Q5 Y5 f# o/ A& \
#include "network.h"* N" \0 L! Z- P4 Q0 n7 {, W
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...' W0 Z+ T7 p. o( H! ^" f
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c..." H4 e* o$ h8 A* P
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...# W6 \: O9 ~& P% @4 D
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...& p* k8 t; O, {0 | Y) m3 L
compiling stm32f7xx_hal_dma_ex.c...8 s O% P5 [1 X' P$ a
compiling stm32f7xx_hal_pwr.c...- D8 p# L/ I0 Z
compiling stm32f7xx_hal_pwr_ex.c...( T0 A: Z# G( M I
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c.c...7 D6 r6 Q( M1 c3 x
compiling stm32f7xx_hal_i2c_ex.c..., d6 c6 e- v6 y9 v4 R
compiling stm32f7xx_hal_exti.c...4 K {2 k6 H# \
compiling system_stm32f7xx.c...
compiling aiPbMgr.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory4 l; a2 b1 X# _
#include "network.h"2 |5 t9 h- |! }7 M4 {4 K
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error6 k* n. F/ H4 [1 ]& D+ Y" M2 I, }
compiling aiTestUtility.c...% t" o; }1 ^( }. {$ H/ I1 t; S2 K
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory5 {. \1 O' c) A7 L; _8 G
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
compiling aiValidation.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory" z( X; o6 a: x4 {. f' A* P
#include "network.h"$ [; a3 f% U. q& w
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...
compiling pb_decode.c...
compiling pb_encode.c...
compiling stm32msg.pb.c..." j W( v7 @* O# D9 T( t% t
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s...
compiling main.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory ]5 H1 R, G4 y3 K% l* e
#include "network.h"
../Src/main.c: 0 warnings, 1 error
compiling app_x-cube-ai.c..." n# r" b$ ~1 `
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory" q+ c% q C! ^3 k! Z4 V
#include "network.h"! q6 Z5 g9 f% `
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c..." |) t3 ]5 j7 o: p. z5 p3 X
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...7 t' h: y7 v8 r4 ?
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c..." n7 k- w S8 o+ f
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...8 x& [, x! P- v! u% X
compiling stm32f7xx_hal_rcc_ex.c...0 H3 p3 x9 L1 X; O$ j
compiling stm32f7xx_hal_flash.c.... a% o6 _% N1 Y }
compiling stm32f7xx_hal_flash_ex.c...% |# B$ r) A% U# A e4 x( ?3 h
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c.c.... g, Q' [2 Q: O$ P) V
compiling stm32f7xx_hal_i2c_ex.c...) T {0 `3 {* a; n: I4 K1 C8 K# w
compiling stm32f7xx_hal_exti.c...) B3 ]+ ?4 C- m- _
compiling system_stm32f7xx.c...% ]& f, F8 K/ V, ^
compiling aiPbMgr.c...) M5 a! D6 Y* W# R. v# C; s" U
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory1 Q7 i- n6 f! E! }% d) j! o
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error5 K1 }7 J( L/ n: \
compiling aiTestUtility.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory6 W7 l5 g ~" Z4 R/ [
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error: H7 H) } u0 J* ~5 F8 I! p# u* ?
compiling aiValidation.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory# [" H) y. f+ D0 t% }; q
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...
compiling pb_decode.c...
compiling pb_encode.c...
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。 J# W* g8 d2 j$ d9 t3 t' S3 E6 t {
6 y5 f' X& g/ t* E
o9 K% m* e3 |! s% {0 W0 _
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗