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

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

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

1 f/ Y$ G; Y. R7 A2 o3 g3 S' N& S/ D. z
1.jpg

% q, H, z+ m6 f* u
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

( ^$ `# T# U( p( K; W8 h
使用STM32Cube.AI简化了人工神经网络映射

$ t$ i6 i: j; p6 [. Y
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

! G; @5 ]# x9 y, I1 n$ m
提高您的工作效率

7 O" X* l6 {- w
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018
$ Q1 `. h9 B5 T
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
0 k; G; a3 t4 s6 Y5 F/ M
2.jpg

7 u: J( S  A5 L! B' x
下载好后,CubeMx里的Artificial intelligent
激活Enable
* Y, L+ V0 K4 ?7 C! m! x* \9 n, g
3.jpg

# _2 R8 K3 W, K0 B$ M  E
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法
( M. Q0 K3 Q  w) T! b
4.jpg

5 A, }& X* s( P
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
2 P7 e' O9 U! P( ^9 h
5.jpg

. W  j+ P0 \6 U
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg
4 W( _3 o( m) n2 R( I
然后我们导入到工程里
7.jpg

" @& S6 \# Y  a. T+ M4 R7 C
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg

7 Y" f  G3 o2 L) g* a: v9 k
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用

+ n1 H7 G' e# V  \! S2 e
9.jpg

$ d( }5 x" s9 L" s2 o' W- u
好了结果出来了,

+ R6 y/ U8 ~- ]' k) M
10.jpg
$ C7 t' C" u; _8 h: W7 ]7 v
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
5 f2 w, E' T. D  ~* H( T
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

8 q) e) @3 H" i
12.jpg

. x# H# |7 Y; e% a
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
, o2 C; a9 @) P" e  Y8 r5 N& t
13.jpg
0 Q* j# y0 e. ~/ T  x/ k) V4 h
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡

" q6 [  P9 p9 D% z5 C6 r* L
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
( K8 n: l6 e3 }1 N* D+ R6 i
7 u4 N1 q; l) o8 {
15.jpg

3 ~' l$ p  c- _& `$ I$ o
' \% i% ^- H6 N3 Q, i9 V
选择好Validation 和打勾 AI core
) {( P% h  L) N% H: p- j5 g1 U
16.jpg
- F7 J+ `" p) m
然后在cube 左下方可以看到下图箭头 提示的插件功能
- x7 ^& l5 e- m0 l) H% |( T
17.jpg

# V$ ~! |- i+ Z1 c
我们需要打勾以下2个功能
1 c" k3 ?4 h5 j! S  c  g1 s
18.jpg

( o) a3 M( A. e6 ?
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。

( y% e+ o2 P8 h. _. ?# U$ Z
19.jpg
/ A( E: _. ^; a! U2 s  n5 C
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
$ K+ w3 N- V0 U* T" z+ Z
20.jpg
, a2 H( d2 i+ j4 c8 q# [0 p
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

7 h) Q2 m8 ]2 n  B$ V
21.jpg

' O. @; }) ]9 i* I/ L4 T/ U6 ^
然后配置MCU主频为216Mhz
( G& A$ L9 x2 i( Y8 O& r2 y& f/ P
22.jpg

, H, X( k7 }1 \. ^- _3 \  H
& {& w' }8 l5 w6 |
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
: H, @- {( E6 u' \
23.jpg

; L& x/ ~+ l/ E; C7 y0 w' T
然后在 AI扩展功能里选择通讯端口为串口3
$ C5 J! p/ Q! Z' S
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)+ O7 N! G) b3 o
. D. r5 {8 D5 r
25.jpg
) l# v" f8 O' i1 Z- n# v) J
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
0 D. k" _& q% e: h( X  w" Y
26.jpg
5 P: ~; s3 A9 `9 ^5 a
这里可以看到,基于AI训练好的模型数据列表。。。
$ }8 C3 m: i# V) `! v
27.jpg

6 b, g# r7 ]5 k5 A! a2 c# y0 C
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
$ u' v, B' R& ^. |: H
28.jpg
6 L8 W- E# }' {" ]
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
. d, g; G" L) Y5 Q& I$ H

8 O* l5 ?7 Z) N* K/ u
30.jpg
  ?1 J" L4 z) H9 S: e2 F. j
选择手动,然后选择对应的串口端口
3 f! q7 d" o2 l9 N  i# e
31.jpg
: t  @9 b7 f; ], I% o8 d: L/ W
这里可以看到验证已经开始了‘

0 h3 B* f% [7 J  v
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
; y) Y3 V' ~: o
33.jpg

7 p2 ]5 m& q$ J' d: x2 w$ h8 m
34.jpg
35.jpg

