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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
8 |2 E2 Y+ P& x7 M* ~
! \- x) A8 T! T7 l
1.jpg
4 E4 H' l* H: ~/ W6 r4 }* C
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。
# l8 T' M* [7 m4 ~1 [: P
使用STM32Cube.AI简化了人工神经网络映射
, w2 X9 p2 p) [; Q, }4 Q
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

9 M$ |+ L3 P3 e7 e, A! P5 |  T
提高您的工作效率

$ x  ?! z% M0 a8 H, s
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018
- q' c9 I  }9 Y5 |$ J  c2 e
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧

4 C* Q, d/ }- g/ w
2.jpg

2 ?* k8 {- j0 z: M: J
下载好后,CubeMx里的Artificial intelligent
激活Enable

* C! P- \2 d( _: W* ^, t& V0 u
3.jpg

1 W4 ]& R0 I' k( g! e9 m* y
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

! w+ ~+ U1 z3 X7 {" i
4.jpg
, i2 F" G! }0 n. x
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

1 y) K& k& K  M! v. {) C/ S
5.jpg
' W2 J7 G# o0 \
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg

% z' Q1 P( \0 _) N; |0 u
然后我们导入到工程里
7.jpg

, o* F! l/ n9 W. t
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg

0 m/ Q) \7 W4 `- L# t0 D4 L
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用

# [! K* k( \6 X
9.jpg

3 e( L% }  x) E% h8 ~4 ]
好了结果出来了,

( h& F# |- y3 u7 h& j
10.jpg
7 h- ?+ c- t. t# K* W& g) H" V
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
; o6 T+ Q7 e" z' q5 P& ?9 @
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

9 y+ O' ~/ }2 n! C  |! R
12.jpg

% S) j4 h: ?% h0 |8 A+ [( \
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。

% @1 Q. b- b/ a' T7 g4 R/ P4 I% f
13.jpg

% C; W  o* v% B0 I+ q
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
' G5 p) ]5 W4 \, F! F
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
9 Q! C! t. j3 f2 i7 e/ f$ ~
3 X" W3 u; D# e# j6 t
15.jpg
1 m" ]9 p$ d" ^) \4 z' e
0 v0 O( L5 y, X- z1 v
选择好Validation 和打勾 AI core

7 A, F! o& G+ ^1 Q) a" \0 P% q1 x: T
16.jpg

' I2 G; F* l: Q  w
然后在cube 左下方可以看到下图箭头 提示的插件功能

: M* i  j! P# w* s* o* h
17.jpg

: B9 o, \9 T' A; B  N* T* M5 @
我们需要打勾以下2个功能
0 ?) e" Y& g/ C
18.jpg
* @( \; L" _  Y" L
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。
* ~8 r& Z6 m! T3 A8 m& l
19.jpg
+ v" ~- S" q8 n* B
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过

# }0 Q9 p9 M, H/ ~) h* V# E7 h
20.jpg
: E# Q0 F5 k; z+ {
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

& |- p% V5 n: o) c* k( v* w& i
21.jpg

4 H1 b$ U, G! F+ o# \4 d' \2 F( _
然后配置MCU主频为216Mhz

! [3 W7 T6 y  u3 F6 ], A
22.jpg

" p5 P  t# |9 k: h0 S0 R1 |4 X6 q3 ]$ H9 H
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

% j8 D+ o. C! T4 s
23.jpg
0 k" y' @" n0 I9 ~! ^1 S2 K8 ]
然后在 AI扩展功能里选择通讯端口为串口3

: c1 f) T, x8 ?3 V. [
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)+ `) [; s6 E, C. }" s+ P+ I2 s
4 s& v! Y$ ~. `- D
25.jpg
8 g: j" F. Z) |$ \& L4 v
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件

6 y/ E! K% O. Y8 ^
26.jpg
, A! C  e; g' F! E/ e9 x" F
这里可以看到,基于AI训练好的模型数据列表。。。

* Z  u. f8 s' S1 D2 J2 b, g
27.jpg
! e- h) |2 n, `9 S
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
. Y  K- z. _2 z; Q, H  F6 \
28.jpg

