|
偶然看到一篇好文章,分享给大家。 " z( h' Q4 V& P+ h1 }. L, V$ U/ ]: x0 Z3 K
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 3 F/ t5 K. u7 ^* c8 `' @8 g使用STM32Cube.AI简化了人工神经网络映射 1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU ( e/ R- p5 m0 y6 m" A提高您的工作效率 + Y, Q* F7 I8 g* 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算法
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型
然后我们导入到工程里
这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 ' ~' s! Z3 j: l2 I2 _, P( v9 E
好了结果出来了, 5 i( q8 V9 Z* k; D0 n0 p# e O
经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里
这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 0 J! q$ C" T5 u( c+ @' E
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
选择好Validation 和打勾 AI core 4 \2 a3 W3 z: b
然后在cube 左下方可以看到下图箭头 提示的插件功能
我们需要打勾以下2个功能 ( s7 {, |! D( W o# a u" P
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 ( D2 @: H! P8 g7 _0 J6 Y
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 . C& V; Z/ x0 R8 ]' u
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache
然后配置MCU主频为216Mhz
- ?' S, n& q z- V: R3 V 然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。 " P' ~5 b2 q W' D7 Q
然后在 AI扩展功能里选择通讯端口为串口3
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 6 l2 d& b; p( Z/ t Y
这里可以看到,基于AI训练好的模型数据列表。。。
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target ( S- n B9 I( p" @9 i4 o: _9 _; `, g" l5 }
选择手动,然后选择对应的串口端口
这里可以看到验证已经开始了‘ ’/ w( S: L! w! J9 n% j# B' |# ]# v
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
基于STM32F767通过cube配置:QSPI接口读写64M PSRAM+flash参考资料...
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模型集合
微信公众号
手机版
assembling startup_stm32f767xx.s...5 r+ P: p1 |7 W
compiling main.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"/ G( d M5 q* k4 y
../Src/main.c: 0 warnings, 1 error1 ^+ t' \' G4 V& F$ F; `
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 directory4 C0 A- t7 E" R% K
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error- \7 U* Q" t% g. i' r
compiling stm32f7xx_it.c...* X8 Y5 L$ K" ]# _( Q4 C
compiling stm32f7xx_hal_msp.c...2 ?! @* M0 _9 I5 m5 \4 d5 L
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...+ C+ N/ a9 \. ?" |6 o& i+ j8 e
compiling stm32f7xx_hal_crc_ex.c.../ j" o m* u9 j% B( R
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...6 ^- I/ n5 b8 q8 x' d1 x$ f. u
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...; W' [9 S) _7 U6 B. w
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...% U. W3 ^. R, L
compiling stm32f7xx_hal_gpio.c...& m% A* Z d+ o2 R2 ]& J Z. g1 B
compiling stm32f7xx_hal_dma.c... s# c. p2 s4 y2 M: {
compiling stm32f7xx_hal_dma_ex.c...7 ]& {* z. a) O) Y
compiling stm32f7xx_hal_pwr.c...! F* k1 u T/ Z# h
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...9 P3 K+ Z9 u" F M
compiling stm32f7xx_hal_i2c.c...2 o M$ R4 e( y2 }+ B7 L! v) L# o6 ^
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c..., c( ~; J, H% v& x6 e4 c
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 directory
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error7 }% m0 Y( k& \# ^
compiling aiTestUtility.c...( j [# \9 ?% ~* q$ c. H
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory1 Y: m7 C# r0 ]. ~ U0 M% ?
#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
#include "network.h"# L0 M. }- e. \) l
../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).+ s* N) }9 p+ b
Target not created.
assembling startup_stm32f767xx.s...% b; Q& ]7 z$ W
compiling main.c...: p0 _5 Z' x; T
../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+ `( P: Y& Q% w1 k6 W0 r+ {) P
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 directory
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error2 y# v8 U# n4 {" O
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c..., x. ]$ s' _0 C. Q3 i7 r
compiling stm32f7xx_hal_cortex.c.../ d8 g( c/ J% a! F; U
compiling stm32f7xx_hal_crc.c...) v2 s7 o1 `% L3 {! {
compiling stm32f7xx_hal_crc_ex.c...8 ~5 e; C; Z0 b4 Q& S' r: n1 l
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...' R* t7 p. i9 u% b5 i
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c.... _! y1 A8 A$ k% R
compiling stm32f7xx_hal_rcc_ex.c...- D2 v" g& u; S/ U
compiling stm32f7xx_hal_flash.c...$ e a1 m+ F' e3 G
compiling stm32f7xx_hal_flash_ex.c...# v9 o3 h, n7 f. r
compiling stm32f7xx_hal_gpio.c...4 w7 q* v& Y& o. E
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...5 ^' _. g+ ^9 L4 t6 x' o
compiling stm32f7xx_hal_i2c.c...! O5 C8 w0 F5 D" D
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...
compiling aiPbMgr.c...9 a( c/ ]( L5 i; Y9 T; u1 ?2 s
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory# P* L1 @$ O9 Q/ `, f$ E
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...9 X7 e) w5 L0 e7 @4 T# }! g% o
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"& ~" i, C. i/ |) x" ]! e/ g
../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
#include "network.h"" ? U5 ^, B8 C- ~+ u
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...
compiling pb_decode.c...4 ~2 L D7 d1 i; ?
compiling pb_encode.c...1 f" K1 d6 I8 e5 Z; p3 M
compiling stm32msg.pb.c...: T7 _, Q" e' e- n
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库" ]; q; g6 f. V( ~2 H h% P5 ]6 {
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
- W! ]) d2 i% s1 Q( }. E' |0 j
$ E* o6 G6 n0 m; @4 R) Q; P
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