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

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

[复制链接]
木木&点点 发布时间:2019-1-6 17:29
偶然看到一篇好文章,分享给大家。

. G* [4 `+ o2 h/ w3 [
8 t8 f1 ]6 o; l5 ?3 v
1.jpg

8 D* |5 J7 K9 t" T+ y- Z
今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。

( e9 N/ p) g) o7 V- P! W
使用STM32Cube.AI简化了人工神经网络映射
$ }; P, |' X6 i" R' a, J0 F
1.可与流行的深度学习培训工具互操作
2.兼容许多IDE和编译器
3.传感器和RTOS无关
4.允许多个人工神经网络在单个STM32MCU上运行
5.完全支持超低功耗STM32MCU

$ J7 o8 t' B' d4 Z3 f
提高您的工作效率

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

9 Z  ~( T$ j, l) z6 ~
2.jpg
# `* ?) K' v/ m' ^& G& n
下载好后,CubeMx里的Artificial intelligent
激活Enable
% ]$ a2 r3 j8 ?6 u! E7 ?
3.jpg
" P8 H$ p8 w7 r3 ^& p& K% X, v
这里我们就可以看到里面的选项了
下载下来。。然后选择Keras 的AI API算法

3 R. |% h0 W; Z& y; E. M
4.jpg

6 N6 {! g% s, a% u# P9 s
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
  \2 F" u4 V8 e
5.jpg
) R! X( O- t) m4 l. e
Human Activity Recognition Using Convolutional Neural Network in Keras
人类活动识别卷积神经网络算法模型
6.jpg
. K  X  W! B6 p. ^
然后我们导入到工程里
7.jpg

- ?/ f) m, o# y# O. b: D
这里选择压缩参数,不同的压缩参数对MCU的flash容量
要求也不一样。。
8.jpg
9 A* Q' ~8 f" F: N+ o
点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用
5 N( o  E* y7 _& ?% ~; N
9.jpg

9 y! _9 I; ~( m6 {/ L
好了结果出来了,
/ G, O: F) M( f' S
10.jpg

, [+ p/ {, _: k8 u
经过分析后Cube会自动列出可以使用的MCU
然后显示在列表里
11.jpg
7 ^2 {& N0 G$ g. x. ]" \5 E
这里举个例子,我们选择没有压缩优化
分析模型算法后的结果我没有匹配的MCU可以使用
. u( P* \% @, `
12.jpg

* M5 b, t6 {0 Z3 q' H! J5 a1 b
这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。
, o. c# n9 C2 D4 N. J
13.jpg

! U" f" X. t2 D1 d3 X  E
好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡
/ X# L8 G8 i. ?2 p0 e) ?, y
14.jpg
好了选择好了,板卡,我们还需要给它添加扩展库,也就是AI库
) Z: |9 c  ]2 o7 ^/ v1 P+ ~) {
, t3 G+ c" b8 a  W
15.jpg
1 m2 U5 w) K; a) k; D9 B
! x+ A  _) {- T# p' ~* {
选择好Validation 和打勾 AI core
: X4 C, |, [6 @  b9 C
16.jpg
# d& M1 F4 H8 D) G1 P. I8 m6 l; u
然后在cube 左下方可以看到下图箭头 提示的插件功能

) z: s4 i6 O% O2 [- H
17.jpg

  U4 [1 n/ ]: m
我们需要打勾以下2个功能
1 g$ H! j" N$ Z# e
18.jpg
0 K- x( s+ u. g' ?5 G8 `9 e. U: t
然后创建我的AI算法名称,这个名称会在后续的里自动创建好。

2 n4 }: E, ~7 V* r2 c3 t2 ]
19.jpg
  q2 G  F4 r0 Z# e$ {1 f/ ?9 G
添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过
+ \. E, Y% ]7 l0 l' A$ J
20.jpg

) C. _; d; o+ B) @; @
然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache

( g/ l6 Z, I: M# k
21.jpg
, z3 s$ d% v, g) G/ v
然后配置MCU主频为216Mhz

& T, q/ r1 k; A7 D0 ]  p
22.jpg

" e0 r* q" L' c% t
- B& a# a! ^7 I# w% p. |
然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。

