|
偶然看到一篇好文章,分享给大家。 * _6 x4 f- s3 A; B# I" C
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 使用STM32Cube.AI简化了人工神经网络映射 9 G9 d) L5 ~: W" N: t1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU 提高您的工作效率 / d2 ]4 G8 Y" X5 m- X利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。 以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018 那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1 然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
下载好后,CubeMx里的Artificial intelligent 激活Enable
这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法 5 a6 m3 C) t: T1 F+ Z9 V- p: i
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 2 t# F9 @1 t6 ]" ?1 J; Y
Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型
然后我们导入到工程里
这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 6 b! b b M7 l. i; O
好了结果出来了,
经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里
这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 6 @' Y! G [. C7 z2 X8 C, e
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 0 b, N0 r6 k# i4 M1 \) @. t
选择好Validation 和打勾 AI core
然后在cube 左下方可以看到下图箭头 提示的插件功能 + R8 w5 [' J1 [% x5 j
我们需要打勾以下2个功能 ) m9 f) S9 d! ? Y$ N" N Z# ?
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 2 e o* D% f' t+ T8 h
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 9 I1 p4 J* l- i2 a
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache 2 o' p- R4 U8 {
然后配置MCU主频为216Mhz " m' P8 d3 |7 {& Z
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
然后在 AI扩展功能里选择通讯端口为串口3 2 ?, h& H. P/ c+ A
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 ! ?2 `, J+ b% {8 m6 Z: f( w
这里可以看到,基于AI训练好的模型数据列表。。。 & R1 j; K/ m8 Q- r5 G
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
选择手动,然后选择对应的串口端口
这里可以看到验证已经开始了‘ ’, `) X1 R7 ]' q6 o% Q
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据 , _% _! t1 g) _. O& v7 Q2 T
: U+ @2 Q3 q. W3 o* _9 Q 好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
意法半导体助力STM32开发者简化AI模型开发流程
迈入融合时代:以统一的STM32 MCU平台释放物理AI潜能
【STM32C0116-DK】MNIST 数字识别
【NUCLEO-C562RE】MNIST 数字识别
【STM32H5 评测】MNIST 数字识别
基于STM32F767通过cube配置:QSPI接口读写64M PSRAM+flash参考资料...
STM32在边缘AI的布局及能力版图
从家电到机器人:STM32边缘AI应用案例拆解
STM32F746G-DISCO移植lvgl9.0性能基准测试
STM32U3B5/U3C5:为超低功耗设计带来高性能 DSP 与边缘 AI
微信公众号
手机版
assembling startup_stm32f767xx.s...
compiling main.c..." t j& x7 W1 T3 v" b6 o
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory) @& I4 g* Q( Q/ O5 \! Q# }
#include "network.h"
../Src/main.c: 0 warnings, 1 error
compiling app_x-cube-ai.c..., k$ p2 V2 k8 y
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"- r5 D* t& ]3 ~6 R2 H
../Src/app_x-cube-ai.c: 0 warnings, 1 error$ B* Q7 {9 v b- B3 l+ M: ^
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...: {* y8 D+ ]( y2 D3 N! q
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c...+ T ]# _0 W2 H! {' T5 v7 H1 ^4 q
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...- G- Y1 n5 o* x% }+ A" h# t
compiling stm32f7xx_hal_uart_ex.c...) h! C# _/ R- z6 \& t: y* k: q
compiling stm32f7xx_hal_rcc.c.../ h7 B- H7 }" ]& F! [) _' a
compiling stm32f7xx_hal_rcc_ex.c...7 H' {/ y- Q: ?2 e
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...1 ^& G/ n+ ~( y% u$ m( S0 p
compiling stm32f7xx_hal_dma.c..., i7 r8 ~- S+ ^$ G& E" Z
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...; W s2 M# s& ]2 E4 k
compiling stm32f7xx_hal.c...$ q. k% R/ N0 a2 a8 Y) o! v# h
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...: N' `0 J( {9 z3 a
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...5 v9 C j8 S2 @6 t/ r$ k
compiling aiPbMgr.c...- ~5 Z7 e+ S: @6 H9 Q! F
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory6 A2 F& ^" T+ |. e
#include "network.h"5 G% H3 z# q; S: S) ~% R# Z" S" H
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error2 |: c: }( c8 |% K- ?5 ~5 J
compiling aiTestUtility.c...9 X- W6 M/ C" P1 |4 f7 f' a
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory0 o A0 F+ a: z- b+ j& z6 ~# g
#include "network.h"2 Q- k7 D- ?( B X6 q
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error7 R7 J. {8 x. A7 N' s
compiling aiValidation.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"* c6 @) w8 j, s
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error1 _/ m, K3 ^& X7 h' o/ n) l e
compiling pb_common.c...- T9 r3 p G- n9 I7 k: D
compiling pb_decode.c...# |# t4 f) b* h- w4 A8 a
compiling pb_encode.c...
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s...% ^. i$ `9 D, L) P/ t+ F( i |- R
compiling main.c...7 W5 j* P! L' @7 V# H0 f" ?
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"
../Src/main.c: 0 warnings, 1 error; M) I3 j" D3 K! ?7 W2 N) H, Y
compiling app_x-cube-ai.c...& v$ p/ a* ~% D: J' E# o5 X9 n
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory; M4 P) t- I8 B/ w
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error y6 z. d" X I5 }% N x! u) K
compiling stm32f7xx_it.c...) X- l+ f8 i$ J! ?: l2 s1 _6 Q
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...& J7 _2 j/ [8 O: H
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c...* }/ |$ M/ d# y
compiling stm32f7xx_hal_tim_ex.c... E: T' `/ Z% c+ ] b7 ^8 T
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...4 F- g- X& G3 Y# ]8 W: t$ e6 |* v
compiling stm32f7xx_hal_rcc.c...% L2 D' e9 t ]( z X: r
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c.../ d7 E1 l- j L/ e4 W% N4 ~+ x( a
compiling stm32f7xx_hal_flash_ex.c...5 [; j& S, X4 q& Y0 Y4 ~
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...$ L5 Y, U6 p) f0 c+ F" G5 n1 `
compiling stm32f7xx_hal_dma_ex.c...( q' h& P* N4 p0 M
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...2 V# ]; n, {' K, ~! V& V
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...5 e* r5 Q' q9 k0 d/ H8 \9 A
compiling system_stm32f7xx.c...! G1 U- g1 }& D4 {( b: i0 y
compiling aiPbMgr.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory( X: r/ J6 b) m% r* o+ J' m3 I
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...' \* h9 Y! }) }# z! {+ F% C! o' q
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory: i# R: u- r, l/ J
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
compiling aiValidation.c...# L* G( m% {8 l* J5 i$ w& ?9 y9 N
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory3 ^7 z) k" S& ?/ q0 b2 ^
#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...4 e; e1 r$ ?+ B
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
. _/ B% [7 T0 Q
2 _5 K8 ?- I% c- R' i
% M% I6 `: N; n) G
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。2 D' n* O& A8 p8 B
3 j; j1 k9 x% b' J0 z1 z1 c8 ^
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗3 q9 d) H, o2 e" l