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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。

1 O; ~, `* F8 ^; ^7 P3 c' u9 A
$ r' t! @9 C& d, l
1.jpg
# ^5 w7 s( }$ D
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

' i: M/ _% M5 C" r9 x
使用STM32Cube.AI简化了人工神经网络映射

; B/ K3 s/ J1 R1 s4 r, v- X/ E
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

' o- K  }/ Z4 K' ^3 N& w
提高您的工作效率

7 T, `! ?7 f2 V3 y1 q4 c8 I
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018
& i8 @+ k% x6 n) k% J8 l+ {& z
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
; z7 t8 |; M/ x' O/ E  [5 `+ y
2.jpg
7 {& z% O. c' f& e1 u6 I
下载好后,CubeMx里的Artificial intelligent
激活Enable

8 R; ?+ e$ P% h" _5 Y
3.jpg

  k' P9 N! Z; m. E1 m" v7 v
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法
% H; l$ R+ o' y- ^
4.jpg
* m& ]* w( {/ s/ g8 f2 d
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
, F. P% U& A+ \
5.jpg
) t3 U, O/ l3 P+ {" Z* t
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg
9 R; s; [" }7 _# B; s6 R
然后我们导入到工程里
7.jpg
9 [* D9 ^% V- `6 {$ u7 [+ U- n
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
! I; i* l$ N+ Z" D
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
" T+ b7 S8 M4 r+ S" K
9.jpg
# _& z. s0 z, C% E
好了结果出来了,

9 S9 i, _3 U, N9 {9 Q
10.jpg

  ]) u: z# [, k, i5 I5 L
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
* j* |* s7 Q) Q8 \# F- }
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用
* Y& J- y9 s3 _3 h  n  ?: n7 \( R
12.jpg
- d/ {3 S1 S0 J
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
2 t+ Y5 {6 J+ U2 r) R
13.jpg

- W4 |0 W9 K5 o0 L9 R- K
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
$ O8 Q) q5 _/ Z
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
$ ]/ W7 G" H( f2 Z$ T3 @7 R* E% C- C8 L3 o$ m7 K9 W
15.jpg
- [  m: z" y: c
& x7 u3 f+ O9 B6 C* |
选择好Validation 和打勾 AI core

- e* z: r0 g) k, g  o! B) o5 a
16.jpg

8 e! i- ~/ B# P, e, p# J
然后在cube 左下方可以看到下图箭头 提示的插件功能

; P0 d" `. q9 V2 b- y: O& b0 Q- S7 B
17.jpg
( M$ a% v3 u# C  \
我们需要打勾以下2个功能
3 J: R9 \. ]+ i9 ^9 s  @
18.jpg

! u) ?8 I. Z# C( k0 o* u
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
* X7 I: x( l6 E. f$ \2 j9 q9 R
19.jpg

0 A' O) ^5 ^4 A: @* Z9 R
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
& b1 z4 B- k9 q$ c6 y
20.jpg

! ?! M6 b  l& N+ w9 b
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

  S, b( H3 L+ t8 c
21.jpg

" }2 X# {4 Z, W* v+ N! f
然后配置MCU主频为216Mhz

% p8 B7 v6 r2 q* c/ q- r
22.jpg

+ x+ }' G  O8 r4 X* _; o! v4 C- x$ S% N, a, N; ^
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

) O6 @& Y- ]- B! f
23.jpg
% K. N; ^# \* x% B- x
然后在 AI扩展功能里选择通讯端口为串口3
( ], U0 {8 O+ F) U+ \& x
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)
5 U7 O, c. c& W  i! `# c' L  s9 o1 y  R
25.jpg
! x0 q( A8 V; w5 ^
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
9 i4 x- N0 k$ y+ D! Q
26.jpg

' W! l. P% t; Y, _  v) i
这里可以看到,基于AI训练好的模型数据列表。。。

; O* g9 r9 B- ?  s- W
27.jpg

# _: c. C' c6 r( p& ?& q
好了,配置位STLINK,然后编译好就可以直接下载到板子上了

& C$ X( c* ]. c
28.jpg

8 T& `# J  |/ {6 Z. }( n, q; I& m
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
3 E6 @6 x: ~3 N2 j9 i# F6 ?! w8 X+ q0 Q- g

, X7 U' Y. [& a0 D6 m
30.jpg

1 v* c' K& a5 x3 J3 i# }
选择手动,然后选择对应的串口端口

' }7 g, l2 E" Z* S$ P& J8 n! X
31.jpg
+ L' z  m% c7 w, F8 G
这里可以看到验证已经开始了‘
$ l4 K% y) h+ d  c) Q. N
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据