# P% C( U/ F- S- Z
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
7 |' ]6 L) i% L7 j
8 z2 z2 P2 \3 n! C( W
30.jpg
) s5 K0 c8 b  t6 f( G
选择手动,然后选择对应的串口端口
2 S1 Q5 q/ b8 d
31.jpg

* S7 Y, t7 `- S1 q/ H( h; B5 f
这里可以看到验证已经开始了‘

% L8 |3 m% x# \/ f
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
9 H0 e  n  s, y0 M1 o
33.jpg

/ e  G; {0 d+ r3 {2 c  m
34.jpg
35.jpg

5 Q& `( N! ~( c. D9 _: f+ N: A
36.jpg
3 J( K" ^9 i9 y. _
# o+ [4 @: i0 U# z# X) g( C1 f
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
" n  Z& a7 T6 n( F5 Sassembling startup_stm32f767xx.s...- t9 H7 v, e) H2 y, e: [: ~1 [, j
compiling main.c...
" Y) z: s) D6 a# ~. h$ X../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory, P! ?- H0 e; p, ?& J) i
  #include "network.h"
! `4 c8 y6 g- W, b../Src/main.c: 0 warnings, 1 error8 ?5 m0 K' {8 q% Z& \. ^, a: ^
compiling app_x-cube-ai.c...
. D8 @1 U. Z, U( `../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory* p3 x! M4 q9 t1 p. W+ R
  #include "network.h"# j9 ?- K! q% ?" A1 c
../Src/app_x-cube-ai.c: 0 warnings, 1 error7 X* Q$ K9 M% `" Z) D6 L
compiling stm32f7xx_it.c...
, m' g* L- f; g1 Vcompiling stm32f7xx_hal_msp.c...* j7 Z3 v$ t& }) T
compiling stm32f7xx_hal_cortex.c...$ h# e6 u) D+ t0 }$ E: M1 G
compiling stm32f7xx_hal_crc.c...# ?' x1 y. D% x2 N6 X# V; ?+ w
compiling stm32f7xx_hal_crc_ex.c...' R; S, X) x" V1 K. y5 T% I2 z
compiling stm32f7xx_hal_tim.c...
! N8 I$ v# q/ x7 u: J0 V5 Jcompiling stm32f7xx_hal_tim_ex.c...! c! f8 a9 v8 T# O
compiling stm32f7xx_hal_uart.c.../ V7 q% W$ O  |9 ^  L% e
compiling stm32f7xx_hal_uart_ex.c...; E- Z" I) y- `- I
compiling stm32f7xx_hal_rcc.c.... t" p/ i" F1 d' A2 t6 p3 w! Q, C/ B
compiling stm32f7xx_hal_rcc_ex.c...* b$ x. o" i8 M2 z
compiling stm32f7xx_hal_flash.c...  @+ l7 C" P1 j5 g; E4 U7 _2 o
compiling stm32f7xx_hal_flash_ex.c...+ w# r4 F3 S1 v" Y& X) f
compiling stm32f7xx_hal_gpio.c...
) k/ e* s9 B9 A% c" N! T4 Ocompiling stm32f7xx_hal_dma.c...
6 D9 f- G/ t) _& S) y. p' lcompiling stm32f7xx_hal_dma_ex.c...; u* W$ S1 k6 w+ S0 v* h
compiling stm32f7xx_hal_pwr.c...
3 E, ~' I, ~: z+ ccompiling stm32f7xx_hal_pwr_ex.c...
1 L; Z1 z: ]2 t5 }compiling stm32f7xx_hal.c...
: ~$ l& G  O' r6 O1 B8 q! Hcompiling stm32f7xx_hal_i2c.c...
! s% N% g% V- A5 k: Q, a3 O0 Acompiling stm32f7xx_hal_i2c_ex.c...% C' p5 t- z  G
compiling stm32f7xx_hal_exti.c.... Y$ w& b: G0 D- w4 P& i4 j
compiling system_stm32f7xx.c.... Y) e# c4 r3 O# C/ Q. [
compiling aiPbMgr.c...
" F8 t: G5 I& a7 R( r../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory$ A' f0 Z+ _, ?4 ]. b
  #include "network.h"