3 r5 j, s% g7 ?( N
36.jpg

2 y4 J7 K' ^: e4 x: a- `) O
, {* Y- p3 s% @# s
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'4 n2 @% @( _  L
assembling startup_stm32f767xx.s...+ e1 e3 x3 w$ X+ {
compiling main.c...
+ f9 l' v4 q% t& r& {/ h../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory3 R2 s4 Q$ e, A; ^2 M
  #include "network.h"# d1 M* S4 Z( D+ D. A! @. F9 f5 w
../Src/main.c: 0 warnings, 1 error
# a& \7 Q/ m) Fcompiling app_x-cube-ai.c...  G3 W+ \( B. {
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory/ u4 b' q. L. m7 s- a
  #include "network.h"
1 D/ c8 ?! Q& O9 ^../Src/app_x-cube-ai.c: 0 warnings, 1 error
) p0 N) m' r3 r& R& b4 [compiling stm32f7xx_it.c...
4 A  Z3 T. R# N6 ^compiling stm32f7xx_hal_msp.c...( C' T/ w6 a- e% H/ s6 ~4 w7 O  k
compiling stm32f7xx_hal_cortex.c...' G5 Y4 ~  L% b
compiling stm32f7xx_hal_crc.c...
$ B+ G; W  R9 Ncompiling stm32f7xx_hal_crc_ex.c...6 B8 z9 v3 s1 o: n
compiling stm32f7xx_hal_tim.c...
: t% P& e* U1 g* X$ mcompiling stm32f7xx_hal_tim_ex.c...
+ r2 W6 M5 T+ ^4 jcompiling stm32f7xx_hal_uart.c...' F, ~" F9 g9 ]: g# L
compiling stm32f7xx_hal_uart_ex.c...
' h9 M+ _3 o& v; y( A' Ccompiling stm32f7xx_hal_rcc.c...* ]5 X8 S" A/ {3 W, P4 n; }& J
compiling stm32f7xx_hal_rcc_ex.c...) [4 e, o" x" H7 D0 W3 V9 n) H
compiling stm32f7xx_hal_flash.c...& H( Z7 d: a, a% T' _& ]
compiling stm32f7xx_hal_flash_ex.c...1 S4 }9 U' X. g) T1 H  a3 e4 s5 N( y
compiling stm32f7xx_hal_gpio.c...
, D& C; I9 b: T" ?1 U2 Z& fcompiling stm32f7xx_hal_dma.c...6 G" s# O  t8 e# ]
compiling stm32f7xx_hal_dma_ex.c...% G+ w$ w3 m2 l" V
compiling stm32f7xx_hal_pwr.c...
! K0 U) z" V0 jcompiling stm32f7xx_hal_pwr_ex.c...1 G7 t- P5 a, G2 y! _5 x
compiling stm32f7xx_hal.c...
: k" @, I% D) ?& T, t3 |. }: ycompiling stm32f7xx_hal_i2c.c...
) q% m8 B1 \8 e3 Y" q; l6 ]2 @! Vcompiling stm32f7xx_hal_i2c_ex.c...
: K  |8 [; N+ w; Wcompiling stm32f7xx_hal_exti.c...# r, j5 R/ o1 P  A4 d! Q
compiling system_stm32f7xx.c...: b7 `6 c! X& V* @& t. g
compiling aiPbMgr.c...6 T" E: f- F& S" ~5 K
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory1 S+ L' x+ q5 @, u, m# ?
  #include "network.h"
/ H  Z9 j2 o" h2 ]/ Q3 N../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
2 Q7 o. P  J, r, t/ s( [# gcompiling aiTestUtility.c...3 c! \8 o' O, ^& W+ S
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory: V% @7 G6 Z& n
  #include "network.h"4 Q, i" v: W: E- ~- Q; H$ d) O
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error( V  H8 s) L8 {2 ?9 P! u7 h
compiling aiValidation.c...* ~  k$ i+ H) m, H, l. S
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
: T  O0 m; ^, e; D3 f. `  #include "network.h"6 X2 _; V: z- k, K, ]& R4 e
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error' j6 [+ E/ V  }) `! o  H$ J: ]
compiling pb_common.c...
2 p5 T4 U+ O9 u* _7 Ucompiling pb_decode.c...
& I" w& E1 H* o6 s) @- X4 acompiling pb_encode.c...
7 C/ P* A4 M7 r5 B7 u2 \: W5 q% x( Bcompiling stm32msg.pb.c...
* R/ \1 `! ^8 C, D" |"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
2 d# s% a- `& F5 S. X: pTarget not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'! |7 w) M5 g; X7 D2 }2 t
assembling startup_stm32f767xx.s...! W- v+ a8 M! B0 Q& J, _6 q5 C9 L
compiling main.c...5 `" N# X+ c5 Y
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
6 j( \; N0 l4 D. b  #include "network.h"
9 ?# @: k8 \/ ^0 x# L% D../Src/main.c: 0 warnings, 1 error
2 K! L, S7 j- [9 Xcompiling app_x-cube-ai.c...$ O$ G" J8 Y" T
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
9 G% q. \: }$ G4 Z  #include "network.h"& P2 W! t, ~1 ^) E
../Src/app_x-cube-ai.c: 0 warnings, 1 error$ k; f/ ?* W; D& [: ?+ d8 Y7 s2 Q
compiling stm32f7xx_it.c...
# K/ X) e6 Q' c  }5 H, |2 t; zcompiling stm32f7xx_hal_msp.c...
; q" U$ p9 L7 R- A2 _" }& \/ X. Gcompiling stm32f7xx_hal_cortex.c...
. f6 x! y& C$ e- u: O- Zcompiling stm32f7xx_hal_crc.c...
4 p' ~, y9 \( X9 Dcompiling stm32f7xx_hal_crc_ex.c...
3 c! F, n/ ^5 ecompiling stm32f7xx_hal_tim.c...
# b* H$ B( O8 \$ w4 _compiling stm32f7xx_hal_tim_ex.c...- k, J/ d% I8 {+ D+ Q& l. l+ r( d
compiling stm32f7xx_hal_uart.c...
  {: t3 N7 v7 U6 ^/ P8 m' ^6 p! W+ Acompiling stm32f7xx_hal_uart_ex.c...
& X9 k: ~; z* ~7 ncompiling stm32f7xx_hal_rcc.c...& w( G- a+ V4 }
compiling stm32f7xx_hal_rcc_ex.c...' y3 c, O) e2 ]3 g
compiling stm32f7xx_hal_flash.c...
* Z5 U4 e" x! J  e* Z: pcompiling stm32f7xx_hal_flash_ex.c...
, ]- j( O4 q/ W& ?6 mcompiling stm32f7xx_hal_gpio.c...
/ X  Z  h; T4 L+ b- `7 xcompiling stm32f7xx_hal_dma.c...
" E+ K3 R; B& V- l. Y% n" O$ b7 h. Jcompiling stm32f7xx_hal_dma_ex.c...) W9 O# ?/ J7 U
compiling stm32f7xx_hal_pwr.c...
! p, ~) V1 S& b2 V" }4 ccompiling stm32f7xx_hal_pwr_ex.c...
6 Y  A, a( m/ x# x$ i$ k" R9 Tcompiling stm32f7xx_hal.c.../ V# f( o$ p5 B( D" i. Q, \( q
compiling stm32f7xx_hal_i2c.c...# m$ B4 s3 w& b/ t7 i4 S8 T  I
compiling stm32f7xx_hal_i2c_ex.c...2 c3 C- I1 U2 i
compiling stm32f7xx_hal_exti.c...
7 N, u3 p3 E( V; u9 V1 U. U: scompiling system_stm32f7xx.c...
; t- p& S9 T  I" `4 Wcompiling aiPbMgr.c...
- i( n: p5 O1 }3 Y' w7 j9 z  ?% W! v% q. j../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory$ B3 d' z) w; Y7 N6 y
  #include "network.h"
8 f$ N) a3 c% {3 [: j/ Y- l. C, w../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error! Q$ ~) G6 ^+ \! G) l
compiling aiTestUtility.c...
* Q" u9 a! k9 F4 _4 x5 P../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory+ l( U3 D) k, n* ?
  #include "network.h"6 V: Z" x8 V8 q- D9 h
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error! u/ \# p6 E5 q
compiling aiValidation.c...
6 q+ r* j$ O7 P, J6 \../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
1 m, c8 [. J6 \% \4 K  #include "network.h"7 i) q' ]- E4 n3 l
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
5 i% I' a- r) e5 ]- [7 X2 w* e/ Pcompiling pb_common.c...
8 b% H, t6 @/ @compiling pb_decode.c...
( b( c% v8 {4 y* A) j; Ucompiling pb_encode.c...
9 W( G  }( B. p! Ucompiling stm32msg.pb.c...1 V  ~2 H! ^' \9 R: T, M
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
& C, \+ @0 D; U/ XTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
1 T+ \& _/ ]9 ^' F我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...

8 N& W4 Y& P6 z% C" e/ Y) b首先确保已经安装了AI库& a- w6 D1 s2 R: H# |' e  U9 C

9 m7 y. B$ m3 }$ }$ X 1.png 5 o( X2 c  U/ y1 M; Q
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。" |9 f6 f" E) }" e6 j

