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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
5 I! _& d3 j. i9 k  d3 w  u

3 g$ u$ \& s# P- O2 J6 c* F
1.jpg

; P$ E0 o2 @0 _' V9 `" P( C( z" Q  {
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

4 t, H5 k1 y1 a
使用STM32Cube.AI简化了人工神经网络映射

  }1 l7 Z+ L8 k; k6 ~
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

# t2 [8 _' H& f1 K6 R, P
提高您的工作效率

- M" M) x9 y0 s7 N
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018
2 N: w7 z6 K6 @, A5 ~
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
7 a3 `, w8 ~. f# m3 D
2.jpg

- C" B  x' y4 V# ~
下载好后,CubeMx里的Artificial intelligent
激活Enable

, N7 `9 `$ I7 S
3.jpg
5 E& m$ z& e: {/ D: _2 q5 u
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

0 Q( L/ t: k) U: C$ U% a* U3 N
4.jpg

: d, H9 l8 V- H8 W, d+ r3 U
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

3 w" z; \* z3 C6 X& m' z' E
5.jpg
0 [! G/ a! q% h  y+ H
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg

! I5 o9 _% h0 g4 N6 E& c1 Z
然后我们导入到工程里
7.jpg

, d5 z2 y8 @5 R1 k
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg

( A/ A/ t. Y1 m+ P6 |% m
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用

5 e( U8 P+ x. c' b
9.jpg
. L" B2 L5 j8 c2 t& O6 E
好了结果出来了,
9 z! l0 `" l, D% \
10.jpg
/ F$ W: [3 K! A; ]! t2 u( B8 a6 v3 l
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg

( `. n$ F* r! T4 F
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

+ M+ S( X" X. P/ z
12.jpg

6 I" `5 p% t; M/ U
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
7 C: c3 `3 Z7 J; t3 d; p2 F
13.jpg
4 j5 O& U% g3 P  E
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
, q3 L2 T4 D+ _: O3 K
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库0 d; |( z' ]/ o+ x) D) ?' O* R- g9 F+ T

' g( l& H3 c, u! z
15.jpg

3 O' B  Y+ d" _& l4 _5 X% V  V; M5 i; [3 Q3 L% G- R5 |: h
选择好Validation 和打勾 AI core

6 g  o: _  O& p
16.jpg

$ S3 F) ^  B5 U
然后在cube 左下方可以看到下图箭头 提示的插件功能

' p0 v5 o! L7 I" t1 v
17.jpg
+ }9 @, }' r' E8 V+ z
我们需要打勾以下2个功能

% H1 Y! w5 o1 F# S: |5 N8 y5 B% g
18.jpg

# Z: X5 n9 j0 l- d+ f
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
  ]( n; h; h! o; ~! i
19.jpg

+ f; P7 K# \2 ]4 u8 {' W' U
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
) S, y2 h8 q# \0 S! }
20.jpg
$ E* J" }5 I- J( O% k
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

- N. f; F& i( s$ z0 L5 l
21.jpg
$ h; i4 q# L: G: I1 M/ s* v
然后配置MCU主频为216Mhz
  f" m# B9 [. K. m% Z
22.jpg
; G) l6 m, P/ E5 d4 L) A- _
+ G1 i+ }# U+ Q& Z( s1 r
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

4 T0 G' I0 P5 B
23.jpg

2 H) `4 t% ~8 f
然后在 AI扩展功能里选择通讯端口为串口3
" t) w& o9 |" H" ]6 A# |+ b
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)( f- q% q7 Y$ A7 O* _2 w. L

: f8 _, J, F# z2 ~$ n9 e+ ^5 g1 _1 u
25.jpg

1 m6 Y% W3 _, H% ?
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
, U8 d: y/ Y. J
26.jpg
5 T! o0 F$ c9 ~3 `6 Q3 Q3 o
这里可以看到,基于AI训练好的模型数据列表。。。
* h! E) I/ P' x7 O3 h% m
27.jpg

  |, q3 s# q: }$ r
好了,配置位STLINK,然后编译好就可以直接下载到板子上了

  P. u- g- `% F/ G4 l! m
28.jpg

  x  F- r. _! @. N3 \/ c0 ]3 F
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target

/ ~6 E4 w/ z5 ?6 |7 T* n
; G/ u. {" K  S" v7 ?8 X2 E, X
30.jpg

; G( q: B9 V+ W
选择手动,然后选择对应的串口端口

6 m" k  R0 ]  d
31.jpg
# o. y2 k# A/ j! z7 y1 H
这里可以看到验证已经开始了‘
+ E% K7 X# E. [! P9 l
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
, X9 F) B* K5 |, I# |0 x
33.jpg

# [6 |' d( _0 _: |: d! ^) W0 k
34.jpg
35.jpg

5 q5 j6 }# ~9 z. F  d; W" h
36.jpg
9 q7 o7 @! L+ r3 O! U! q+ Z

8 i  s5 B. Z3 z, ?; I. Y
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
3 @/ k9 q9 W. @" P% M% g2 ~& }assembling startup_stm32f767xx.s...; M+ K" k0 k5 u
compiling main.c...' s* h4 n0 \" M: U4 M
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory: y" [9 b1 s9 \  c. }' y
  #include "network.h"/ `5 v- G: j1 D9 |
../Src/main.c: 0 warnings, 1 error2 T+ s( G( D* ~' u. Q  p
compiling app_x-cube-ai.c...7 y  A: M; x! |1 J! d1 ~
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory" _! d5 p1 }6 {4 u' u. o
  #include "network.h"
  i1 k% n. b- u8 V, A: a../Src/app_x-cube-ai.c: 0 warnings, 1 error
9 \7 _4 }& s1 d; j# y9 H2 U1 bcompiling stm32f7xx_it.c...
5 W3 G! m- G8 k4 v' f2 f! D3 X4 Tcompiling stm32f7xx_hal_msp.c...
$ K; T, D9 `, S- T* W% j* Pcompiling stm32f7xx_hal_cortex.c...# r& z0 k! A: j3 ~- g, |( ]- q
compiling stm32f7xx_hal_crc.c...- m+ L1 i9 u6 S- T, A4 \, K) L
compiling stm32f7xx_hal_crc_ex.c...0 q7 m' l: J, D5 ?+ T* ~) x) k6 N
compiling stm32f7xx_hal_tim.c...
4 {6 p) E! E3 s" m* k: U; S1 Gcompiling stm32f7xx_hal_tim_ex.c...& h/ k$ D$ z6 `' E/ k+ F/ O
compiling stm32f7xx_hal_uart.c...* Z# U5 ]6 M2 e( N5 l: H
compiling stm32f7xx_hal_uart_ex.c.... Q! u4 z0 v9 N8 Z+ A2 @# @
compiling stm32f7xx_hal_rcc.c...
* `* J) G2 h" Y5 K8 x" @compiling stm32f7xx_hal_rcc_ex.c...7 n& I$ D% y4 L/ }
compiling stm32f7xx_hal_flash.c...2 c- h; v' E/ s" u. j) ?' f
compiling stm32f7xx_hal_flash_ex.c...$ a4 B) G. Z8 l0 G
compiling stm32f7xx_hal_gpio.c...
6 I% M  n6 N) B" a% T0 w# ecompiling stm32f7xx_hal_dma.c.../ C8 G3 E% |2 I) S; I
compiling stm32f7xx_hal_dma_ex.c...
" B7 O( ]* d- `; zcompiling stm32f7xx_hal_pwr.c...
& M, v/ D. m/ @. Ecompiling stm32f7xx_hal_pwr_ex.c...3 [1 f  V/ g+ F0 W% J# {. t+ M
compiling stm32f7xx_hal.c...9 R3 w: X  o* ^3 K8 T
compiling stm32f7xx_hal_i2c.c...
7 k! h* o; ~9 k4 n2 [' _9 Ocompiling stm32f7xx_hal_i2c_ex.c...
7 }! ^! u4 [/ R( n5 Gcompiling stm32f7xx_hal_exti.c..." p4 w# V0 ?* |* n
compiling system_stm32f7xx.c...1 o8 b, `1 A# c0 k1 O8 \
compiling aiPbMgr.c...& w( Q( a0 D8 u1 r) W/ C' ^) y
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
7 c* b7 Q+ D; R/ J+ B) R  #include "network.h"
" Y0 v, j. R; H5 F. A../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
8 C5 M) ~# E  A6 b3 Wcompiling aiTestUtility.c...
7 b9 v+ h: E6 D( }3 _. Q2 {../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
1 O8 A( V: l+ A# O/ e1 [; D  #include "network.h"
3 s: Y% k* |6 }6 R! S/ ]../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error% p$ P- N" K- R* k$ X
compiling aiValidation.c...2 w' X, }" G, P" s
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
* R! A; U. F" |2 |  #include "network.h"$ F! y' a$ U8 \% E4 i/ U
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error& Q% S" z( u! S2 f
compiling pb_common.c...
+ X5 o6 E$ ]( a$ W0 P$ i5 u# gcompiling pb_decode.c...
( p4 G% s9 T, ucompiling pb_encode.c...
5 g/ e- t3 F# r% N9 Qcompiling stm32msg.pb.c...3 {. I8 e% ^7 D3 M0 c3 A# N- U
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
% `" Z; V# F0 R; r& Y/ U% x4 S/ ~Target not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'
- C  A4 l+ T, k- W0 v) yassembling startup_stm32f767xx.s...
) A+ @  \; R" }6 r/ A3 k6 Ecompiling main.c...
/ e! C; _' ?: S( f; o../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
: g, j' {& X4 `8 B3 p9 ?) i  #include "network.h"
6 c" p/ O$ _0 ]# T# L, g- }../Src/main.c: 0 warnings, 1 error$ G  N% u1 N  t
compiling app_x-cube-ai.c...6 a$ P' r( r. G4 d  K
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
9 ]: V2 }+ {. n( b2 m6 a" U  #include "network.h"! f4 v3 u( ~4 X  k; ~% ?
../Src/app_x-cube-ai.c: 0 warnings, 1 error, s" O. U4 b1 r0 q; W; O
compiling stm32f7xx_it.c...; V  H& U6 K" q
compiling stm32f7xx_hal_msp.c...
1 W8 {! {1 o, `, |% Bcompiling stm32f7xx_hal_cortex.c...
: z. ^- I( S+ d1 Z& Acompiling stm32f7xx_hal_crc.c...
0 z) J4 W8 V1 `, R+ Wcompiling stm32f7xx_hal_crc_ex.c...
. \4 y. K1 q# icompiling stm32f7xx_hal_tim.c.../ f# j, W6 b8 p  c& q) `
compiling stm32f7xx_hal_tim_ex.c...# E2 f1 m, `; Q, M
compiling stm32f7xx_hal_uart.c...
; r2 [; o2 ?, R. u- c/ y1 Acompiling stm32f7xx_hal_uart_ex.c...% w: r& L" C$ I( q! [. G
compiling stm32f7xx_hal_rcc.c...
, x2 Q1 o: M3 ]$ Kcompiling stm32f7xx_hal_rcc_ex.c...
4 _( i6 Z& ]9 y* |6 Tcompiling stm32f7xx_hal_flash.c...
9 G' S6 ~# V7 |compiling stm32f7xx_hal_flash_ex.c...7 I4 V& n& w$ {* Y( n" v
compiling stm32f7xx_hal_gpio.c...
% M- G: y4 d. ]# zcompiling stm32f7xx_hal_dma.c...6 }; D: j$ x# Y( x$ _/ E8 m  [
compiling stm32f7xx_hal_dma_ex.c...
1 `# j& d$ a8 v* x1 x; C1 Ecompiling stm32f7xx_hal_pwr.c...9 R8 \3 k- Y0 \4 ^. j3 x" b& u4 Z+ K
compiling stm32f7xx_hal_pwr_ex.c...
2 Z6 D* X5 g2 F8 q3 D" G# bcompiling stm32f7xx_hal.c...+ A& T3 p& B5 M. G3 D, U
compiling stm32f7xx_hal_i2c.c...1 t1 ^2 ?! I1 K8 y0 o. Q/ ~
compiling stm32f7xx_hal_i2c_ex.c...
- q4 `# ]/ a9 xcompiling stm32f7xx_hal_exti.c...
: P3 [0 x" R$ c$ |: Ocompiling system_stm32f7xx.c...
5 y( \" a0 d1 r$ f8 ocompiling aiPbMgr.c...
) m& u; S+ N9 w2 a, T  E../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory& |! |; ?  K0 H* r" S7 c  h- [6 A
  #include "network.h"- a5 Z. y3 H3 e2 ?
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error  P& ?) M( I7 J0 G" C+ m3 c0 Z
compiling aiTestUtility.c...- y$ t6 T/ t2 _7 c3 }
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory3 g0 X5 @9 r, r
  #include "network.h"
( x5 U2 y8 ]7 i3 C, i3 q0 @/ P8 F../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error, b7 U$ Q! Y6 f  _% F
compiling aiValidation.c...
- h/ O7 ~6 E! Z" z; B: _../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory9 U0 }: m# t$ l- U, C' Q" Q& J
  #include "network.h"
, g0 q7 z: S) z) X2 ?% O1 s../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
6 v% J7 B& t5 w. Ocompiling pb_common.c...
" t- {+ m) {. u3 Jcompiling pb_decode.c...
' x9 ~! _/ h9 e( d# J; \compiling pb_encode.c...$ N5 L- ?2 O" A& U/ m$ x* V  Q
compiling stm32msg.pb.c...0 x5 N& S( G( D/ s$ k; ]
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
) G# Z  K9 A# \7 [# t4 K; DTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
6 g( p( D; v  U8 P! ]我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...

) o% U1 [9 b9 n. N/ L% n( y首先确保已经安装了AI库6 F6 {0 ^; A1 I) n' W
5 j, R# |4 P' r/ S) R, t
1.png / J* Q0 O) u; t1 J' ~
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
& W  [6 e& @3 N% T9 }/ q6 b' t, P- J! }$ \, j- R9 U

; ?4 v* X% B+ M9 T: d) L 2.png $ `' ^6 q# v7 w% u* S. }$ B
) k8 l4 v6 X% }- x; X
. E+ g) k1 p6 w3 m# }8 o

) F. F+ J" `0 |1 o) a' e如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
9 P3 U( A. C0 T9 m5 W( J
$ I5 S7 Y* M( s7 _ 3.png
0 R8 e, L  @* @6 v
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
; H/ A  Q% @# }* ]; S( h# Q+ S多谢分享。。
! p5 B! G3 p8 o4 G& D2 H" p0 H! [+ b
厉害了大佬
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:146 i* _& @7 j) N5 c1 h( ]
我只看见MODEL.H5没看见STM32F767AI.H5,为什么
6 i0 |3 e" ]/ P9 X* L
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52
9 r% D9 S6 R8 N解释下输出结果的含义

4 B$ c4 o- u  D8 o7 L输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
6 n$ |' r, V3 G* v) rmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型

) k7 A/ w% W+ Z" t9 [* P+ m我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
+ Y2 C% O4 n( Z% T/ R我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...
2 _3 \7 t# r6 B4 ]
导入到工程的时候,没出现STM32F767AI.h5吗# b: d7 K2 ~, x6 x+ j5 W
123下一页

所属标签

相似分享

官网相关资源

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