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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
' X3 X4 s  a5 M3 S! D
5 P; R( i" j# S7 \# Y6 N
1.jpg
% H. s" o) x. B8 u8 _5 r! x* X
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

8 F; `. y, {$ A4 e% @4 M& T
使用STM32Cube.AI简化了人工神经网络映射

" L  t  M9 U0 S: ]' A
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU
0 ~; P, \( u: _2 _; S* D* e  p+ |1 l
提高您的工作效率

" b$ _9 i' N8 a: q! R+ P
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018

! f5 n0 R4 s6 G6 \
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
8 G8 k, r( `! o: i
2.jpg

( u' s3 C8 ~" Z" [& q
下载好后,CubeMx里的Artificial intelligent
激活Enable

2 [* T# l6 g9 q( e
3.jpg

# [- v7 {& J; \0 L9 M4 \" Y( ~( x
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

9 q( _  I% r( k+ M4 u! G
4.jpg

7 z* o7 L. I9 I. N( J
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
3 O$ E$ C& J- |6 B5 z; r
5.jpg
" U2 o5 c# o. M& p- S- v( C
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg

% J8 B3 Q+ {+ D' Z5 a" B; ?! x8 m
然后我们导入到工程里
7.jpg
& ~+ q* S- S* F/ Z
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
/ r' d% U# T' I) U
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用

6 u+ P! M+ h% ?% x
9.jpg
0 D5 S0 R) F5 L) Y/ V/ j
好了结果出来了,

0 W6 u' ?& d9 }/ R
10.jpg

& s- m: g$ u- w. c, Z
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
5 f- e- I! I* p+ i! [3 W
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

( V/ ~9 Q. t% F% u+ U
12.jpg

" Q6 [3 c. b! c
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。

# Q: U" c* G% ^! O6 G& v% M% p
13.jpg

# P; R" \2 r8 f. A2 ?1 G
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡

* u# o6 G) v, W2 C6 z2 D# c8 [
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
" J2 ~8 d* t, V1 ]6 Z5 R  t6 x+ P$ m2 V" E
15.jpg

' @- R! l; y/ ^1 m) s
& M, \& l& [% X# p$ N( w/ I5 h
选择好Validation 和打勾 AI core
& r- [$ I1 l. {0 }  ?# R
16.jpg
9 `+ T3 y- g* h* e; O( r+ S. D7 e
然后在cube 左下方可以看到下图箭头 提示的插件功能
  O- m1 d, x& i& `
17.jpg

4 M7 z8 j. Q6 _! h- c4 Y4 P4 T
我们需要打勾以下2个功能
5 K0 }+ Q4 U8 f1 x3 N- I9 y) ]
18.jpg
9 c, F' @$ v9 D/ z
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。

% M1 q5 u" f* Y. p$ i
19.jpg
+ m0 ?6 ~( R9 C2 L( J+ B( T! H& C
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过

1 j. x% j& g. L8 m6 O
20.jpg

2 \7 ^1 y; s; t' J9 x2 W
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

4 z/ B0 z6 m" b0 I
21.jpg

3 \% J* H' N5 N3 ^
然后配置MCU主频为216Mhz
5 Z' O& U3 L1 V0 j
22.jpg
  Z5 p6 I% x5 A4 ?! h* G1 P

; E! w. c9 s5 H- d  U
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

- K4 Y8 T( }$ T: a0 \# _( `# Q8 W2 I8 `
23.jpg

: c6 G, u1 ]9 J- y! b6 l0 `, d" F
然后在 AI扩展功能里选择通讯端口为串口3

7 M0 v7 l. N" J$ |
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)
: Q3 l' H  C( U9 c1 I  P( R
/ S! ^# H2 P* A7 Y' y+ @
25.jpg
- _# F# w. h6 ]. m6 ]5 s
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
, V8 i8 }; ]2 i) d% X. e
26.jpg

$ f: `  J6 @8 r$ @0 I0 Q, S
这里可以看到,基于AI训练好的模型数据列表。。。
  T$ W2 P8 K9 G& o0 T
27.jpg

: E& x, l/ g+ R# `8 w
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
; r, j9 @$ n+ T# O# R
28.jpg

0 A+ L% p& _1 o0 B7 Z
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target

6 E  Q5 h& n' W. {. |' I% u! f
8 K6 J1 h+ S, ]/ f  d( L: |
30.jpg
; x6 h% p  h0 z4 K! i% }
选择手动,然后选择对应的串口端口
, w0 D) I" X3 _7 |
31.jpg
/ u, S: t- a8 e) f
这里可以看到验证已经开始了‘
’# z4 Q: Q2 i, ~, }
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据

6 o% A4 A4 L& o) M7 u( A
33.jpg
) R. ~; ^6 B& d
34.jpg
35.jpg

- z  z: r: V/ q. G
36.jpg

2 G# y* `4 |4 L! r3 L7 v% o( d
3 `6 @% m0 D9 g( `
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
赞 收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
9 d, G1 I% h7 E8 d) D: o0 iassembling startup_stm32f767xx.s...
7 u- U$ `# b% U, \3 i9 d2 ]; _compiling main.c...- D! a; R* a- O5 z* D2 D2 |4 d
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory, N- j/ I  w8 Z& s$ y# }- C, x
  #include "network.h"9 L4 _+ R2 Y! R* x
../Src/main.c: 0 warnings, 1 error0 }0 v8 L' t& e1 h! d8 S) ~3 H0 C
compiling app_x-cube-ai.c..." [9 j3 [% Q* e' K' C" \
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
1 i$ [; W/ L0 _4 Z/ r: R  #include "network.h"
8 S/ D& A2 g" Z0 a../Src/app_x-cube-ai.c: 0 warnings, 1 error
% u0 r  h0 Q* _' k6 R3 Pcompiling stm32f7xx_it.c...
( a* \  q1 H3 N  D' q/ Qcompiling stm32f7xx_hal_msp.c...6 ^& A2 W2 y/ y, m. g
compiling stm32f7xx_hal_cortex.c...
3 _( K: d( |  B6 h, {6 m) Xcompiling stm32f7xx_hal_crc.c...3 S% \0 f# A$ K
compiling stm32f7xx_hal_crc_ex.c...7 F* Y# g5 D0 w- H+ N. J, u/ K
compiling stm32f7xx_hal_tim.c...
3 L9 w- z. D- Pcompiling stm32f7xx_hal_tim_ex.c...
! w. P3 B7 V% \/ M) G( Ucompiling stm32f7xx_hal_uart.c...( H0 H- G* P8 I: j
compiling stm32f7xx_hal_uart_ex.c...
5 s" x. }6 }/ ^compiling stm32f7xx_hal_rcc.c...
4 D1 [( a5 X9 lcompiling stm32f7xx_hal_rcc_ex.c...  e5 J" ^. J* H
compiling stm32f7xx_hal_flash.c...
/ ^9 \% o7 a4 U) a: g# fcompiling stm32f7xx_hal_flash_ex.c...
/ u8 P% w. T6 g7 Y0 w( G, @compiling stm32f7xx_hal_gpio.c...
6 h4 \  u- x% `) j3 y  l% l( ~1 Z  Fcompiling stm32f7xx_hal_dma.c...) M+ E8 R0 H/ l; c7 K" T% x8 S
compiling stm32f7xx_hal_dma_ex.c...
8 V  S- K# z' d  |, D' k3 zcompiling stm32f7xx_hal_pwr.c...
! @8 F/ w5 E! X1 acompiling stm32f7xx_hal_pwr_ex.c...
% }3 T2 J" M$ N0 E/ e) x! M0 t! Xcompiling stm32f7xx_hal.c...% T: t$ K: O( O( f
compiling stm32f7xx_hal_i2c.c...
4 A6 q5 |7 U; j# E" X! W/ e$ {compiling stm32f7xx_hal_i2c_ex.c...+ s" i+ I2 Q0 z& l: n1 H
compiling stm32f7xx_hal_exti.c...
* v; b: Z; Q' x$ L) Lcompiling system_stm32f7xx.c...7 o; f5 k& T7 a. S- }
compiling aiPbMgr.c...9 T& N6 N- b' A7 u1 l
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory5 Y8 T% W# z9 h( ^! D0 q
  #include "network.h"# H$ b8 C1 a3 N; b9 o2 {8 a6 l; P
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error4 q2 a1 N$ K4 p: D& _1 x
compiling aiTestUtility.c...+ E/ p: O; \6 s" I
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
4 Y/ }% p, Y5 Y8 l: [  #include "network.h"
2 n/ [, [% T9 y: g, J../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
* h' D  C3 N& l" Y# fcompiling aiValidation.c...* P2 M5 t* R6 E$ g% i3 b) l
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
- H3 R$ A2 F! c1 B3 z+ ~" D  #include "network.h"; L5 z% _& y& P
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error6 d, E- Z7 p) g* [5 c% W
compiling pb_common.c...0 D! C% M% [" G$ Y# ^
compiling pb_decode.c...
! ^# C0 M# s2 a  a0 D! d  Pcompiling pb_encode.c...& c& e/ ^' M5 a" F# {: V
compiling stm32msg.pb.c...
* a( q8 w, }6 C+ x"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
1 Q# D, }, M" c' ^4 _) q+ Z8 zTarget not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'3 T0 ^% ]  S  n* R3 F
assembling startup_stm32f767xx.s..., h: n) ~. F0 I% x
compiling main.c...! b: M* [" J# K; C; x/ C7 X4 o- x
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory! `; Q: v/ p2 Q% ]+ z
  #include "network.h"+ O; b* c; G0 f) k
../Src/main.c: 0 warnings, 1 error9 j+ x2 u4 J, P  C4 R" i5 g2 I) G0 t
compiling app_x-cube-ai.c...6 \7 f" O" J; o) T
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
# y$ v2 o8 Z2 \  ~1 E  #include "network.h"
% x7 N, o8 t' F../Src/app_x-cube-ai.c: 0 warnings, 1 error3 Z0 `, W/ k- C) J6 g( o. d; @+ j
compiling stm32f7xx_it.c...- F* t6 Y" D4 g# [( E, r
compiling stm32f7xx_hal_msp.c...
3 q" O2 @" N( ?/ Q. X  `compiling stm32f7xx_hal_cortex.c...9 {; B8 V7 S, b/ W
compiling stm32f7xx_hal_crc.c...
) e) Y2 R; s  h0 Zcompiling stm32f7xx_hal_crc_ex.c...4 O# d/ \3 o2 e7 e6 n
compiling stm32f7xx_hal_tim.c...
, t0 _' C5 R) |3 ?, icompiling stm32f7xx_hal_tim_ex.c...0 v- _0 x% P, h; a
compiling stm32f7xx_hal_uart.c...
9 }6 X9 }9 ]' C, n' l! E2 Rcompiling stm32f7xx_hal_uart_ex.c...
; ~! O0 U( m% j: h* \9 Gcompiling stm32f7xx_hal_rcc.c..." t& L# v$ U+ L2 d) [
compiling stm32f7xx_hal_rcc_ex.c...
/ B6 B! ~' w" pcompiling stm32f7xx_hal_flash.c...
( {0 R  b8 C2 N3 K0 O0 P. Rcompiling stm32f7xx_hal_flash_ex.c...0 D# {: J1 v- i6 x8 X8 h
compiling stm32f7xx_hal_gpio.c...
: s1 z* D" y# j2 [1 O# |! p( b$ Bcompiling stm32f7xx_hal_dma.c...! u2 \9 ^9 c' e7 C. M' B4 A
compiling stm32f7xx_hal_dma_ex.c..., _& s0 `! a& _# }+ p" }& ~% V& T
compiling stm32f7xx_hal_pwr.c..., T. X0 Z4 O( A$ n* U0 M
compiling stm32f7xx_hal_pwr_ex.c...1 R6 k2 g9 s, n/ V! W; B
compiling stm32f7xx_hal.c...
. A1 I" i# G  X% Icompiling stm32f7xx_hal_i2c.c...9 i8 o& k# f6 [4 N1 g  s
compiling stm32f7xx_hal_i2c_ex.c...
5 Z  X( i" h1 _+ m% d! G; zcompiling stm32f7xx_hal_exti.c...
1 M: N9 e( E7 Bcompiling system_stm32f7xx.c...! U4 N$ R# T/ S$ l
compiling aiPbMgr.c...
; C' w4 ]+ F+ Z% Y../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
% J+ R  w$ x4 R% F* P' c  #include "network.h"3 v2 |$ L% e1 E8 m& B+ [1 n
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error2 z0 t( O8 Z9 a4 ]9 y# h6 b
compiling aiTestUtility.c...1 I5 x% U* s( t
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory* }# A" v  H# p. T& @$ x
  #include "network.h"+ n7 [8 J, S/ [
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error  q8 Q4 o: P' F  t- p0 ~
compiling aiValidation.c...
4 I/ n" L, e3 J4 `) O$ D& s../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory) K( G7 h; g/ Q5 B2 N
  #include "network.h"3 q* i3 X! j. u9 k/ o# z; E" c
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
0 t  j/ C7 O3 q* [compiling pb_common.c.... O8 C1 N+ |, N% Y
compiling pb_decode.c...* q* B3 f2 r  X- i9 ~: D( T' j
compiling pb_encode.c...1 H$ z* F! A: \
compiling stm32msg.pb.c...
3 ~* A8 m( z2 s( u& e6 h/ o"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
7 A. k) W# G" g* B, B& K# q' PTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:158 D. I& o" K$ E  H6 V4 j
我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...
; J4 l/ B' U, F6 E' C$ R
首先确保已经安装了AI库
2 L. j! l$ m+ r* ]( c/ T9 _/ s' J9 O3 m( a' i) [
1.png : O& S! Z: k% J: [8 |3 @
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。7 ~# |" S( z+ L& \) |7 ~% w# E

- K7 R* `0 }5 D& `- W" d9 n
' u& G$ E: }8 Q  x5 o, N5 ^4 P 2.png
: ?6 ^. ]! A1 C# B: d3 H- `9 J4 E2 B) K/ u" ^: F
5 k* u& Q1 Z* J4 e' L: w1 y
  F4 M8 J2 Q+ C$ \/ t7 N) d+ O: ~
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。2 W/ C/ [' t+ h& x7 m; V

0 `4 X: o8 g1 b. Q+ T 3.png
% s/ Q0 W$ d6 G* S# b
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
0 G! @8 ~& Z/ `# ?/ W6 t多谢分享。。
/ I; ~+ p3 L1 s" s- j
厉害了大佬
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:143 z& `' T8 ]( R% C& ?( g* A
我只看见MODEL.H5没看见STM32F767AI.H5,为什么
5 R5 {5 O, o2 `* F
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:529 }  Z9 P' A, w) ]' C5 B/ N
解释下输出结果的含义

: o9 d' h) a4 X( r! H1 P7 R$ W8 P$ @8 V输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11$ A) J: v+ J7 \" O9 S& R
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

# k6 ^: m) |% U4 X$ j6 Y! a我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02: i+ c; J- H7 |: M6 ~
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...

6 {$ l9 W, o5 V0 b' r+ s  |导入到工程的时候,没出现STM32F767AI.h5吗
4 `, t8 Q4 n- W
123下一页

所属标签

相似技术帖

官网相关资源

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