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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。
7 M3 @1 p0 E# }) a8 n2 {; _. R
$ ~' n: X/ J0 j3 U# T
1.jpg

8 q0 l* F1 |7 d3 ^: b+ s
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。
4 F. j$ p' a* Y* j1 d1 q
使用STM32Cube.AI简化了人工神经网络映射

% z8 G" q8 r) _6 \0 f5 w6 c- f
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU
0 r  n6 U( T8 }# A/ x3 }. r/ H
提高您的工作效率

1 B2 N7 Q4 |" o" `% ?- z% W7 x
利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。
以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018

5 \' P. a, p" p$ E
那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1
然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧
4 p! F+ R+ b% K' n1 [
2.jpg

( ?) L0 y# K4 D
下载好后,CubeMx里的Artificial intelligent
激活Enable

5 Q3 h' Z/ d+ _" c2 h% T1 V
3.jpg

. g* E- [8 S8 e+ V/ o2 ?# r
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

4 s% _1 L5 L8 m' N
4.jpg
8 V+ Q! e; \4 o7 `
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
* ~' ?4 s1 o4 U& U
5.jpg

2 U2 \& M! K! D: p, J8 d% A
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg
  y) x9 R( J1 g6 f6 z8 e9 [: U
然后我们导入到工程里
7.jpg

# K0 a# f- K; r9 [/ @
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg

- t0 a: D/ V% L, g" {
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用

, u" v& Q- H! l5 Q
9.jpg

/ z6 m+ ~5 L& f# d7 W8 A
好了结果出来了,
  q. F; V; W, ?2 R3 \# t
10.jpg
' ~& j- J, [" b4 O2 o
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
* h" P/ Y6 {  T" A2 q6 L
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用

  i. U, {9 _6 W; w
12.jpg
9 e6 |1 y9 j8 [& ~+ @: D& K4 \, t
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
) b/ N6 j& h+ _1 o
13.jpg

( L5 b3 Z9 S; C: `+ s
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡

/ W: ]4 C: ^3 i2 G" G1 w
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
6 Z+ i# Y7 b# U) q' y
5 g8 i1 C/ j* k) ], o. k, l# h
15.jpg
  P/ |* ?; {4 S% r  ?
2 [4 M( e. }# b$ b1 M: {9 ]: m6 T
选择好Validation 和打勾 AI core
# h" ~* z# {4 n" Z4 @
16.jpg

3 z* ~" l8 s/ D7 Q
然后在cube 左下方可以看到下图箭头 提示的插件功能

4 f* `) a) `+ B6 {8 ]* U
17.jpg

, ~3 {2 w  x# E# Z* e! D3 B7 E4 _1 m
我们需要打勾以下2个功能
# s  l3 r: w9 |5 [0 x
18.jpg
  [8 Q& \6 w2 G1 g
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。

- v5 N9 ^' y- c+ [( O6 t
19.jpg

# P! M0 l! w: |) J4 L
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过

$ w. Y# X' _2 y# R
20.jpg

6 w: {6 t) p7 r4 c: ]2 q+ T. W
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

: m9 [9 e" z4 G( x3 N
21.jpg
! y6 G2 O6 ]' \
然后配置MCU主频为216Mhz
! ]& C% ~" D) ]( O- x$ S- N7 Q
22.jpg

$ O; U8 d5 o. c4 W3 N9 j8 k, U4 m$ n8 }$ z: [
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。
& D# }- k+ [7 R% B; Y
23.jpg

6 A+ K2 o9 C% W8 V" r
然后在 AI扩展功能里选择通讯端口为串口3
/ k: r; f2 I# D4 F
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)
" U& ~% d. h$ s! X$ x
3 G, r  C& P) [& f
25.jpg
2 n; ?: @' q  r. H1 [/ z' Y8 ^- [: A
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件

) \( p) Y; G4 W0 \% h+ c* i
26.jpg
1 ~' A7 d9 d/ t: T( n3 n) |
这里可以看到,基于AI训练好的模型数据列表。。。
; j7 s9 b2 z7 x9 R  J+ a4 q; h% [
27.jpg

2 q, f. x) P6 z( S
好了,配置位STLINK,然后编译好就可以直接下载到板子上了
6 {5 Q6 z7 P+ J9 O. d4 t
28.jpg

# |! n% s6 |3 R, F; N5 i& U- m! D
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
) A& ^1 Z4 Q9 @/ f) ?/ D
2 A5 M0 i3 v- s7 Y7 Z7 i
30.jpg

, ]) y  i+ i8 Z$ `
选择手动,然后选择对应的串口端口
. ~. w" t" c1 D- M
31.jpg

4 J! w! T1 P+ a/ Z- R
这里可以看到验证已经开始了‘

% t1 B: ^* @$ P7 D) T
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据
; m( U. ?* N% X) n( q
33.jpg
4 y8 R( ~# C% d2 X2 O, |
34.jpg
35.jpg

/ b$ h6 I# |- E
36.jpg

! U4 T) r' b! h
# g0 T' }& Q; M0 |$ v' g6 q
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'
; S, m& V8 G5 O1 Iassembling startup_stm32f767xx.s...
* B! o& r+ k7 n% Pcompiling main.c...
- a: ^! Y! r1 u7 Y8 M' y/ p, F! k../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory7 j  L' q) W3 a3 C! k4 U$ j
  #include "network.h"  m0 a2 N! N, @- U( p. p8 D* o
../Src/main.c: 0 warnings, 1 error5 `' ^- b' ^/ ?" C7 G/ w! L3 }9 I
compiling app_x-cube-ai.c...; ^4 o2 Y; j: H5 Y8 `* E0 j& ^+ s
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory* v; C& B9 C  D1 Z* p
  #include "network.h"
+ V3 \$ R# J. j; J3 q8 `+ I+ f../Src/app_x-cube-ai.c: 0 warnings, 1 error
. k- R* X$ ~  L8 y; {% ~compiling stm32f7xx_it.c...0 |1 c" [' n% a7 n1 s
compiling stm32f7xx_hal_msp.c...
, p+ y! Q4 a/ Q1 V  F$ Tcompiling stm32f7xx_hal_cortex.c...
; D4 s& r2 _  C: l- E' Kcompiling stm32f7xx_hal_crc.c...
9 Z! i4 r- A9 U8 O& n' `compiling stm32f7xx_hal_crc_ex.c...  R$ u: k: j1 t- Z
compiling stm32f7xx_hal_tim.c...8 u8 G! x8 d: ?1 c# E4 v& c( V  y
compiling stm32f7xx_hal_tim_ex.c..." M. X! S% g% |" d' J# ]% S% ~+ X
compiling stm32f7xx_hal_uart.c...
; p& {; H' m: z; ~, `$ i+ z3 |compiling stm32f7xx_hal_uart_ex.c...6 Z! ~( q% [$ I0 S9 D) m$ Q
compiling stm32f7xx_hal_rcc.c...6 x1 O* w$ l1 M, `! G5 y
compiling stm32f7xx_hal_rcc_ex.c...
1 M1 ?# k- F  C" g/ N, ]) C2 ccompiling stm32f7xx_hal_flash.c...
% T0 ?" l# u. I7 scompiling stm32f7xx_hal_flash_ex.c...
8 \2 M2 c0 T' i3 e4 T. Bcompiling stm32f7xx_hal_gpio.c...2 B0 w$ V- u( V- j
compiling stm32f7xx_hal_dma.c...
# t! A. D- A& @6 Z4 w' \compiling stm32f7xx_hal_dma_ex.c...: S6 G) Z3 m. b  u" _$ |9 {
compiling stm32f7xx_hal_pwr.c...1 Z1 F$ I. ?. q! i
compiling stm32f7xx_hal_pwr_ex.c...
0 W$ P& G9 `: [, kcompiling stm32f7xx_hal.c.../ a) }0 O! O$ K0 y. |; R8 I
compiling stm32f7xx_hal_i2c.c...) P; m% p# c8 c' h# Y
compiling stm32f7xx_hal_i2c_ex.c...9 j( J8 e! E& n3 n
compiling stm32f7xx_hal_exti.c...
- n5 o$ o) u; F5 ^compiling system_stm32f7xx.c...4 X) ^# h; s* P$ Z0 p8 w$ [2 z3 d
compiling aiPbMgr.c...
2 D4 {  R# w; s../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory) k) i9 U; ^2 L. k
  #include "network.h"
! W& q- O% g$ U+ Z../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
& G8 y- ^' W2 ?compiling aiTestUtility.c...
: N, b& C2 o/ u2 w, y8 h../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory2 t8 g0 m+ w$ U# i& k
  #include "network.h"
) z" i, Q% K& Y+ g8 h: n../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error: S# S& m9 H/ g+ l0 x: S, l
compiling aiValidation.c...- h( v7 ]6 w0 L. C, e' i* i% r
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
( |, h9 i  N9 x  #include "network.h"' v0 N( h, o' \0 Z$ b' ^
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
; W4 f. z2 i$ b) C7 w# wcompiling pb_common.c...+ _9 [6 t2 [) ^
compiling pb_decode.c...$ V! j. c$ z3 {4 K+ y
compiling pb_encode.c...+ w# P; }0 T# [
compiling stm32msg.pb.c...7 S9 x$ n. d; I8 L$ q4 q
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s)./ X3 V* T8 z; j9 J% p5 U
Target not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'
7 X+ ^4 l, k; l* P! K# xassembling startup_stm32f767xx.s...
0 g, t5 h# C/ y% y" p" Dcompiling main.c...& Q' X7 r3 [( F) B
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory9 c2 s# z6 j6 H  {* G+ |4 H8 ?( k
  #include "network.h"
