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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
" z( h' Q4 V& P+ h
1 }. L, V$ U/ ]: x0 Z3 K
1.jpg
" _/ ~7 O; `9 U( [& ^% C+ u
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。
3 F/ t5 K. u7 ^* c8 `' @8 g
使用STM32Cube.AI简化了人工神经网络映射

3 S' U% d3 g1 c$ y+ {
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU
( e/ R- p5 m0 y6 m" A
提高您的工作效率
+ Y, Q* F7 I8 g* X
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018

# A' ~2 n$ p7 w# ^
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧

! m* p, U: i( w
2.jpg
5 r8 A' C! h0 p( J* I( c2 z7 {
下载好后,CubeMx里的Artificial intelligent
激活Enable

1 ~. y$ M& a* [& x1 l  ~+ {
3.jpg
! z7 l4 y) H. W' ]
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

* @2 G9 C" f6 ?* @
4.jpg

5 m8 E) z$ I6 x
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

  |( ?: L4 I1 w: l% d. W: @
5.jpg
8 u5 D+ R7 Z: d+ c6 K5 I
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg

  M. s3 L5 l$ g7 o8 Q. S* S8 q1 u0 t7 K
然后我们导入到工程里
7.jpg

" F5 `* }0 b0 Z3 \4 f$ W
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
8 }% {1 F# N7 ^3 e" Q( D' u# _
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
' ~' s! Z3 j: l2 I2 _, P( v9 E
9.jpg

. z( U  V8 y- }( U: i, g  G. y  T
好了结果出来了,
5 i( q8 V9 Z* k; D0 n0 p# e  O
10.jpg
& C; o% H! d! J; [% x
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg

4 m  v9 m% H, R/ X
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

' W; q/ G6 z8 k
12.jpg

2 Z, o# q. J# L) c
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
0 J! q$ C" T5 u( c+ @' E
13.jpg

  O7 y2 c* i4 Q8 B& j0 i* P
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡

; r# T# E5 z( n" e2 G
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
" Y8 f+ F! d+ Y+ L( N) z2 y
/ M2 j7 y: F' c* @! I8 B5 p. F
15.jpg

- B9 U& N% p. E
. K: z' n* s. g# W6 o
选择好Validation 和打勾 AI core
4 \2 a3 W3 z: b
16.jpg

; R% D6 M1 B, o8 p
然后在cube 左下方可以看到下图箭头 提示的插件功能

. O' x+ L$ T6 ^8 P
17.jpg
. n$ c& `! V  [. y
我们需要打勾以下2个功能
( s7 {, |! D( W  o# a  u" P
18.jpg
1 r) b6 g8 e. |7 }. N
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
( D2 @: H! P8 g7 _0 J6 Y
19.jpg

; }. B, |# i, J' H- E
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
. C& V; Z/ x0 R8 ]' u
20.jpg

. u5 Q/ c) s8 D
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

3 f# H8 O8 I9 g2 E
21.jpg

1 H( _& \6 J7 ~4 d
然后配置MCU主频为216Mhz

) M+ k/ w  d" b" J7 j0 U; \
22.jpg
" i) N+ H( G% A  _
- ?' S, n& q  z- V: R3 V
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
" P' ~5 b2 q  W' D7 Q
23.jpg
6 s9 C% H, i( `% c5 ]
然后在 AI扩展功能里选择通讯端口为串口3

  D* P' r8 J+ ^' S* Y# b
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)3 I- Z3 N# k, m0 V; y; U) [5 ~6 |

' N. y+ s9 P$ T# f3 o
25.jpg
" `3 g( n2 d: k+ S
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
6 l2 d& b; p( Z/ t  Y
26.jpg
4 X1 x: Q" v$ @% N
这里可以看到,基于AI训练好的模型数据列表。。。

3 m* C: C: F  K) I, L
27.jpg
* n* C- B4 R' e/ ~1 w3 l6 N4 ]
好了,配置位STLINK,然后编译好就可以直接下载到板子上了

) g4 g2 _2 N# W) d
28.jpg
3 K3 Q7 \, s9 w& k" w
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
( S- n  B9 I( p" @
9 i4 o: _9 _; `, g" l5 }
30.jpg
1 Y, ~" l8 I; Z0 ]+ k$ P% _
选择手动,然后选择对应的串口端口

4 r5 S# V) |2 C, ?7 U' g
31.jpg
- {! R3 W0 j" [4 O. }4 V+ F
这里可以看到验证已经开始了‘
’/ w( S: L! w! J9 n% j# B' |# ]# v
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据

/ F: ~! K, L1 K! K5 U
33.jpg

7 g" i, u# n  h. ?# u) \) B
34.jpg
35.jpg

, z) N# o! d: R
36.jpg
7 X6 W, P  j+ B  T

3 `7 s/ a- r! j
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
赞 收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
1 u* D& ]+ R4 Sassembling startup_stm32f767xx.s...5 r+ P: p1 |7 W
compiling main.c...
$ P# @( n+ ?3 s6 c& E../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
6 G% h' T8 S2 W$ x  #include "network.h"/ G( d  M5 q* k4 y
../Src/main.c: 0 warnings, 1 error1 ^+ t' \' G4 V& F$ F; `
compiling app_x-cube-ai.c...
9 ^9 h* j$ U8 z7 ]6 a6 ?: R../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory4 C0 A- t7 E" R% K
  #include "network.h"
7 g% q; P6 K% h1 A1 Z7 Z7 @../Src/app_x-cube-ai.c: 0 warnings, 1 error- \7 U* Q" t% g. i' r
compiling stm32f7xx_it.c...* X8 Y5 L$ K" ]# _( Q4 C
compiling stm32f7xx_hal_msp.c...2 ?! @* M0 _9 I5 m5 \4 d5 L
compiling stm32f7xx_hal_cortex.c...
0 g  Z# e6 S: bcompiling stm32f7xx_hal_crc.c...+ C+ N/ a9 \. ?" |6 o& i+ j8 e
compiling stm32f7xx_hal_crc_ex.c.../ j" o  m* u9 j% B( R
compiling stm32f7xx_hal_tim.c...
3 T8 @/ u( F3 ~" Wcompiling stm32f7xx_hal_tim_ex.c...
5 x( J. l" r; p) d3 ecompiling stm32f7xx_hal_uart.c...6 ^- I/ n5 b8 q8 x' d1 x$ f. u
compiling stm32f7xx_hal_uart_ex.c...
5 V1 l' ?# P# i6 E4 K: R( Lcompiling stm32f7xx_hal_rcc.c...
. d" J1 }8 I* i0 I2 i4 L. qcompiling stm32f7xx_hal_rcc_ex.c...; W' [9 S) _7 U6 B. w
compiling stm32f7xx_hal_flash.c...
" ?5 J0 W: ?2 F  {compiling stm32f7xx_hal_flash_ex.c...% U. W3 ^. R, L
compiling stm32f7xx_hal_gpio.c...& m% A* Z  d+ o2 R2 ]& J  Z. g1 B
compiling stm32f7xx_hal_dma.c...  s# c. p2 s4 y2 M: {
compiling stm32f7xx_hal_dma_ex.c...7 ]& {* z. a) O) Y
compiling stm32f7xx_hal_pwr.c...! F* k1 u  T/ Z# h
compiling stm32f7xx_hal_pwr_ex.c...
' N7 Q, |7 M0 e" I; W2 d/ ccompiling stm32f7xx_hal.c...9 P3 K+ Z9 u" F  M
compiling stm32f7xx_hal_i2c.c...2 o  M$ R4 e( y2 }+ B7 L! v) L# o6 ^
compiling stm32f7xx_hal_i2c_ex.c...
7 ~: q7 d; ^4 g+ C( jcompiling stm32f7xx_hal_exti.c..., c( ~; J, H% v& x6 e4 c
compiling system_stm32f7xx.c...
: T$ {4 M3 n( ~) d; xcompiling aiPbMgr.c...
+ j( [8 c. X# Z../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
$ S0 V, R% e2 `  O  #include "network.h"
1 _0 B  g3 \# x../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error7 }% m0 Y( k& \# ^
compiling aiTestUtility.c...( j  [# \9 ?% ~* q$ c. H
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory1 Y: m7 C# r0 ]. ~  U0 M% ?
  #include "network.h"
$ n! N! r0 O1 t, }  m  N../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
4 C5 ^4 D, ~5 O7 ~5 ~% _compiling aiValidation.c...
- j& X1 j' ~( S. w../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
2 ?. \" s0 _/ C  #include "network.h"# L0 M. }- e. \) l
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
) A1 w+ N+ a4 Y9 }7 \compiling pb_common.c...
5 s8 x7 u$ U5 D  ]( g* n& n# b) zcompiling pb_decode.c...
, [. h) V7 x4 v: A% Z( @, Vcompiling pb_encode.c...
/ b* C) n( ?* E/ c% wcompiling stm32msg.pb.c...
( x+ z2 O$ E6 }, q: d( `"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).+ s* N) }9 p+ b
Target not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'
0 \* y! E) [2 m' Zassembling startup_stm32f767xx.s...% b; Q& ]7 z$ W
compiling main.c...: p0 _5 Z' x; T
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
/ Z4 h+ d" O* P8 }- P  #include "network.h"
' Z* x7 p  b* s; |9 k* m; z/ Y../Src/main.c: 0 warnings, 1 error+ `( P: Y& Q% w1 k6 W0 r+ {) P
compiling app_x-cube-ai.c...
, r( S- B/ ]* q9 u! V7 b../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
, V6 \4 d1 L5 r8 W+ {& ~# m4 j  @  #include "network.h"
8 T& W  F* x9 H# P- s' U../Src/app_x-cube-ai.c: 0 warnings, 1 error2 y# v8 U# n4 {" O
compiling stm32f7xx_it.c...
  k: s5 j( n6 Y( @; X1 T7 @% {compiling stm32f7xx_hal_msp.c..., x. ]$ s' _0 C. Q3 i7 r
compiling stm32f7xx_hal_cortex.c.../ d8 g( c/ J% a! F; U
compiling stm32f7xx_hal_crc.c...) v2 s7 o1 `% L3 {! {
compiling stm32f7xx_hal_crc_ex.c...8 ~5 e; C; Z0 b4 Q& S' r: n1 l
compiling stm32f7xx_hal_tim.c...
+ E0 F7 S& h( e2 _0 b0 c; ocompiling stm32f7xx_hal_tim_ex.c...' R* t7 p. i9 u% b5 i
compiling stm32f7xx_hal_uart.c...
; v0 Z% w" \* k; b, C; Y7 `; Acompiling stm32f7xx_hal_uart_ex.c...
" o  |4 n# u& m& Z' i" i* ccompiling stm32f7xx_hal_rcc.c.... _! y1 A8 A$ k% R
compiling stm32f7xx_hal_rcc_ex.c...- D2 v" g& u; S/ U
compiling stm32f7xx_hal_flash.c...$ e  a1 m+ F' e3 G
compiling stm32f7xx_hal_flash_ex.c...# v9 o3 h, n7 f. r
compiling stm32f7xx_hal_gpio.c...4 w7 q* v& Y& o. E
compiling stm32f7xx_hal_dma.c...
3 M( m6 J6 ]. Dcompiling stm32f7xx_hal_dma_ex.c...
9 j; G- u& C" L7 }compiling stm32f7xx_hal_pwr.c...
% f2 E$ [& I# vcompiling stm32f7xx_hal_pwr_ex.c...
+ j' R: r( K" w4 C  m9 _  Zcompiling stm32f7xx_hal.c...5 ^' _. g+ ^9 L4 t6 x' o
compiling stm32f7xx_hal_i2c.c...! O5 C8 w0 F5 D" D
compiling stm32f7xx_hal_i2c_ex.c...
$ K6 I& a( x3 F3 F6 s2 pcompiling stm32f7xx_hal_exti.c...
0 A: k: u9 R5 Y8 {" |compiling system_stm32f7xx.c...
2 U' A. s% c; Mcompiling aiPbMgr.c...9 a( c/ ]( L5 i; Y9 T; u1 ?2 s
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory# P* L1 @$ O9 Q/ `, f$ E
  #include "network.h"
1 m; s5 w# B& Z$ i' \( J../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
. x1 M, Z- g0 c5 pcompiling aiTestUtility.c...9 X7 e) w5 L0 e7 @4 T# }! g% o
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
/ t% n! N0 H* Z! u/ P+ u3 D  #include "network.h"& ~" i, C. i/ |) x" ]! e/ g
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
' }2 `) L% f) H; G# ~. Y' }/ Pcompiling aiValidation.c...
5 ?) }  v3 |( F* S! y../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
+ q/ H5 \8 ^7 k9 N: e! J  #include "network.h"" ?  U5 ^, B8 C- ~+ u
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
; g, e4 e- H4 g* Y$ _compiling pb_common.c...
0 h0 z" S6 @( G$ ^5 S9 @- x2 pcompiling pb_decode.c...4 ~2 L  D7 d1 i; ?
compiling pb_encode.c...1 f" K1 d6 I8 e5 Z; p3 M
compiling stm32msg.pb.c...: T7 _, Q" e' e- n
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
+ \  c7 _8 {7 M  h  ]/ pTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
# T5 H+ l$ G# S% I' I4 |- G/ U我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...

% I+ L7 \) P/ U/ k6 d, ]首先确保已经安装了AI库" ]; q; g6 f. V( ~2 H  h% P5 ]6 {

  A% ~- ?" Z9 E) W9 I# s$ y5 R. Z 1.png
" m' r" N' H& ~- C5 |使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
" v: D) Q  f) k$ b' b0 b
8 I& \! n. g' _  Y$ z* a
4 H: f- T) }. P% R) h6 @ 2.png ) q9 P: L2 ~, v1 [, [6 j
- W! ]) d2 i% s1 Q( }. E' |0 j

0 y- e4 d( H1 I2 ?. z1 V$ E* o6 G6 n0 m; @4 R) Q; P
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
+ `$ u; J! x& _. \* R
5 o$ d! m8 R; B+ g6 ^/ V 3.png
  i5 U$ n1 }2 ~: \: `7 p  e5 M% J
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
6 w( o2 w8 _, C  y- P# Y0 v/ k多谢分享。。

9 A" k2 r" U+ }& M) \厉害了大佬
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:141 x0 o4 `, Y' m' k: r1 O
我只看见MODEL.H5没看见STM32F767AI.H5,为什么

3 x9 U: V! v( Y- N' o$ s& `model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52( a0 H* P) x1 Y- I; b
解释下输出结果的含义

( X) U8 n' u8 q" C; t6 I; O输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:112 L7 Q" K9 S6 q& u$ b
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

! v8 I/ t8 f: n5 z) q我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
  p9 j2 W0 X; |) e1 t9 B( H我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...
7 s4 U9 l8 n" t9 u* t: m
导入到工程的时候,没出现STM32F767AI.h5吗
' {! K  B5 M8 o
123下一页

所属标签

相似技术帖

官网相关资源

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