你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

基于STM32F767ZI AI 应用工程创建----转载  

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
% Q" r! V" o" K- v& ?9 g1 f

- F9 ]# d; C9 u
1.jpg

* H7 I* c3 N, Z/ g
今天介绍下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 D
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

6 P- x9 m% ~& C' H4 E# x; Z
提高您的工作效率

% |8 j+ [$ W3 Y9 A! g' u- I
利用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的容量。。慢慢下载吧

+ ?7 }/ G7 j6 U2 V
2.jpg

0 X: v! e, M6 m
下载好后,CubeMx里的Artificial intelligent
激活Enable

& W: ~8 y$ {) {4 F9 x3 q
3.jpg

, k6 H* D- ]) ]! J/ S
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法
# Y, f1 V# M. a, [2 ]9 U
4.jpg

( w/ P% v1 j+ q- s2 ?" v0 _
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

2 U( a" o, Y) U" v
5.jpg
- s6 n7 \, J# A5 W
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg
" w! A* j7 r; j  g+ K( D- D' o
然后我们导入到工程里
7.jpg
; k+ r- f8 X9 q- J2 r% o
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
4 e9 a" |0 B- H1 J. P1 C* n
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
- d* }* B: x: P5 i$ k) Y
9.jpg

- H# \" S0 `- p, Z) P3 J
好了结果出来了,
) X; B7 X( }$ {2 c1 V
10.jpg

# c  c% o3 p4 i, F: k
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
2 j) v3 X5 v5 W/ a# R
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用
: e* G! h9 ^3 e9 i$ V
12.jpg

/ u) W+ X" u' ~2 x% V
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。

+ H2 U& G( |0 s/ T/ i' n
13.jpg

$ E* q1 S0 L+ k% U. d
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
; {$ ?' Q. C0 v% \
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
# `! @  F# {' z& W6 O( t% w/ l
# t# i# J% @. N1 Z5 x( ~
15.jpg
5 B+ U6 o' e* L: m% A1 n

6 }9 N" H& j0 ~- G$ @6 S' u. ^. [
选择好Validation 和打勾 AI core
3 J: L3 {3 R  u' ~0 t# F4 q
16.jpg

7 }5 s# C' z. a9 R( u3 Z$ U) ~
然后在cube 左下方可以看到下图箭头 提示的插件功能
/ ]" ?( t: V( Q! d  A
17.jpg
" Z0 {; e3 H" t
我们需要打勾以下2个功能
+ C) P, I2 Y, `) K9 Y+ W
18.jpg

8 z; `6 C( }* \' w, C1 i& s+ w
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
" y+ I9 _. ]! I9 a
19.jpg

. A# O7 X% r$ V- T" {! t1 m& S
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
+ B# s" ~3 g% Q' j3 w
20.jpg

/ e( d4 W& ^4 o
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache
4 Q! |7 Q/ s% X7 M2 o' H, h) |
21.jpg
+ C, d  P8 p) Q" g1 N2 v& {9 N
然后配置MCU主频为216Mhz

* f0 a- q) O) O$ k' c1 O& X8 x, l. R
22.jpg

6 `2 s9 t' X' }& F5 A, p$ i3 a+ {, Z% A# ]  t0 p
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
3 z" j# V. w" ~! K0 Y
23.jpg
2 f0 \# m, I# `2 Y0 l
然后在 AI扩展功能里选择通讯端口为串口3
9 c0 O. N( C& f  h- m) ?
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)
$ x$ P& Q; c! \  p; V& O* h4 Q9 U: H3 F3 u/ b7 u
25.jpg