' h! G" `/ W3 \8 n  X../Src/main.c: 0 warnings, 1 error, l: e# u- Y; P6 p; E
compiling app_x-cube-ai.c...* ~0 U: _/ L3 n2 v. Z
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory# Q, {& j+ Q. ^
  #include "network.h"% w6 J- Y# }8 E) }5 p) L, Z9 n! L
../Src/app_x-cube-ai.c: 0 warnings, 1 error
( k; K, n; n1 N" q& M. Fcompiling stm32f7xx_it.c...
- \2 Y8 D; x7 `& U- acompiling stm32f7xx_hal_msp.c...* c- t3 g  q  j( ~6 G
compiling stm32f7xx_hal_cortex.c...
% t  a  N) ]& |# g7 Pcompiling stm32f7xx_hal_crc.c...
! j  v3 e5 t& j2 qcompiling stm32f7xx_hal_crc_ex.c...
$ b' C2 k4 V; _% H! w; H$ Ucompiling stm32f7xx_hal_tim.c...% Y# E3 y: S) A
compiling stm32f7xx_hal_tim_ex.c...
% b3 v% A9 @) n! W& Pcompiling stm32f7xx_hal_uart.c...% a1 P) t8 W" V: O
compiling stm32f7xx_hal_uart_ex.c...
& q' E0 a0 T6 A4 E' y7 L  d: Zcompiling stm32f7xx_hal_rcc.c...
3 O6 R' B; {' y' }& Y* h( W( Qcompiling stm32f7xx_hal_rcc_ex.c...
; B3 E, m8 `6 `5 M+ `; P9 scompiling stm32f7xx_hal_flash.c...
- s0 [' z; r/ [4 acompiling stm32f7xx_hal_flash_ex.c...) u2 k* ?+ _5 Z
compiling stm32f7xx_hal_gpio.c...* ^& y. L) [, r! Q" T' f
compiling stm32f7xx_hal_dma.c...: ]9 Y" ~  Y! U$ E" x/ ~# Q5 k9 M
compiling stm32f7xx_hal_dma_ex.c...
  D3 c) u7 v  d3 r$ wcompiling stm32f7xx_hal_pwr.c...* B" m8 i/ `6 l8 h- k! T$ L