7 o6 z8 K7 f! o8 s4 ]../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
" e2 h4 k0 A* i# @/ Jcompiling aiTestUtility.c...
: J  i7 I9 O) |; ^- ~1 c../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
, s, q6 E9 b1 ~0 B  #include "network.h"
; S% X" c7 w* O: x../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error, j7 j, x1 m: i1 H1 S% Y
compiling aiValidation.c...
$ o+ O# `3 w) d" h+ w: n/ ^' d../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
" x# ]( [3 _( d" P  Y  #include "network.h"
+ N- o; R: r% V! ]../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
! Y! d- ]5 }9 S6 L- Scompiling pb_common.c...
' e: y. k) A4 @compiling pb_decode.c...
' c5 o! A& P/ p+ ]; X* G5 }compiling pb_encode.c...7 O+ c' [. c' m5 ]: y) K7 s
compiling stm32msg.pb.c...
. f' p! \# z# n7 \3 L& p"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).3 x7 m* |( N# [3 S0 S' j) }' C% O
Target not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'4 E5 |# T7 Y! q8 A9 F* z1 d' B
assembling startup_stm32f767xx.s...9 I- j$ F3 @: l
compiling main.c...
4 u# ^  f& R% _../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
# y# ?  s( C$ j; z1 l" f- l  #include "network.h"! T# B& |" A8 F$ z6 U
../Src/main.c: 0 warnings, 1 error% J6 B: w7 P6 I% ^
compiling app_x-cube-ai.c...1 s- p$ g5 R: `; z3 X- [
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
. F$ |- l9 J! k2 R( ]  X: R2 F4 f  #include "network.h"
. v7 a$ j% [$ L: s../Src/app_x-cube-ai.c: 0 warnings, 1 error9 R0 k2 d9 W( K2 E6 c
compiling stm32f7xx_it.c...1 X' |7 O8 o, W  x2 S/ O) W! v7 n
compiling stm32f7xx_hal_msp.c...; ^6 d" W2 ~0 C' x8 z( O
compiling stm32f7xx_hal_cortex.c...3 X  Z% Z/ T. e9 W6 a& U% ?" ^
compiling stm32f7xx_hal_crc.c..." \2 A0 V' w0 {7 |
compiling stm32f7xx_hal_crc_ex.c...
/ g8 e5 z( N: Jcompiling stm32f7xx_hal_tim.c...% J! |# \3 @0 o  p/ a
compiling stm32f7xx_hal_tim_ex.c...
3 i: |5 h3 J' u( y" a9 J3 Acompiling stm32f7xx_hal_uart.c...
9 x; Q3 \' b3 j3 w1 ~) Ecompiling stm32f7xx_hal_uart_ex.c...8 ?$ j$ I' B+ c( t0 j
compiling stm32f7xx_hal_rcc.c...: |& \1 r1 f4 L" {4 ?
compiling stm32f7xx_hal_rcc_ex.c...9 P- k  U& B! [; W' N- W
compiling stm32f7xx_hal_flash.c...
+ K1 m; T$ O! i# l) Q% t8 p- Dcompiling stm32f7xx_hal_flash_ex.c...
* [* L* A8 d, f" Z* G8 v6 H# W/ F* e3 @& ]compiling stm32f7xx_hal_gpio.c...
- L4 P9 b/ v* |# C/ f) p5 Fcompiling stm32f7xx_hal_dma.c...
6 i" r9 C( s" j9 u( Y  z- W& R! J3 B& mcompiling stm32f7xx_hal_dma_ex.c...: a: B! h8 P6 ]8 g9 i2 {2 B, Y
compiling stm32f7xx_hal_pwr.c...' {7 o( d4 @" ]) a: |
compiling stm32f7xx_hal_pwr_ex.c...
' w4 I) g1 ?- x6 j' `6 ucompiling stm32f7xx_hal.c...
, h7 ^; b- H. w' [% k$ \5 l$ Lcompiling stm32f7xx_hal_i2c.c...
) A0 N5 m* S2 Xcompiling stm32f7xx_hal_i2c_ex.c...
: w/ b* o' g) `9 l2 J0 t& t+ }/ n/ `compiling stm32f7xx_hal_exti.c...
. _/ h% y  S" Q& J6 Mcompiling system_stm32f7xx.c...
- H/ _4 S/ k2 t" Z5 J1 ^compiling aiPbMgr.c...
* t5 w2 U0 C5 V+ Z9 z1 n../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
7 c/ I. I% @& Z# i! {  #include "network.h", ?4 N7 C0 f, S' z8 `- C/ Z
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
4 G/ `; O, [, ^compiling aiTestUtility.c...
! F; `. M; }. d../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
3 P% I+ I. D, W  l  #include "network.h"; H* M' {; p9 }
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
" R  Q2 x- z9 E- M' fcompiling aiValidation.c...
+ M# u$ {; _) T1 |../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory6 _& x  K, w9 r' t' F- S+ T. O  t
  #include "network.h"
