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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
* _6 x4 f- s3 A; B# I" C

3 Y: }  y. y& r/ G8 M
1.jpg

, q; ~! d6 V9 f2 v3 q; l' s3 @& M! k
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

+ {2 D7 U0 j: m  E
使用STM32Cube.AI简化了人工神经网络映射
9 G9 d) L5 ~: W" N: t
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

5 X4 e4 o& B! d: z4 I
提高您的工作效率
/ d2 ]4 G8 Y" X5 m- X
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018

; z9 Q2 O) k3 B, V+ k) ^
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧

/ J( C! [9 s# l7 y% f% t: E  p2 D
2.jpg

* }1 j7 E$ j" T- T
下载好后,CubeMx里的Artificial intelligent
激活Enable

+ n- i1 u; B. ^/ L! P
3.jpg

9 x; @$ k9 w6 i2 s
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法
5 a6 m3 C) t: T1 F+ Z9 V- p: i
4.jpg
* J, e" y8 C" ^+ R' E; C' S6 J: X
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
2 t# F9 @1 t6 ]" ?1 J; Y
5.jpg

$ w% F- \; F) g% u+ o7 L
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg

8 X$ q4 V  s% u
然后我们导入到工程里
7.jpg

8 _* ^: m/ |8 C6 j, ?
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
8 f' c1 h% @2 m4 `& {$ d% t
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
6 b! b  b  M7 l. i; O
9.jpg

/ f- K% c% c  Z$ Z+ ^
好了结果出来了,

& g; z1 i. X1 d; K0 g
10.jpg

  k3 d4 y  |8 o" |- }7 O" [
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
& t% \+ C" f0 V( W& P% S
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

' a9 D8 Z2 z% |+ Z* I8 A0 @' i
12.jpg
+ x' B& U! ~( I) o7 x. ]
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
6 @' Y! G  [. C7 z2 X8 C, e
13.jpg

9 D+ m4 l6 j1 K& T+ z
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
0 b, N0 r6 k# i4 M1 \) @. t
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
) k& c2 E& P" l# [, W
" S* V2 N; b6 V: E6 d' W! k- ]6 Z
15.jpg

; I: v- l/ y: {: D7 Y7 s
! ^& y6 c7 }. W/ H) c3 U) D
选择好Validation 和打勾 AI core

; P7 Y. J( z' i* ~: ~" g% V, l( S9 [
16.jpg

( P2 d; @' x: D. b$ C& m
然后在cube 左下方可以看到下图箭头 提示的插件功能
+ R8 w5 [' J1 [% x5 j
17.jpg
( ~& C9 C* O0 _' x) @
我们需要打勾以下2个功能
) m9 f) S9 d! ?  Y$ N" N  Z# ?
18.jpg

; E' c8 E) v" c# [8 V: K
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
2 e  o* D% f' t+ T8 h
19.jpg
# Q7 A( p* F8 \  N7 F8 B
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
9 I1 p4 J* l- i2 a
20.jpg

4 e' B3 A3 ]) K5 l( E. N; L) s2 }
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache
2 o' p- R4 U8 {
21.jpg
* T& X* X/ r9 n2 u# A7 B
然后配置MCU主频为216Mhz
" m' P8 d3 |7 {& Z
22.jpg
. Y$ a6 ^3 T: Y: g

4 N* l. Z* A+ d$ g+ @' z* U. A- P
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

- X2 C6 O& I7 Q9 Q: a8 i( a5 T
23.jpg
+ G# k4 |: a2 G, `
然后在 AI扩展功能里选择通讯端口为串口3
2 ?, h& H. P/ c+ A
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记), u# P, }. Q  ^+ t% J

1 I' L; `1 G/ h' ^' ^
25.jpg

) p  }# B% m* {6 o
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
! ?2 `, J+ b% {8 m6 Z: f( w
26.jpg
+ N( h5 j1 l3 @5 V5 i' b
这里可以看到,基于AI训练好的模型数据列表。。。
& R1 j; K/ m8 Q- r5 G
27.jpg
+ l$ |3 H& j& l4 x
好了,配置位STLINK,然后编译好就可以直接下载到板子上了

' ~: n1 M4 r- J+ w" c4 {! T# B
28.jpg

- j  y- y+ _7 S7 N
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target

" K! j: G8 \2 |# Y3 J5 l
+ n, m: x6 R( u. D8 C4 H- H
30.jpg

( k3 v! r+ Y. V  M* w) W; {
选择手动,然后选择对应的串口端口

' t6 c8 K* |1 @" c$ |
31.jpg

9 Y$ s( K$ J6 s# z4 ]: g+ f
这里可以看到验证已经开始了‘
’, `) X1 R7 ]' q6 o% Q
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
, _% _! t1 g) _. O& v7 Q2 T
33.jpg

