偶然看到一篇好文章,分享给大家。 % Q" r! V" o" K- v& ?9 g1 f今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 $ V! i& R4 ]- |3 y4 J使用STM32Cube.AI简化了人工神经网络映射 ( a# ?2 ]4 K+ B: L- S; I0 D1.可与流行的深度学习培训工具互操作 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 |- v4 e" b" f那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1 然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧 下载好后,CubeMx里的Artificial intelligent 激活Enable 这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法 # Y, f1 V# M. a, [2 ]9 Umodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型 Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型 然后我们导入到工程里 这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。 点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 - d* }* B: x: P5 i$ k) Y好了结果出来了, ) X; B7 X( }$ {2 c1 V经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里 这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用 这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 ; {$ ?' Q. C0 v% \选择好Validation 和打勾 AI core 3 J: L3 {3 R u' ~0 t# F4 q然后在cube 左下方可以看到下图箭头 提示的插件功能 / ]" ?( t: V( Q! d A我们需要打勾以下2个功能 + C) P, I2 Y, `) K9 Y+ W然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 " y+ I9 _. ]! I9 a添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 + B# s" ~3 g% Q' j3 w然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache 4 Q! |7 Q/ s% X7 M2 o' H, h) |然后配置MCU主频为216Mhz 3 a+ {, Z% A# ] t0 p 然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。 3 z" j# V. w" ~! K0 Y然后在 AI扩展功能里选择通讯端口为串口3 9 c0 O. N( C& f h- m) ?4 Q9 U: H3 F3 u/ b7 u 好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 这里可以看到,基于AI训练好的模型数据列表。。。 $ x- R2 E9 L5 p) W7 @0 w1 j好了,配置位STLINK,然后编译好就可以直接下载到板子上了 n% |( X X- B6 E$ d好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target , f0 Y) f% G: f7 e* c 选择手动,然后选择对应的串口端口 这里可以看到验证已经开始了‘ ’& j* u3 W5 T. P' x 好了,结果出来了。我们可以在串口输出的信息里看到有关的数据 / f ^. k# J7 T" O7 R( F( S1 N1 n# x& N& [6 a- ^! |! M 好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
【银杏科技ARM+FPGA双核心应用】STM32H7系列10——ADC
破解边缘AI硬件与软件挑战,意法半导体解读三大创新要点
【银杏科技ARM+FPGA双核心应用】STM32H7系列57——MDK_FLM
【STM32图书分享之九】—《STM32F 32位ARM微控制器应用设计与实践》
基于STM32F746G-Discover的扩展电路板
意法半导体助力企业产品智能化,加快边缘人工智能应用
【合集】STM32F7教程、资料大集合
F769 Discovery实现播放U盘音乐的播放器
STM32 VS Code Extension (在Ubuntu上开发STM32,ST官方vscode插件使用指南)
无刷直流电机控制应用+基于STM8S系列单片机---电子书
assembling startup_stm32f767xx.s...) R' k2 k5 j, ~
compiling main.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory" ~# r. r3 B; w7 C
#include "network.h"
../Src/main.c: 0 warnings, 1 error% V8 v7 G$ r7 S- t
compiling app_x-cube-ai.c..., s& X3 r7 r T* y5 z$ 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 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c..., Z, |. h$ C; n- }/ ~
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c.../ N! v! q- G6 X
compiling stm32f7xx_hal_crc_ex.c...$ K- q1 q S# z7 Y. R2 }; j
compiling stm32f7xx_hal_tim.c...: X7 ?* G: N. ^
compiling stm32f7xx_hal_tim_ex.c...$ A( U9 p6 F; s5 l* ^
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...# I& z( C4 ?/ h$ `- `. ]
compiling stm32f7xx_hal_rcc_ex.c...$ W ]4 d; d; \5 C
compiling stm32f7xx_hal_flash.c...* p# \/ r0 J/ F. x
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_dma_ex.c...' Z$ {" g! r& n- |$ I1 Q3 C/ B
compiling stm32f7xx_hal_pwr.c...' u% S) e, g4 V' u2 x { H8 D& N
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...% x% j; V, F1 A: R4 I, i: R
compiling stm32f7xx_hal_i2c.c...9 u9 `0 _' [+ T9 i) R/ {) `
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...9 u; f0 Z7 m" }+ a: A% e
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"' ]3 Q, i3 s4 Q/ `+ ~$ c5 D8 A
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...4 e0 ^ J( V' b
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory/ C" u I1 V& H2 c9 Z1 _3 o% @. B
#include "network.h" K# K! q- R4 k- [. F! j
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
compiling aiValidation.c...% D& a6 {+ P$ f7 w+ G
../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/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...' {! l, L2 y( Y9 W1 i
compiling pb_decode.c...; D- D' v/ U" z. M3 q4 v( @6 W
compiling pb_encode.c...3 z, Q) F& y3 z- {8 d
compiling stm32msg.pb.c...; `& \0 V0 ]2 L/ p* K
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s...! x6 ?7 q: _# S3 x' f1 c+ S) [$ a
compiling main.c..., Y3 Y8 M2 }6 J( K
../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$ k; Y( Y, d3 W7 c2 O3 j8 d
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"3 r. C1 O/ F: u; d
../Src/app_x-cube-ai.c: 0 warnings, 1 error- p- ?1 `& O0 o1 @) f: S0 z: z5 K" j
compiling stm32f7xx_it.c.... f6 t3 F3 w ^- P$ ?
compiling stm32f7xx_hal_msp.c...% Q& D, z9 c. e R5 k
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...' Y4 `, P5 T9 q# y4 U9 I
compiling stm32f7xx_hal_crc_ex.c...& d2 g% D* h+ T( b6 u* n
compiling stm32f7xx_hal_tim.c...; b6 j5 y8 y4 a% ^ t
compiling stm32f7xx_hal_tim_ex.c...' ^ ~2 G7 f9 }- g
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...2 n+ g% P$ f8 H5 @. p% G
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...+ g" t1 j1 W) s2 `$ b G
compiling stm32f7xx_hal_flash.c.../ j6 ~- C# Q% T! N% h+ n2 s
compiling stm32f7xx_hal_flash_ex.c...6 t$ F' q+ w7 E/ V8 {6 }
compiling stm32f7xx_hal_gpio.c... f9 x; y0 S( x7 F; ~# G
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_dma_ex.c...2 ~0 q/ m) |' A. c m# N
compiling stm32f7xx_hal_pwr.c...2 a; z) a0 ?3 v: |2 [8 P6 v
compiling stm32f7xx_hal_pwr_ex.c...7 c$ X& y1 C: @; ]5 y$ }: X
compiling stm32f7xx_hal.c...9 f' A' w' d+ |
compiling stm32f7xx_hal_i2c.c...# f9 s. ~* X9 e9 C8 [% o x! A
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...; f# ~- u$ ^+ m: ~' e, H4 D! T
compiling system_stm32f7xx.c...
compiling aiPbMgr.c...' \# a$ s0 Q& U5 U
../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 error
compiling aiTestUtility.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"1 Y: e0 [4 \3 x- O3 L
../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& U: l+ Y$ O# f# j, k
#include "network.h"" W: R# S. s r1 T& l8 R" s8 P
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error1 S9 v3 q6 U" X) N! B
compiling pb_common.c...
compiling pb_decode.c...* ^2 K7 f9 A% ~
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后,配置好参数,确保自己使用的单片机是在列表中的。
, [# `# q' {# `" T: d3 @/ v
9 ]: o7 i/ R' U' @# T8 P2 W* F
$ A8 t: Q2 L, u% @
3 W- {( C* Z3 N( ]: \
! L) ~) O/ e+ N* J$ K& z
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
' j' L6 ?( t) X6 Q( e. T, z
厉害了大佬
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗$ |( p) }6 v" [8 ?