& O* r/ j( y" m6 V. h7 Y
23.jpg

8 Z/ U4 s% `! N; n& W- p
然后在 AI扩展功能里选择通讯端口为串口3
5 x1 W  ~9 G0 m: C; a, g& Y) x/ m
24.jpg
好了,工程差不多创建好了。接下来就是 配置工程的路径好 我们配置使用IAR 编译环境。。 然后Heap 然后要配置到2000 这个很重要,要是设置少了 系统就会奔溃(切记)/ i) G) }% Q3 {: z4 N
$ O5 s7 Y  E9 s) [6 p
25.jpg
3 p! q' n" H% r
好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件
$ i, d. N) X) U5 \" b$ U
26.jpg
9 U9 K6 y0 N5 Z& Q* ^
这里可以看到,基于AI训练好的模型数据列表。。。
9 Q  W+ I* R0 k! N7 k4 B
27.jpg
# o8 a% F. J% h8 }
好了,配置位STLINK,然后编译好就可以直接下载到板子上了

, y" S! K4 U' |# C8 @
28.jpg

2 N2 r" @" Q' R5 y( [8 V, _' Z
29.jpg
好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target
0 j  ~/ m1 A; b" O- J* R

% j" D- Q# v: L4 x$ A' w; x0 w
30.jpg

  @6 V- |  d  @+ ~! k( I
选择手动,然后选择对应的串口端口
* |# ]2 k3 L: s
31.jpg

0 G4 u/ _$ N7 `7 t
这里可以看到验证已经开始了‘

: n" M6 M+ d: a. V; `) ~
32.jpg
好了,结果出来了。我们可以在串口输出的信息里看到有关的数据

+ c" n# u# w& b7 s
33.jpg
' W( d6 `3 ]( v" ]* B& A
34.jpg
35.jpg
: S: e( [6 F9 C# W8 q% Z
36.jpg

% {! X4 x; C3 a* G; o
# l$ H  [8 ]/ X4 _  y  x
好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。
收藏 3 评论33 发布时间:2019-1-6 17:29

举报

33个回答
单片机爱好者 回答时间:2019-5-25 21:12:11
Build target 'STM32F767_AI'$ p1 r: F/ p5 }( ]  R2 R; u
assembling startup_stm32f767xx.s...
% b9 G" {' L( W( z9 F* h6 q  a! Ccompiling main.c...
! G; T. U8 r( T4 c4 i../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory  Q2 E( Q# l0 K2 R
  #include "network.h"; L+ d  B% y+ R( D9 M; L
../Src/main.c: 0 warnings, 1 error
  w0 G$ a( o! k% w- V% kcompiling app_x-cube-ai.c...
- k+ i! \% y; O2 S../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory8 |2 E. Q5 Y5 f# o/ A& \
  #include "network.h"* N" \0 L! Z- P4 Q0 n7 {, W
../Src/app_x-cube-ai.c: 0 warnings, 1 error
+ e( c3 `# x' E' b, |( T+ j( s- {8 T8 rcompiling stm32f7xx_it.c...
2 p$ F( [& a  m- r1 Q* I8 {' o( ~compiling stm32f7xx_hal_msp.c...
9 k9 B; b; c8 zcompiling stm32f7xx_hal_cortex.c...
& U, ^1 t+ m) S2 I) Q# \8 l7 O8 ecompiling stm32f7xx_hal_crc.c...' W0 Z+ T7 p. o( H! ^" f
compiling stm32f7xx_hal_crc_ex.c...
! s. X; q3 T2 N5 |! Ycompiling stm32f7xx_hal_tim.c...
7 i  O# U8 ?' s0 p% g! Ecompiling stm32f7xx_hal_tim_ex.c...
) g  Z  q- |, f0 ^* Kcompiling stm32f7xx_hal_uart.c...
; o2 l; G( `3 Ocompiling stm32f7xx_hal_uart_ex.c...
* F7 l# e! y4 |compiling stm32f7xx_hal_rcc.c..." H4 e* o$ h8 A* P
compiling stm32f7xx_hal_rcc_ex.c...
: A$ W0 G0 A: n" d# `3 ]8 F% Kcompiling stm32f7xx_hal_flash.c...
1 V+ A# u7 ?# m* m5 {% Lcompiling stm32f7xx_hal_flash_ex.c...# W6 \: O9 ~& P% @4 D
compiling stm32f7xx_hal_gpio.c...
5 @! M" j2 A+ a& pcompiling stm32f7xx_hal_dma.c...& p* k8 t; O, {0 |  Y) m3 L
compiling stm32f7xx_hal_dma_ex.c...8 s  O% P5 [1 X' P$ a
compiling stm32f7xx_hal_pwr.c...- D8 p# L/ I0 Z
compiling stm32f7xx_hal_pwr_ex.c...( T0 A: Z# G( M  I
compiling stm32f7xx_hal.c...
- p1 {, r  t& b7 Lcompiling stm32f7xx_hal_i2c.c...7 D6 r6 Q( M1 c3 x
compiling stm32f7xx_hal_i2c_ex.c..., d6 c6 e- v6 y9 v4 R
compiling stm32f7xx_hal_exti.c...4 K  {2 k6 H# \
compiling system_stm32f7xx.c...
) H* s& M4 D! [, @7 @* B, Xcompiling aiPbMgr.c...
" y0 `! W& S( [* \" S( z; ?/ {../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory4 l; a2 b1 X# _
  #include "network.h"2 |5 t9 h- |! }7 M4 {4 K
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error6 k* n. F/ H4 [1 ]& D+ Y" M2 I, }
compiling aiTestUtility.c...% t" o; }1 ^( }. {$ H/ I1 t; S2 K
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory5 {. \1 O' c) A7 L; _8 G
  #include "network.h"
; g" i& c+ m7 m! k6 P  W../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error
( O0 j$ ~  \% g  u4 R5 ?# icompiling aiValidation.c...
5 s+ o; ]  n/ T9 K) S4 |, U0 J$ u9 s../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory" z( X; o6 a: x4 {. f' A* P
  #include "network.h"$ [; a3 f% U. q& w
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
, P, }( {6 g" n- \" O# u4 ocompiling pb_common.c...
; D& P* o) d6 {compiling pb_decode.c...
3 L  |( S  x  e6 g: Bcompiling pb_encode.c...
4 [; b  ~; \, q/ Y  e  dcompiling stm32msg.pb.c..." j  W( v7 @* O# D9 T( t% t
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
- v3 f% R0 O. Y* GTarget not created.
单片机爱好者 回答时间:2019-5-25 21:11:53
Build target 'STM32F767_AI'
' E" F! U/ X; n& t6 x6 _$ i. yassembling startup_stm32f767xx.s...
' R/ @+ J- J+ B1 |compiling main.c...
5 R, p( u7 I" h& E2 W( s* K$ H7 _../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory  ]5 H1 R, G4 y3 K% l* e
  #include "network.h"
& M4 Y: q: j) x( C7 i../Src/main.c: 0 warnings, 1 error
/ m+ o1 Z% c* B0 \2 l1 ?! u9 Ncompiling app_x-cube-ai.c..." n# r" b$ ~1 `
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory" q+ c% q  C! ^3 k! Z4 V
  #include "network.h"! q6 Z5 g9 f% `
../Src/app_x-cube-ai.c: 0 warnings, 1 error
1 t2 ^+ z* l) S: U2 T. [compiling stm32f7xx_it.c..." |) t3 ]5 j7 o: p. z5 p3 X
compiling stm32f7xx_hal_msp.c...
  c1 t) U3 m- m' w/ G3 d  S  c! Qcompiling stm32f7xx_hal_cortex.c...
4 E  E1 Q4 _; `% H, z8 E$ dcompiling stm32f7xx_hal_crc.c...7 t' h: y7 v8 r4 ?
compiling stm32f7xx_hal_crc_ex.c...
# m/ `' j) ?; J7 \3 U" Acompiling stm32f7xx_hal_tim.c...
7 l( x. g& U$ icompiling stm32f7xx_hal_tim_ex.c..." n7 k- w  S8 o+ f
compiling stm32f7xx_hal_uart.c...
  b: D3 }3 m" H" g3 w% ~compiling stm32f7xx_hal_uart_ex.c...
, i% G1 T- F0 z3 q8 h5 n' Fcompiling stm32f7xx_hal_rcc.c...8 x& [, x! P- v! u% X
compiling stm32f7xx_hal_rcc_ex.c...0 H3 p3 x9 L1 X; O$ j
compiling stm32f7xx_hal_flash.c.... a% o6 _% N1 Y  }
compiling stm32f7xx_hal_flash_ex.c...% |# B$ r) A% U# A  e4 x( ?3 h
compiling stm32f7xx_hal_gpio.c...
/ V: `( ~; [+ B9 r6 n7 _' scompiling stm32f7xx_hal_dma.c...
6 y# a" f% S$ E# S8 N0 Q; b+ Icompiling stm32f7xx_hal_dma_ex.c...
+ |% O% _/ _6 @8 \' U5 Acompiling stm32f7xx_hal_pwr.c...
. r: H$ h( N. o9 j2 ycompiling stm32f7xx_hal_pwr_ex.c...
& _1 U+ r; y6 O9 N! v3 m% W( wcompiling stm32f7xx_hal.c...
7 _; D8 Z# g4 M; Bcompiling stm32f7xx_hal_i2c.c.... g, Q' [2 Q: O$ P) V
compiling stm32f7xx_hal_i2c_ex.c...) T  {0 `3 {* a; n: I4 K1 C8 K# w
compiling stm32f7xx_hal_exti.c...) B3 ]+ ?4 C- m- _
compiling system_stm32f7xx.c...% ]& f, F8 K/ V, ^
compiling aiPbMgr.c...) M5 a! D6 Y* W# R. v# C; s" U
../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory1 Q7 i- n6 f! E! }% d) j! o
  #include "network.h"
- q% b+ O& \- G' Y& A../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error5 K1 }7 J( L/ n: \
compiling aiTestUtility.c...
; d' b6 S% M+ H% R0 F! I* Y4 z../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory6 W7 l5 g  ~" Z4 R/ [
  #include "network.h"
4 y5 z) I' e+ w% p. g& p../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error: H7 H) }  u0 J* ~5 F8 I! p# u* ?
compiling aiValidation.c...
% Y1 ~* U# ~5 r0 U" f../Inc/app_x-cube-ai.h(77): error:  #5: cannot open source input file "network.h": No such file or directory# [" H) y. f+ D0 t% }; q
  #include "network.h"
* {* ]$ s% M% e! t4 n../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
& z2 i" v9 O- E1 ~5 N+ k1 n- w  ^compiling pb_common.c...
4 k, `2 h2 p4 T5 ~* U9 l" pcompiling pb_decode.c...
8 o. p- K1 t3 M, c, B! Vcompiling pb_encode.c...
6 a7 @+ {4 U% xcompiling stm32msg.pb.c...
9 h9 ~" ?  z( M$ ^) S$ `"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
1 N4 P9 N  Q* i1 a  aTarget not created.
Beatle 回答时间:2019-7-14 14:55:07
じ太阳当空照 发表于 2019-7-14 09:15
3 D- y. d* ?( h. x我真的不知道是哪出了问题,求大神指导,我导入以后,选好芯片,然后点击Additional Software进去,里面 ...
# _) a, {9 J  W+ t1 C
首先确保已经安装了AI库
1 M" w6 ?7 T$ d9 ?
5 A5 O; m! f) v6 Y 1.png
4 [' p" m' W% }; T7 Y使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。  J# W* g8 d2 j$ d9 t3 t' S3 E6 t  {

" E7 I2 X0 H5 Y$ O3 c8 M
. \9 `9 t) i0 \5 Q" q1 M 2.png
" S0 _1 T) n$ U% y: c, l0 R
) J! y& x( y# x% U6 y5 f' X& g/ t* E
  o9 K% m* e3 |! s% {0 W0 _
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
  ~0 ~0 ~$ ?, [+ d$ J, `! ]* g. S6 {# r
: |+ C: K  A; w9 M1 i0 T 3.png 0 Q4 X+ {. |& d# f
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
- l; ]' }5 q: N: B% B. t- a$ j多谢分享。。
& ?# y# d% n' @9 D! M/ K; V% f& P
厉害了大佬
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, ]3 a. n1 S* y. H
我只看见MODEL.H5没看见STM32F767AI.H5,为什么
" t/ N' P# n; Q9 B9 D' G/ V
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
杨满意 回答时间:2019-1-21 16:52:12
解释下输出结果的含义
木木&点点 回答时间:2019-1-23 15:23:29
杨满意 发表于 2019-1-21 16:524 V- [) J" v- K% A* s- n. \
解释下输出结果的含义

; ~9 U% W1 N; ~3 Y8 a) _& e输出吗   这是去使用库的AI神经算法
h55 回答时间:2019-1-28 11:02:50
点点&木木 发表于 2019-1-21 16:11! f/ z! \7 h9 f7 z
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型

) H+ Q" z' n' E6 ?) ?# @& B我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
木木&点点 回答时间:2019-1-31 19:42:28
hu-jian-li 发表于 2019-1-28 11:024 s1 j6 B$ j$ C) V/ u
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作 ...
# t  y* Y6 f+ Z+ y9 _9 a6 v
导入到工程的时候,没出现STM32F767AI.h5吗
* R6 c2 ~. G7 z3 e- e
123下一页

所属标签

相似技术帖

官网相关资源

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