' s* T% j! _4 K* a( h: F& Z. I
34.jpg
35.jpg

1 B" ]* z/ H4 h* ^$ Z
36.jpg
+ P1 v5 w6 h0 S( ~5 m( _# q! v
: U+ @2 Q3 q. W3 o* _9 Q
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
赞 收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
% F4 v5 |; l1 o+ `* f7 R$ T7 Tassembling startup_stm32f767xx.s...
) R9 q& X/ t1 Y8 R" s+ H6 S; N+ }2 Fcompiling main.c..." t  j& x7 W1 T3 v" b6 o
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory) @& I4 g* Q( Q/ O5 \! Q# }
  #include "network.h"
8 Z: n& w: h, C+ [: E6 U../Src/main.c: 0 warnings, 1 error
( f1 q8 i. v  b6 ]) {3 mcompiling app_x-cube-ai.c..., k$ p2 V2 k8 y
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
: @/ w) P+ W) Q9 v; y# J9 l6 q3 m  #include "network.h"- r5 D* t& ]3 ~6 R2 H
../Src/app_x-cube-ai.c: 0 warnings, 1 error$ B* Q7 {9 v  b- B3 l+ M: ^
compiling stm32f7xx_it.c...
& o  y& u+ p: h  X  |5 Rcompiling stm32f7xx_hal_msp.c...
. z0 b! j; ^: M6 H1 R" O; |  xcompiling stm32f7xx_hal_cortex.c...
& V8 {% a) s# p+ @  acompiling stm32f7xx_hal_crc.c...: {* y8 D+ ]( y2 D3 N! q
compiling stm32f7xx_hal_crc_ex.c...
6 b! u$ O- y& l$ j+ C) f" |compiling stm32f7xx_hal_tim.c...+ T  ]# _0 W2 H! {' T5 v7 H1 ^4 q
compiling stm32f7xx_hal_tim_ex.c...
( [8 M; b. u3 O5 f& b1 T5 Lcompiling stm32f7xx_hal_uart.c...- G- Y1 n5 o* x% }+ A" h# t
compiling stm32f7xx_hal_uart_ex.c...) h! C# _/ R- z6 \& t: y* k: q
compiling stm32f7xx_hal_rcc.c.../ h7 B- H7 }" ]& F! [) _' a
compiling stm32f7xx_hal_rcc_ex.c...7 H' {/ y- Q: ?2 e
compiling stm32f7xx_hal_flash.c...
/ q4 n9 i0 \6 u5 w) W5 v+ scompiling stm32f7xx_hal_flash_ex.c...
& M4 B0 V4 G' j1 c/ M8 Y% q! ?( Jcompiling stm32f7xx_hal_gpio.c...1 ^& G/ n+ ~( y% u$ m( S0 p
compiling stm32f7xx_hal_dma.c..., i7 r8 ~- S+ ^$ G& E" Z
compiling stm32f7xx_hal_dma_ex.c...
  G; U! |" T4 n7 u- x2 L; @  V/ Ccompiling stm32f7xx_hal_pwr.c...
6 [5 |6 @8 `8 e. `+ Icompiling stm32f7xx_hal_pwr_ex.c...; W  s2 M# s& ]2 E4 k
compiling stm32f7xx_hal.c...$ q. k% R/ N0 a2 a8 Y) o! v# h
compiling stm32f7xx_hal_i2c.c...
) k$ H3 Q1 A: h( v7 Icompiling stm32f7xx_hal_i2c_ex.c...: N' `0 J( {9 z3 a
compiling stm32f7xx_hal_exti.c...
  p- _6 O+ ?8 u$ t5 E: v0 y/ p$ Ncompiling system_stm32f7xx.c...5 v9 C  j8 S2 @6 t/ r$ k
compiling aiPbMgr.c...- ~5 Z7 e+ S: @6 H9 Q! F
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory6 A2 F& ^" T+ |. e
  #include "network.h"5 G% H3 z# q; S: S) ~% R# Z" S" H
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error2 |: c: }( c8 |% K- ?5 ~5 J
compiling aiTestUtility.c...9 X- W6 M/ C" P1 |4 f7 f' a
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory0 o  A0 F+ a: z- b+ j& z6 ~# g
  #include "network.h"2 Q- k7 D- ?( B  X6 q
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error7 R7 J. {8 x. A7 N' s
compiling aiValidation.c...
: W- ]$ ^9 }2 G../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
( Q) q+ |2 Q. s% S0 `5 M! G  #include "network.h"* c6 @) w8 j, s
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error1 _/ m, K3 ^& X7 h' o/ n) l  e
compiling pb_common.c...- T9 r3 p  G- n9 I7 k: D
compiling pb_decode.c...# |# t4 f) b* h- w4 A8 a
compiling pb_encode.c...
3 R4 }) s7 u1 R$ x- I8 Kcompiling stm32msg.pb.c...
8 l3 {/ H) a0 ]4 E"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
7 G( D9 w1 l( G% x# I1 W+ M  ~Target not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'8 d* D+ B7 \. e6 c
assembling startup_stm32f767xx.s...% ^. i$ `9 D, L) P/ t+ F( i  |- R
compiling main.c...7 W5 j* P! L' @7 V# H0 f" ?
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
- R, ?( S7 d) ?  #include "network.h"
. N, |  z+ X. O3 n../Src/main.c: 0 warnings, 1 error; M) I3 j" D3 K! ?7 W2 N) H, Y
compiling app_x-cube-ai.c...& v$ p/ a* ~% D: J' E# o5 X9 n
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory; M4 P) t- I8 B/ w
  #include "network.h"
" d$ g& G6 M! W" _) J/ y../Src/app_x-cube-ai.c: 0 warnings, 1 error  y6 z. d" X  I5 }% N  x! u) K
compiling stm32f7xx_it.c...) X- l+ f8 i$ J! ?: l2 s1 _6 Q
compiling stm32f7xx_hal_msp.c...
5 {$ [# Q2 K9 c! k: Z1 m- Jcompiling stm32f7xx_hal_cortex.c...
8 w: @& R& f( Lcompiling stm32f7xx_hal_crc.c...& J7 _2 j/ [8 O: H
compiling stm32f7xx_hal_crc_ex.c...
* Z8 H. p, y+ p) m) l& j& pcompiling stm32f7xx_hal_tim.c...* }/ |$ M/ d# y
compiling stm32f7xx_hal_tim_ex.c...  E: T' `/ Z% c+ ]  b7 ^8 T
compiling stm32f7xx_hal_uart.c...
4 v/ e" V3 u! X4 m8 b, [compiling stm32f7xx_hal_uart_ex.c...4 F- g- X& G3 Y# ]8 W: t$ e6 |* v
compiling stm32f7xx_hal_rcc.c...% L2 D' e9 t  ]( z  X: r
compiling stm32f7xx_hal_rcc_ex.c...
/ N6 S) T% H0 X9 v5 ocompiling stm32f7xx_hal_flash.c.../ d7 E1 l- j  L/ e4 W% N4 ~+ x( a
compiling stm32f7xx_hal_flash_ex.c...5 [; j& S, X4 q& Y0 Y4 ~
compiling stm32f7xx_hal_gpio.c...
8 M1 U% [/ \8 p/ Ocompiling stm32f7xx_hal_dma.c...$ L5 Y, U6 p) f0 c+ F" G5 n1 `
compiling stm32f7xx_hal_dma_ex.c...( q' h& P* N4 p0 M
compiling stm32f7xx_hal_pwr.c...
& B, d$ _- R) j0 p; Q2 Icompiling stm32f7xx_hal_pwr_ex.c...
' x# e2 J) P: \( {5 e/ k* ncompiling stm32f7xx_hal.c...2 V# ]; n, {' K, ~! V& V
compiling stm32f7xx_hal_i2c.c...
0 f! s: `- V, v! Y9 ecompiling stm32f7xx_hal_i2c_ex.c...
% X! E% {3 v( c+ ]compiling stm32f7xx_hal_exti.c...5 e* r5 Q' q9 k0 d/ H8 \9 A
compiling system_stm32f7xx.c...! G1 U- g1 }& D4 {( b: i0 y
compiling aiPbMgr.c...
2 i  |) a2 v( Y2 W# j( R- i- A, {../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory( X: r/ J6 b) m% r* o+ J' m3 I
  #include "network.h"
4 o7 Q: {6 d* ]- L7 Z+ Q& Z../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
, W3 R7 C' N+ v4 U; ]* H- x( q5 Lcompiling aiTestUtility.c...' \* h9 Y! }) }# z! {+ F% C! o' q
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory: i# R: u- r, l/ J
  #include "network.h"
( g" G5 Z/ n0 c# [& k../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
. ?4 u, [' |+ fcompiling aiValidation.c...# L* G( m% {8 l* J5 i$ w& ?9 y9 N
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory3 ^7 z) k" S& ?/ q0 b2 ^
  #include "network.h"
- i8 Q& Q- U, Z9 V3 i../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
3 x7 F' ]8 F  \* V! W2 e) O1 Jcompiling pb_common.c...
! H0 e* h# c9 C5 u" E! V' @7 @compiling pb_decode.c...
6 d- F+ U5 s9 r4 Acompiling pb_encode.c...4 e; e1 r$ ?+ B
compiling stm32msg.pb.c...
) S: b( ]" @0 x7 }  \# j3 R"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
" o% |! E: {) JTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
) i6 v/ b  `5 x3 g% @* L0 y; S, c我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...

# M- j0 c7 i7 o7 G首先确保已经安装了AI库
. M, o5 Q, L  U! a5 P* L
. n  ~9 B& z0 B" b0 v5 X( l6 o 1.png
2 f9 ~6 u8 d, S  g使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
4 K2 I( H: W$ R* Z, a6 A, Z
# \% B* [) {) `, t8 u. _/ B% [7 T0 Q
2.png : z$ B2 l+ t# h3 r

  N. ?( h: `$ l+ p8 ?, {4 G2 _5 K8 ?- I% c- R' i
% M% I6 `: N; n) G
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。2 D' n* O& A8 p8 B
3 j; j1 k9 x% b' J0 z1 z1 c8 ^
3.png
" [+ k" |; y/ l* J: ]' ^0 _
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- G3 i2 X( p( I+ r' p
多谢分享。。
! Y* ~4 N) E7 m1 d0 x: l  ~  v5 Y
厉害了大佬
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
' U6 u1 o" K) J我只看见MODEL.H5没看见STM32F767AI.H5,为什么
. |8 Y+ W) l4 x  c2 Y  C- x) v
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52
+ l- ^0 A# W/ R' ~3 I8 ?* H. I: \解释下输出结果的含义

7 R/ o5 {! ~3 F- s输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
4 u* `! P1 [2 t# H4 S4 Hmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型

; O' `" Y# n& K( ?8 v& I我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:029 C( v$ O% }! p! |
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...
  i$ y$ y* b, o3 H1 g3 {- v
导入到工程的时候,没出现STM32F767AI.h5吗3 q9 d) H, o2 e" l
123下一页

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版