! L" ^- \$ t. y# b* [& W; `3 V  z! m( q$ f/ n# n/ y5 E
2.png
( L; c2 ~' z2 t( A( T; G5 @+ g
  |( B9 F5 T: |
8 q  ]4 n/ Y' v* `9 `( D7 [  @8 U$ `
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
* M" _$ U  K) u. J
1 K" ^, Q7 E; X& R; Z2 S# }) k 3.png 3 E1 y" {% z% q3 w& i
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
/ v* s4 }" m+ C& a( I4 Q多谢分享。。
6 x8 k9 G* Q6 t1 \- E5 @1 T
厉害了大佬
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
" _- c( k/ ^4 D3 _6 u我只看见MODEL.H5没看见STM32F767AI.H5,为什么
( Y; k' M& r% A2 N! {/ T6 H
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52! z8 u8 C) q* L( m) N
解释下输出结果的含义
7 e8 @! L# G# q. w3 \- q
输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
. f6 u, C- j; R  `. U% X: k' {model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
8 W2 Z- [% P2 Y" ?6 r
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
% V2 ~7 l8 d( \" v- I" M我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...

  c) X0 r) w" W2 R/ f5 T导入到工程的时候,没出现STM32F767AI.h5吗4 f) {/ X1 ?; G1 r9 C
123下一页

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版