compiling stm32f7xx_hal_pwr_ex.c...# n( A! @. q3 o) K; f. `& e1 u* U
compiling stm32f7xx_hal.c...
: ?" k* @* k( ocompiling stm32f7xx_hal_i2c.c...
5 z6 X9 \* o& z7 }  D. Vcompiling stm32f7xx_hal_i2c_ex.c...
5 K* H. @' @* ?) r. K3 Bcompiling stm32f7xx_hal_exti.c...
  s' o3 M! M  k, L9 Tcompiling system_stm32f7xx.c...
2 Z. S6 H& M. L. t. d. Fcompiling aiPbMgr.c...
& f; M, J& H( j' J0 h$ z, J../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory
0 r# @. @0 c5 H5 s) v  #include "network.h"( r: \5 \# t! t& |! S9 H; C$ Z+ R
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
. V4 z3 m7 _# dcompiling aiTestUtility.c...
4 c8 U3 K4 H2 V/ b5 J../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory4 J. d& d3 }% f2 O
  #include "network.h"
: O' K1 O9 {% B# ]../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error% _* S$ q! r$ z/ _
compiling aiValidation.c...% ?, v3 b( A( d. E! L
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory  H# u, Q0 p; }: s* x6 G
  #include "network.h". {4 E3 q$ Y( |- f9 y
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
. _) C, [5 t5 \& K) Icompiling pb_common.c...4 l" g7 G2 L# L* B7 L
compiling pb_decode.c...: N+ _1 @( G: y5 [- e% M4 j! f
compiling pb_encode.c...) T& H1 s1 j6 S3 z% Y3 ~/ B
compiling stm32msg.pb.c...
6 Q, [; h5 O4 t" N% L"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).! |3 b3 Q3 X( f" z/ s/ d  _5 S- N
Target not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
  o! B8 {/ H% Z# v) G, [我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...
9 a) ]8 i) r9 `) T
首先确保已经安装了AI库
1 {$ a# |6 D; B( @" C5 `& B
; t4 t& u  B5 w% y8 y 1.png 1 x. E+ t. G8 x4 ]0 f. m
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
1 ~8 k& I: b1 G* e) ?, o3 R* \& x) P8 [
6 F& ~8 I% u1 O
4 R& \6 g+ l% [% j 2.png 8 G4 Y2 \; o/ L4 a9 s: F
& ~( t" ]- h# q' _# s- {& Q
$ E' ~8 P, \) k/ x) b. b0 {9 @3 s
& T, G' C5 _' [6 K
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
" Y8 o* X% d% P' N* i3 Q/ V4 c0 A5 `, x5 W, q  ^: u4 K$ z
3.png 0 H2 j) n) q. e1 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
  T9 }1 N4 {# M! K) ~) R* t多谢分享。。
# X5 f& H' m2 V7 c
厉害了大佬
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
" M8 I  [# u' |3 C* E+ ]1 d+ C4 K9 ]7 `5 g我只看见MODEL.H5没看见STM32F767AI.H5,为什么

# f; z, Y. W- o" L3 Y7 cmodel.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:52
3 ?. c( v2 N+ p+ z解释下输出结果的含义
' t$ q' v. w. L4 H. S
输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:114 V# D8 t% a* M" {: O
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
: V& D8 G- i1 {* c& C0 y
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:02
8 V0 H" A7 ?' ^2 V1 {4 F; U( w我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...
) ?1 z$ E  r5 |9 d7 r/ H. z# z+ L
导入到工程的时候,没出现STM32F767AI.h5吗$ O) F. F0 l) @. \2 g- t9 {+ S
123下一页
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版