" o* D( Z- N  t/ b../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error0 k! I! B; y# p# Y
compiling pb_common.c...' L5 i1 e" S4 T9 e
compiling pb_decode.c...
9 F) r- I, u  n4 V) Bcompiling pb_encode.c...
4 F) v$ Q. d& V+ W* }1 ]compiling stm32msg.pb.c...+ B* K. N  e# b: Y
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
, R$ P2 q5 U$ R! s- TTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
+ p( u9 r/ G) ]/ z$ K$ h5 i我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...

$ ]  u& W1 n1 }7 C首先确保已经安装了AI库
; D& R+ t6 i$ G, b1 r
+ n# B0 s* g: |* U4 x 1.png # @* z& O. C4 B( P' a
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。& Z9 U/ l. e" \3 X) j0 C

$ J& {) w+ k5 F' ^
3 }. B3 I; [7 _; p6 N3 s  K 2.png + ^7 I3 @# o7 X7 o7 ]9 m: c" @

* D7 n; P$ F9 g- E# R# I  W) S, F/ z
+ u( R, P. ?- J" v+ ~. o  t8 z5 a9 k$ ?3 ^! s; j. x/ H2 q
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
: I. m8 u. q. T# @) D+ {6 X
- @: j' t( H# f' t 3.png   \0 `' O* @+ d  B' 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
2 {8 p! R$ i+ R2 m. {' l2 K多谢分享。。
& I3 Z1 n& q3 `0 A5 Z0 F9 T; C0 f
厉害了大佬
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:145 R7 Y" C# J4 r  u4 P) w0 j1 u9 @
我只看见MODEL.H5没看见STM32F767AI.H5,为什么

1 l# m  X8 P/ f; `6 tmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52, T# ~/ ?  G8 M& K& Y+ m) x  W
解释下输出结果的含义

! {. D/ _. B% m输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11
5 Q) r1 _- Q! E# t0 x0 u6 Wmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型

( h/ c+ f& ]3 `+ |5 X我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02" n/ L  @' b8 p6 q& i, l
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...

2 b& b% }+ D  `5 I( x2 L( _导入到工程的时候,没出现STM32F767AI.h5吗( G0 l& X- y0 |! n
123下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版