偶然看到一篇好文章,分享给大家。 7 M3 @1 p0 E# }) a8 n2 {; _. R$ ~' n: X/ J0 j3 U# T 今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 4 F. j$ p' a* Y* j1 d1 q使用STM32Cube.AI简化了人工神经网络映射 1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU 0 r n6 U( T8 }# A/ x3 }. r/ H提高您的工作效率 利用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的容量。。慢慢下载吧 4 p! F+ R+ b% K' n1 [下载好后,CubeMx里的Artificial intelligent 激活Enable 这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法 model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 * ~' ?4 s1 o4 U& UHuman Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型 然后我们导入到工程里 这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。 点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 好了结果出来了, q. F; V; W, ?2 R3 \# t经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里 这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用 这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 ) b/ N6 j& h+ _1 o好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 2 [4 M( e. }# b$ b1 M: {9 ]: m6 T 选择好Validation 和打勾 AI core # h" ~* z# {4 n" Z4 @然后在cube 左下方可以看到下图箭头 提示的插件功能 我们需要打勾以下2个功能 # s l3 r: w9 |5 [0 x然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache 然后配置MCU主频为216Mhz ! ]& C% ~" D) ]( O- x$ S- N7 Q, U4 m$ n8 }$ z: [ 然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。 & D# }- k+ [7 R% B; Y然后在 AI扩展功能里选择通讯端口为串口3 / k: r; f2 I# D4 F好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 这里可以看到,基于AI训练好的模型数据列表。。。 ; j7 s9 b2 z7 x9 R J+ a4 q; h% [好了,配置位STLINK,然后编译好就可以直接下载到板子上了 6 {5 Q6 z7 P+ J9 O. d4 t好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target ) A& ^1 Z4 Q9 @/ f) ?/ D2 A5 M0 i3 v- s7 Y7 Z7 i 选择手动,然后选择对应的串口端口 . ~. w" t" c1 D- M这里可以看到验证已经开始了‘ ’ 好了,结果出来了。我们可以在串口输出的信息里看到有关的数据 ; m( U. ?* N% X) n( q好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
【合集】STM32F7教程、资料大集合
【STM32H7S78-DK评测】移植AI框架TensorFlow Lite【上篇】
【STM32H7S78-DK评测】移植边缘AI推理框架——TFLM(TensorFlow Lite for Microcontrollers)上篇
《无刷直流电机控制应用 基于STM8S系列单片机》
STM32定时器触发SPI逐字收发之应用示例
【银杏科技ARM+FPGA双核心应用】STM32H7系列10——ADC
破解边缘AI硬件与软件挑战,意法半导体解读三大创新要点
【银杏科技ARM+FPGA双核心应用】STM32H7系列57——MDK_FLM
【STM32图书分享之九】—《STM32F 32位ARM微控制器应用设计与实践》
基于STM32F746G-Discover的扩展电路板
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 directory7 j L' q) W3 a3 C! k4 U$ j
#include "network.h" m0 a2 N! N, @- U( p. p8 D* o
../Src/main.c: 0 warnings, 1 error5 `' ^- b' ^/ ?" C7 G/ w! L3 }9 I
compiling app_x-cube-ai.c...; ^4 o2 Y; j: H5 Y8 `* E0 j& ^+ s
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory* v; C& B9 C D1 Z* p
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c...0 |1 c" [' n% a7 n1 s
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c... R$ u: k: j1 t- Z
compiling stm32f7xx_hal_tim.c...8 u8 G! x8 d: ?1 c# E4 v& c( V y
compiling stm32f7xx_hal_tim_ex.c..." M. X! S% g% |" d' J# ]% S% ~+ X
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...6 Z! ~( q% [$ I0 S9 D) m$ Q
compiling stm32f7xx_hal_rcc.c...6 x1 O* w$ l1 M, `! G5 y
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...2 B0 w$ V- u( V- j
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_dma_ex.c...: S6 G) Z3 m. b u" _$ |9 {
compiling stm32f7xx_hal_pwr.c...1 Z1 F$ I. ?. q! i
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c.../ a) }0 O! O$ K0 y. |; R8 I
compiling stm32f7xx_hal_i2c.c...) P; m% p# c8 c' h# Y
compiling stm32f7xx_hal_i2c_ex.c...9 j( J8 e! E& n3 n
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...4 X) ^# h; s* P$ Z0 p8 w$ [2 z3 d
compiling aiPbMgr.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory) k) i9 U; ^2 L. k
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory2 t8 g0 m+ w$ U# i& k
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error: S# S& m9 H/ g+ l0 x: S, l
compiling aiValidation.c...- h( v7 ]6 w0 L. C, e' i* i% r
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"' v0 N( h, o' \0 Z$ b' ^
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...+ _9 [6 t2 [) ^
compiling pb_decode.c...$ V! j. c$ z3 {4 K+ y
compiling pb_encode.c...+ w# P; }0 T# [
compiling stm32msg.pb.c...7 S9 x$ n. d; I8 L$ q4 q
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s)./ X3 V* T8 z; j9 J% p5 U
Target not created.
assembling startup_stm32f767xx.s...
compiling main.c...& Q' X7 r3 [( F) B
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory9 c2 s# z6 j6 H {* G+ |4 H8 ?( k
#include "network.h"
../Src/main.c: 0 warnings, 1 error, l: e# u- Y; P6 p; E
compiling app_x-cube-ai.c...* ~0 U: _/ L3 n2 v. Z
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory# Q, {& j+ Q. ^
#include "network.h"% w6 J- Y# }8 E) }5 p) L, Z9 n! L
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...* c- t3 g q j( ~6 G
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c...% Y# E3 y: S) A
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...% a1 P) t8 W" V: O
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...) u2 k* ?+ _5 Z
compiling stm32f7xx_hal_gpio.c...* ^& y. L) [, r! Q" T' f
compiling stm32f7xx_hal_dma.c...: ]9 Y" ~ Y! U$ E" x/ ~# Q5 k9 M
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...* B" m8 i/ `6 l8 h- k! T$ L
compiling stm32f7xx_hal_pwr_ex.c...# n( A! @. q3 o) K; f. `& e1 u* U
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.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"( r: \5 \# t! t& |! S9 H; C$ Z+ R
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory4 J. d& d3 }% f2 O
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error% _* S$ q! r$ z/ _
compiling aiValidation.c...% ?, v3 b( A( d. E! L
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory H# u, Q0 p; }: s* x6 G
#include "network.h". {4 E3 q$ Y( |- f9 y
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...4 l" g7 G2 L# L* B7 L
compiling pb_decode.c...: N+ _1 @( G: y5 [- e% M4 j! f
compiling pb_encode.c...) T& H1 s1 j6 S3 z% Y3 ~/ B
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).! |3 b3 Q3 X( f" z/ s/ d _5 S- N
Target not created.
首先确保已经安装了AI库
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
& ~( t" ]- h# q' _# s- {& Q
$ E' ~8 P, \) k/ x) b. b0 {9 @3 s
& T, G' C5 _' [6 K
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
4 c0 A5 `, x5 W, q ^: u4 K$ z
厉害了大佬
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗$ O) F. F0 l) @. \2 g- t9 {+ S