3 R1 R  W0 d6 C. ]; e7 R9 d
33.jpg

5 w; E( a- W! @1 s
34.jpg
35.jpg

: Z+ I, ^" k/ }) I5 {. O" d# O
36.jpg

1 c: V( y3 b2 ?
1 \, d: C, `1 K
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'0 N  M3 x2 b* [; l% `3 m
assembling startup_stm32f767xx.s...: y/ E' H& e8 ]6 g6 w
compiling main.c...9 b* N1 R+ a( n8 `, J" W* P4 n- ~
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
% }: G3 T% J4 l; y5 k, s. x( \9 g. s" o  #include "network.h"8 n. G- L5 t+ e9 w) N) `3 k
../Src/main.c: 0 warnings, 1 error8 i& y) M3 \  C  G; v6 p! B
compiling app_x-cube-ai.c...7 U& e( r3 k8 Q9 t$ T* F2 _
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory! L# g+ [) e, d
  #include "network.h"/ W! @, {8 K; u5 U% x* Y9 v
../Src/app_x-cube-ai.c: 0 warnings, 1 error  Z! X# \& g. c  f, S5 u9 N, [$ z; P
compiling stm32f7xx_it.c...6 Q/ v1 ?) P- \6 z. p) J
compiling stm32f7xx_hal_msp.c...
1 f( D) m% W& a, S: C3 ~1 dcompiling stm32f7xx_hal_cortex.c...: n4 f4 {& C# U2 K* U) k
compiling stm32f7xx_hal_crc.c...- `! y  a% X; `% a/ N& [7 y, ?
compiling stm32f7xx_hal_crc_ex.c...' s& A/ v8 @7 q
compiling stm32f7xx_hal_tim.c...
: M: ]5 z! l/ v. f9 r1 x' ccompiling stm32f7xx_hal_tim_ex.c...$ M& S# v9 |/ J4 m' _" ]+ a& ~
compiling stm32f7xx_hal_uart.c...5 K" o3 U7 r; `" p& i' z3 @
compiling stm32f7xx_hal_uart_ex.c...
& D; ?- N, u5 i; b7 D4 Pcompiling stm32f7xx_hal_rcc.c...
0 V0 f' K) t% ]) Lcompiling stm32f7xx_hal_rcc_ex.c...
7 @% A: N+ a& L$ A6 d/ b* [compiling stm32f7xx_hal_flash.c...
9 L( [. x, k5 Pcompiling stm32f7xx_hal_flash_ex.c...0 S- ^, ~! g. ]! _8 U7 r
compiling stm32f7xx_hal_gpio.c...
4 W  t" r2 A7 Z1 H; P( }( |# L9 |# Q' mcompiling stm32f7xx_hal_dma.c...
0 d" _7 w  P9 v5 m% j% Ocompiling stm32f7xx_hal_dma_ex.c...
+ k9 e  @7 D! G$ v4 P7 Z7 g, F& rcompiling stm32f7xx_hal_pwr.c...( s" p% \9 b! Y3 i0 x
compiling stm32f7xx_hal_pwr_ex.c...
8 ]+ ~* m! T$ Q5 Jcompiling stm32f7xx_hal.c...
5 z$ t1 f8 E; R  h/ O1 Ocompiling stm32f7xx_hal_i2c.c...
: @) S6 X- m1 e& i) ^compiling stm32f7xx_hal_i2c_ex.c...
8 A* P" W& y6 w" W5 u& ecompiling stm32f7xx_hal_exti.c...
9 |" w7 O) W: f0 C4 Ncompiling system_stm32f7xx.c...
" u* [4 l5 @* @1 M- ?- {3 l9 f* l* Ecompiling aiPbMgr.c...
* H1 q6 `9 g# h" z/ B9 ~$ f5 \../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory$ K. C) u, ~& d' z" }
  #include "network.h"3 F% G+ l% ]: L! G; {. W. ?
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
0 Z9 d' l7 H; C; N; [compiling aiTestUtility.c...
7 a4 B! G$ y, g7 e2 Y../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory6 j2 v3 ?8 a3 f' [$ c) p1 }
  #include "network.h"! r; n7 m1 V: F# S3 x8 X# B
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error8 R, l( l  [, ]
compiling aiValidation.c...
1 \8 Y! U/ v1 ]0 [  H3 ]2 q5 |../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
0 A0 f) D$ g( Y/ a  #include "network.h"' |+ b$ q6 p3 x( V( t& i8 e
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error3 k+ I2 g' z+ Q
compiling pb_common.c...
+ \8 z: j$ Y+ g) F! N9 }; ^3 acompiling pb_decode.c...
0 w& T$ a& F1 Y7 X' I8 ]! T* X0 ]compiling pb_encode.c...0 ]  a0 W8 X, }4 _0 A1 W
compiling stm32msg.pb.c...# s* y$ g* w% U# Q( I4 v! T
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
- n8 u1 u/ R' Z' Z- f& a0 J  g. V& HTarget not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'
6 _- b$ R/ J1 C" z# U8 G" o2 {assembling startup_stm32f767xx.s...
) V; z2 b# U5 Ocompiling main.c...
' ~, [* d# ?% u; C5 F. Q../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory6 l- o7 w8 @) F- V) ^6 C
  #include "network.h"7 B; t  G  R2 y7 k; ]
../Src/main.c: 0 warnings, 1 error
0 I  D" W4 J8 Ucompiling app_x-cube-ai.c...
! M' t) b3 \4 M- X- ^6 y% C7 w9 Q../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory! P2 u9 [3 B. G! A' E
  #include "network.h"
' L; ~& a$ w8 M0 H) [. @0 Y0 q../Src/app_x-cube-ai.c: 0 warnings, 1 error: v( Y' W, v- ^+ I' [) }
compiling stm32f7xx_it.c...% z) g9 z$ h% g1 t
compiling stm32f7xx_hal_msp.c...; {7 k( D+ F- G0 X
compiling stm32f7xx_hal_cortex.c...2 j1 r) j7 u1 C! Q& v) ]" a
compiling stm32f7xx_hal_crc.c...
4 t' r& k5 d7 m5 e) hcompiling stm32f7xx_hal_crc_ex.c...2 Z3 ?# ~' W  R* G' J* |* N
compiling stm32f7xx_hal_tim.c...
* g; k- s( W; b$ d3 gcompiling stm32f7xx_hal_tim_ex.c...0 ?4 c/ L- m( Z7 {9 O3 N- z# L+ j
compiling stm32f7xx_hal_uart.c...
. x8 ~8 r  \# o% W( a) o9 D5 icompiling stm32f7xx_hal_uart_ex.c...9 p# F* }# h- l+ ], e
compiling stm32f7xx_hal_rcc.c...2 m7 n- a! R4 ]3 n2 k9 ^/ g
compiling stm32f7xx_hal_rcc_ex.c...; i  m. J! ?" T" l' P* {$ \
compiling stm32f7xx_hal_flash.c...
$ b* R1 A# @7 g* r- }( Ccompiling stm32f7xx_hal_flash_ex.c...) T! S% B( K: S. t& S, _  T
compiling stm32f7xx_hal_gpio.c...( \+ v- y& m) y; H  ?3 s# s  H
compiling stm32f7xx_hal_dma.c...4 S1 e. s+ q% E) _* u. [/ p5 E% I6 a
compiling stm32f7xx_hal_dma_ex.c...
" c: b( I0 ^+ K* x( E5 Q& R' F- qcompiling stm32f7xx_hal_pwr.c..., G$ p; Z! L7 `, t; D! O
compiling stm32f7xx_hal_pwr_ex.c...
3 o+ x7 |9 s3 L& a) Q* @compiling stm32f7xx_hal.c...
; l0 I$ k, Y& w+ P% D6 Ucompiling stm32f7xx_hal_i2c.c...
. B/ H8 h" p0 F# q$ G( Y+ icompiling stm32f7xx_hal_i2c_ex.c...
5 B' h- |8 Z! Q0 t7 `: I; vcompiling stm32f7xx_hal_exti.c...4 e6 Z1 q) s* |+ \
compiling system_stm32f7xx.c...) U8 p% x) m9 V" R2 E- g0 o9 b- g
compiling aiPbMgr.c...
" v- W( H+ G) c../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
$ z2 {& ^/ H+ f  o  r  #include "network.h"
' E. q" K% w; H) g. ?$ F  Y../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
" r' H4 L) f4 dcompiling aiTestUtility.c...
1 }' _1 U% G/ x# Y: k../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory1 F8 b6 c9 |4 l$ J8 H2 d: P
  #include "network.h"6 L* X- W) j8 V! x7 A1 T: {$ u1 M  A
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
' a/ m3 U% r! q5 v0 B0 j7 ]# Vcompiling aiValidation.c...
2 I/ W" m+ C* f" k& b0 ^4 u../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
4 K! c& k4 i2 F7 W5 e0 ~- w  #include "network.h": J* [2 h- |+ A0 {
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error6 J$ }  c3 N5 u- N, j% N
compiling pb_common.c...
# t- m3 j! P( @  V5 Y/ P* ?8 zcompiling pb_decode.c...
/ g! r4 _' K. |: J) D) q/ l& Ecompiling pb_encode.c...! U+ `5 D5 U5 [3 K/ S2 Y
compiling stm32msg.pb.c...
6 l& M& A2 g4 `"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).( G, E6 u6 Q( [+ {7 h
Target not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
0 r& ~* a! E& i5 a5 f我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...
5 W( V5 p; y# {# R3 J
首先确保已经安装了AI库
- z7 A9 I" j6 M/ E4 ~( n1 R1 f- k1 E  B) ^4 ^$ O# W5 n4 b" ~
1.png 2 Y9 G8 v+ o: ^! M0 W
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
' o5 O  _8 {& c& s
+ C3 w: z# _& V- y, ^8 A0 W$ P
! I* I. t& m3 W6 |1 | 2.png , e) z* z# I( n

0 Z" \$ N* k" i. i% c! k) i' Y1 t9 B' u& u4 g0 B+ D
9 i2 X2 h5 `, F0 A
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。4 ^' e7 u; L& |9 \

3 H, T$ Y1 E1 \/ ^; k 3.png " b8 V. D2 w! z3 ]- L5 h* R
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
5 J/ o4 M. b: {; ]5 t$ {8 o多谢分享。。
1 y4 X; F7 h( g  j
厉害了大佬
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! ]. z( k: M) B4 F9 B
我只看见MODEL.H5没看见STM32F767AI.H5,为什么
, o" F' Z- Q1 Z
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52
4 K. {& H# k4 @4 N解释下输出结果的含义

  w0 e3 w2 v% q7 E& b输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
; {4 o0 ?% M4 ]+ F% kmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型
$ d. D8 i( ~3 ?. }1 m; `3 u: ?
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
9 |4 v8 ]" _; R6 {" b0 I我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...

" q% R  D% B$ ~: B- |5 |' C导入到工程的时候,没出现STM32F767AI.h5吗
2 E# r9 A4 H5 c8 l( E- ]- v+ z; g
123下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版