! n& C. b) ]4 }0 B" q5 }
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件

) a! ~1 [5 L4 D
26.jpg
6 H8 Q0 N8 \: g- G3 V- s% r
这里可以看到,基于AI训练好的模型数据列表。。。
$ x- R2 E9 L5 p) W7 @0 w1 j
27.jpg
# n1 d" c; n$ p: E8 b/ x! D0 C! B
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
  n% |( X  X- B6 E$ d
28.jpg
& B9 z% X" }  I0 L. g
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target

3 [$ w) F' L4 |) m, Z# P: g, f0 Y) f% G: f7 e* c
30.jpg

' |) I+ s8 }6 r% x
选择手动,然后选择对应的串口端口

+ d' P1 [( i, f, q, @& d1 f
31.jpg

" I' u  a- S+ s$ N
这里可以看到验证已经开始了‘
& j* u3 W5 T. P' x
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
/ f  ^. k# J7 T" O7 R( F( S1 N1 n# x
33.jpg

4 }1 e3 H- ^) \, a! ?, a7 p3 M
34.jpg
35.jpg
2 ^+ c: |+ }; z$ ~, a
36.jpg

( m9 }' B  c/ ]3 [& N& [6 a- ^! |! M
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
0 m( T3 z9 v. n; W" V# ^5 n6 f* Uassembling startup_stm32f767xx.s...) R' k2 k5 j, ~
compiling main.c...
- X2 [4 _7 r, q1 n" S* E; D../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"
7 C2 L( s. ^* C2 g: @' X- d../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
. W, A* ^6 I# F) c/ y, X  #include "network.h"
7 T) S0 ]5 [9 l" E- H2 y../Src/app_x-cube-ai.c: 0 warnings, 1 error
+ m& T0 s/ e  x1 B' @compiling stm32f7xx_it.c...
9 k+ M+ d+ a' ?4 @0 i* ]compiling stm32f7xx_hal_msp.c..., Z, |. h$ C; n- }/ ~
compiling stm32f7xx_hal_cortex.c...
8 D0 \1 r& s4 p& x7 ?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...
: j2 _0 [+ r% \. m3 ^& Scompiling stm32f7xx_hal_uart_ex.c...
0 B! [: F3 p! gcompiling 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...
8 L, V0 l( I5 b: q. z  q: Tcompiling stm32f7xx_hal_gpio.c...
# m3 W8 c0 v  |7 s" a, scompiling stm32f7xx_hal_dma.c...
; c, Q7 h2 [8 J8 b6 W  w7 ucompiling 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...
9 X- H: y! _) N* C6 scompiling 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...
. q( G# R9 g2 l: a* u' j  ^' Wcompiling stm32f7xx_hal_exti.c...9 u; f0 Z7 m" }+ a: A% e
compiling system_stm32f7xx.c...
0 U( z+ z% W: C3 X* S6 Tcompiling aiPbMgr.c...
" A9 n  o$ F" D../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
. {2 @# b, ], |# O8 _9 T  #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
: ~: W6 J" ?. f( pcompiling 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
4 _  L  n% ^7 N& Ocompiling 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
+ `9 q( U( W! c) c6 {  #include "network.h"
- b/ Q6 N$ r7 d2 I, h../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
- B( S# W' U# E  Acompiling 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).
! g' k% ?# Y# F! H' ITarget not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'$ o% a2 t8 j4 x& U% {9 Q. |( t
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
) X2 h7 x/ P3 h+ m' p& j6 K  #include "network.h"
! |1 Y* X, g) g" L* `- K+ Y../Src/main.c: 0 warnings, 1 error$ k; Y( Y, d3 W7 c2 O3 j8 d
compiling app_x-cube-ai.c...
# W0 M8 Q! u: b/ u+ k; k../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
) x7 k9 M2 ]+ q% s8 H: t- K  #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...
& X* ^9 P: i! ?: n( B& {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...
5 |! ~; S0 G/ n  m) U4 fcompiling stm32f7xx_hal_uart_ex.c...2 n+ g% P$ f8 H5 @. p% G
compiling stm32f7xx_hal_rcc.c...
: @8 n3 G5 @; R% ~8 Jcompiling 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...
, _: g& e0 Y, M1 rcompiling 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...
& N. r3 s" @+ g0 ecompiling stm32f7xx_hal_exti.c...; f# ~- u$ ^+ m: ~' e, H4 D! T
compiling system_stm32f7xx.c...
$ K/ c/ Z' G$ V+ e8 _  Dcompiling 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
/ ~' I# f: }  R. v  #include "network.h"
+ a4 D8 G% o5 z; q  ~../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
  k! w5 w' Q( n! mcompiling aiTestUtility.c...
' ^" w, N7 d7 M( a* u% {+ F../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
4 o# p6 t, e. ]! _- J  #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
7 U$ o% E8 w2 C/ F; \compiling aiValidation.c...
* N8 ~4 n& L1 }5 X# b4 k../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...
4 l) Q+ `+ I  J- zcompiling pb_decode.c...* ^2 K7 f9 A% ~
compiling pb_encode.c...
9 \( O3 z- W) M+ e; S! Acompiling stm32msg.pb.c...
" M9 C$ |4 e9 p& u"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
  }0 q8 R; {7 g3 ~Target not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
" q9 O7 E6 S8 A" Z' _* J我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...
' {0 w9 r, H( Q4 [  N. q1 K  `
首先确保已经安装了AI库
8 l" w* M$ s1 C6 E* r9 b: e# G& u
' z& g/ I! W9 j/ I1 D7 s 1.png 0 n! b8 r6 v7 Q* N+ g
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
0 v5 V* u' r9 c' c1 ]; k, [# `# q' {# `" T: d3 @/ v
9 ]: o7 i/ R' U' @# T8 P2 W* F
2.png
9 n- Y+ O+ H) V- m% M, `$ A8 t: Q2 L, u% @
3 W- {( C* Z3 N( ]: \
! L) ~) O/ e+ N* J$ K& z
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
, ]) {; d+ _4 L1 n, |' j' L6 ?( t) X6 Q( e. T, z
3.png
, n& v' F1 ]  ~. l- i7 i9 H3 |
zero99 回答时间:2019-1-8 13:15:38
看看
wujialing4000 回答时间:2019-1-8 15:24:33
辛苦了,学习了。耐心的看完每句话。
奏奏奏 回答时间:2019-1-8 19:12:17
用DSP部分来算神经网络,感觉是不是后面ST要出专用的神经网络计算单元了吗?
creep 回答时间:2019-1-9 09:44:21
厉害了@Paderboy
Paderboy 回答时间:2019-1-9 09:46:24
多谢分享。。
STMCU-管管 回答时间:2019-1-9 10:05:06
Paderboy 发表于 2019-1-9 09:46( b7 F9 `: [; x$ {8 ^
多谢分享。。
: }/ N& q8 S; c2 T1 n; }, E5 @
厉害了大佬
qhq8001 回答时间:2019-1-9 10:51:07
大概了解一下,感谢分享
xujiantj 回答时间:2019-1-10 09:06:19
谢谢楼主!!!
h55 回答时间:2019-1-21 09:14:29
我只看见MODEL.H5没看见STM32F767AI.H5,为什么
木木&点点 回答时间:2019-1-21 16:11:57
hu-jian-li 发表于 2019-1-21 09:14
) T& I  a6 b$ O& m$ X* R6 R2 a我只看见MODEL.H5没看见STM32F767AI.H5,为什么

' h* L6 H/ D3 [& N6 bmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52
. R5 b0 t) t" t0 K( H% w解释下输出结果的含义

# d6 E: [, [; C# X- R8 z$ y+ G输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
) x& U' |9 h" w3 x% h1 _6 rmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型

$ y  W' ~9 E+ ^- E, z" N我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
+ U+ Q; H, o  a( I7 o8 r我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...

) c( x5 b* ?; D+ R3 [导入到工程的时候,没出现STM32F767AI.h5吗$ |( p) }6 v" [8 ?
123下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版