|
偶然看到一篇好文章,分享给大家。 ' X3 X4 s a5 M3 S! D5 P; R( i" j# S7 \# Y6 N
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 使用STM32Cube.AI简化了人工神经网络映射 1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU 0 ~; P, \( u: _2 _; S* D* e p+ |1 l提高您的工作效率 利用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的容量。。慢慢下载吧 8 G8 k, r( `! o: i
下载好后,CubeMx里的Artificial intelligent 激活Enable
这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 3 O$ E$ C& J- |6 B5 z; r
Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型
然后我们导入到工程里
这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
好了结果出来了,
经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里
这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
5 R t6 x+ P$ m2 V" E
选择好Validation 和打勾 AI core & r- [$ I1 l. {0 } ?# R
然后在cube 左下方可以看到下图箭头 提示的插件功能 O- m1 d, x& i& `
我们需要打勾以下2个功能 5 K0 }+ Q4 U8 f1 x3 N- I9 y) ]
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache
然后配置MCU主频为216Mhz 5 Z' O& U3 L1 V0 j
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
然后在 AI扩展功能里选择通讯端口为串口3
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 , V8 i8 }; ]2 i) d% X. e
这里可以看到,基于AI训练好的模型数据列表。。。 T$ W2 P8 K9 G& o0 T
好了,配置位STLINK,然后编译好就可以直接下载到板子上了 ; r, j9 @$ n+ T# O# R
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
选择手动,然后选择对应的串口端口 , w0 D) I" X3 _7 |
这里可以看到验证已经开始了‘ ’# z4 Q: Q2 i, ~, }
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
好了,基于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...- D! a; R* a- O5 z* D2 D2 |4 d
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory, N- j/ I w8 Z& s$ y# }- C, x
#include "network.h"9 L4 _+ R2 Y! R* x
../Src/main.c: 0 warnings, 1 error0 }0 v8 L' t& e1 h! d8 S) ~3 H0 C
compiling app_x-cube-ai.c..." [9 j3 [% Q* e' K' 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 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...6 ^& A2 W2 y/ y, m. g
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...3 S% \0 f# A$ K
compiling stm32f7xx_hal_crc_ex.c...7 F* Y# g5 D0 w- H+ N. J, u/ K
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...( H0 H- G* P8 I: j
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c... e5 J" ^. J* H
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...) M+ E8 R0 H/ l; c7 K" T% x8 S
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...% T: t$ K: O( O( f
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...+ s" i+ I2 Q0 z& l: n1 H
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...7 o; f5 k& T7 a. S- }
compiling aiPbMgr.c...9 T& N6 N- b' A7 u1 l
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory5 Y8 T% W# z9 h( ^! D0 q
#include "network.h"# H$ b8 C1 a3 N; b9 o2 {8 a6 l; P
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error4 q2 a1 N$ K4 p: D& _1 x
compiling aiTestUtility.c...+ E/ p: O; \6 s" I
../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/aiTestUtility.c: 0 warnings, 1 error
compiling aiValidation.c...* P2 M5 t* R6 E$ g% i3 b) l
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"; L5 z% _& y& P
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error6 d, E- Z7 p) g* [5 c% W
compiling pb_common.c...0 D! C% M% [" G$ Y# ^
compiling pb_decode.c...
compiling pb_encode.c...& c& e/ ^' M5 a" F# {: V
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s..., h: n) ~. F0 I% x
compiling main.c...! b: M* [" J# K; C; x/ C7 X4 o- x
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory! `; Q: v/ p2 Q% ]+ z
#include "network.h"+ O; b* c; G0 f) k
../Src/main.c: 0 warnings, 1 error9 j+ x2 u4 J, P C4 R" i5 g2 I) G0 t
compiling app_x-cube-ai.c...6 \7 f" O" J; o) 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/app_x-cube-ai.c: 0 warnings, 1 error3 Z0 `, W/ k- C) J6 g( o. d; @+ j
compiling stm32f7xx_it.c...- F* t6 Y" D4 g# [( E, r
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...9 {; B8 V7 S, b/ W
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c...4 O# d/ \3 o2 e7 e6 n
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...0 v- _0 x% P, h; a
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c..." t& L# v$ U+ L2 d) [
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...0 D# {: J1 v- i6 x8 X8 h
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...! u2 \9 ^9 c' e7 C. M' B4 A
compiling stm32f7xx_hal_dma_ex.c..., _& s0 `! a& _# }+ p" }& ~% V& T
compiling stm32f7xx_hal_pwr.c..., T. X0 Z4 O( A$ n* U0 M
compiling stm32f7xx_hal_pwr_ex.c...1 R6 k2 g9 s, n/ V! W; B
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c.c...9 i8 o& k# f6 [4 N1 g s
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...! U4 N$ R# T/ S$ l
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"3 v2 |$ L% e1 E8 m& B+ [1 n
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error2 z0 t( O8 Z9 a4 ]9 y# h6 b
compiling aiTestUtility.c...1 I5 x% U* s( t
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory* }# A" v H# p. T& @$ x
#include "network.h"+ n7 [8 J, S/ [
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error q8 Q4 o: P' F t- p0 ~
compiling aiValidation.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory) K( G7 h; g/ Q5 B2 N
#include "network.h"3 q* i3 X! j. u9 k/ o# z; E" c
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c.... O8 C1 N+ |, N% Y
compiling pb_decode.c...* q* B3 f2 r X- i9 ~: D( T' j
compiling pb_encode.c...1 H$ z* F! A: \
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库
9 _/ s' J9 O3 m( a' i) [
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。7 ~# |" S( z+ L& \) |7 ~% w# E
3 H- `9 J4 E2 B) K/ u" ^: F
5 k* u& Q1 Z* J4 e' L: w1 y
F4 M8 J2 Q+ C$ \/ t7 N) d+ O: ~
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。2 W/ C/ [' t+ h& x7 m; V
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