
偶然看到一篇好文章,分享给大家。 5 I! _& d3 j. i9 k d3 w u![]() 今天介绍下ST官方刚刚推出的CubeMx 自带的X-CUBE-AI(Artificial intelligent)插件功能,可以给现有的STM32 M3-M7高性能的处理器添加基于训练好的ANN 的模型用于不同的数据分析处理。 使用STM32Cube.AI简化了人工神经网络映射 1.可与流行的深度学习培训工具互操作 2.兼容许多IDE和编译器 3.传感器和RTOS无关 4.允许多个人工神经网络在单个STM32MCU上运行 5.完全支持超低功耗STM32MCU 提高您的工作效率 利用DeepLearning的强大功能提高信号处理性能并提高STM32应用程序的生产率。创建人工神经网络并将其映射到STM32(通过CubeMx自动生成优化的代码),而无需手动构建代码。 以上就做个简短的介绍,想了解更多有关STM32Cube.AI可以访问下面的链接:http://www.st.com/content/st_com ... 2_gl_social_dec2018 2 N: w7 z6 K6 @, A5 ~那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1 然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧 7 a3 `, w8 ~. f# m3 D![]() 下载好后,CubeMx里的Artificial intelligent 激活Enable ![]() 这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法 ![]() model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 ![]() Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型 ![]() 然后我们导入到工程里 ![]() 这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。 ![]() 点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 ![]() 好了结果出来了, 9 z! l0 `" l, D% \![]() 经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里 ![]() 这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用 ![]() 这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 7 C: c3 `3 Z7 J; t3 d; p2 F![]() 好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 , q3 L2 T4 D+ _: O3 K![]() ![]() V; M5 i; [3 Q3 L% G- R5 |: h 选择好Validation 和打勾 AI core ![]() 然后在cube 左下方可以看到下图箭头 提示的插件功能 ![]() 我们需要打勾以下2个功能 ![]() 然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 ]( n; h; h! o; ~! i![]() 添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 ) S, y2 h8 q# \0 S! }![]() 然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache ![]() 然后配置MCU主频为216Mhz f" m# B9 [. K. m% Z![]() + G1 i+ }# U+ Q& Z( s1 r 然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。 ![]() 然后在 AI扩展功能里选择通讯端口为串口3 " t) w& o9 |" H" ]6 A# |+ b![]() ![]() 好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 , U8 d: y/ Y. J![]() 这里可以看到,基于AI训练好的模型数据列表。。。 * h! E) I/ P' x7 O3 h% m![]() 好了,配置位STLINK,然后编译好就可以直接下载到板子上了 ![]() ![]() 好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target ![]() 选择手动,然后选择对应的串口端口 ![]() 这里可以看到验证已经开始了‘ ’+ E% K7 X# E. [! P9 l ![]() 好了,结果出来了。我们可以在串口输出的信息里看到有关的数据 , X9 F) B* K5 |, I# |0 x![]() ![]() ![]() ![]() 好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
MCSDK FOC应用详解
【实战经验】基于STM32F7的网络时间同步例程
STM32硬件结构学习
STM32中BOOT的作用
【STM32N6570-DK评测】1.开箱测评
【STM32F769I-DISC1】开发板刷入Micropython并完成点灯、读取内部温度测试
【STM32F769I-DISC1】测评01:创建STM32cube IDE 工程,点个灯
【STM32F769】创建deepseek本地服务,并实现http请求
【STM32N6570-DK评测】1.你好N6
实战经验 | STM32 AI Model Zoo 的安装及实例介绍
assembling startup_stm32f767xx.s...; M+ K" k0 k5 u
compiling main.c...' s* h4 n0 \" M: U4 M
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory: y" [9 b1 s9 \ c. }' y
#include "network.h"/ `5 v- G: j1 D9 |
../Src/main.c: 0 warnings, 1 error2 T+ s( G( D* ~' u. Q p
compiling app_x-cube-ai.c...7 y A: M; x! |1 J! d1 ~
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory" _! d5 p1 }6 {4 u' u. o
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...# r& z0 k! A: j3 ~- g, |( ]- q
compiling stm32f7xx_hal_crc.c...- m+ L1 i9 u6 S- T, A4 \, K) L
compiling stm32f7xx_hal_crc_ex.c...0 q7 m' l: J, D5 ?+ T* ~) x) k6 N
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...& h/ k$ D$ z6 `' E/ k+ F/ O
compiling stm32f7xx_hal_uart.c...* Z# U5 ]6 M2 e( N5 l: H
compiling stm32f7xx_hal_uart_ex.c.... Q! u4 z0 v9 N8 Z+ A2 @# @
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...7 n& I$ D% y4 L/ }
compiling stm32f7xx_hal_flash.c...2 c- h; v' E/ s" u. j) ?' f
compiling stm32f7xx_hal_flash_ex.c...$ a4 B) G. Z8 l0 G
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c.../ C8 G3 E% |2 I) S; I
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...3 [1 f V/ g+ F0 W% J# {. t+ M
compiling stm32f7xx_hal.c...9 R3 w: X o* ^3 K8 T
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c..." p4 w# V0 ?* |* n
compiling system_stm32f7xx.c...1 o8 b, `1 A# c0 k1 O8 \
compiling aiPbMgr.c...& w( Q( a0 D8 u1 r) W/ C' ^) y
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error% p$ P- N" K- R* k$ X
compiling aiValidation.c...2 w' X, }" G, P" s
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"$ F! y' a$ U8 \% E4 i/ U
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error& Q% S" z( u! S2 f
compiling pb_common.c...
compiling pb_decode.c...
compiling pb_encode.c...
compiling stm32msg.pb.c...3 {. I8 e% ^7 D3 M0 c3 A# N- U
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s...
compiling main.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"
../Src/main.c: 0 warnings, 1 error$ G N% u1 N t
compiling app_x-cube-ai.c...6 a$ P' r( r. G4 d K
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"! f4 v3 u( ~4 X k; ~% ?
../Src/app_x-cube-ai.c: 0 warnings, 1 error, s" O. U4 b1 r0 q; W; O
compiling stm32f7xx_it.c...; V H& U6 K" q
compiling stm32f7xx_hal_msp.c...
compiling stm32f7xx_hal_cortex.c...
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c...
compiling stm32f7xx_hal_tim.c.../ f# j, W6 b8 p c& q) `
compiling stm32f7xx_hal_tim_ex.c...# E2 f1 m, `; Q, M
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...% w: r& L" C$ I( q! [. G
compiling stm32f7xx_hal_rcc.c...
compiling stm32f7xx_hal_rcc_ex.c...
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...7 I4 V& n& w$ {* Y( n" v
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...6 }; D: j$ x# Y( x$ _/ E8 m [
compiling stm32f7xx_hal_dma_ex.c...
compiling stm32f7xx_hal_pwr.c...9 R8 \3 k- Y0 \4 ^. j3 x" b& u4 Z+ K
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c...+ A& T3 p& B5 M. G3 D, U
compiling stm32f7xx_hal_i2c.c...1 t1 ^2 ?! I1 K8 y0 o. Q/ ~
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...
compiling system_stm32f7xx.c...
compiling aiPbMgr.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory& |! |; ? K0 H* r" S7 c h- [6 A
#include "network.h"- a5 Z. y3 H3 e2 ?
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error P& ?) M( I7 J0 G" C+ m3 c0 Z
compiling aiTestUtility.c...- y$ t6 T/ t2 _7 c3 }
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory3 g0 X5 @9 r, r
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error, b7 U$ Q! Y6 f _% F
compiling aiValidation.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory9 U0 }: m# t$ l- U, C' Q" Q& J
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error
compiling pb_common.c...
compiling pb_decode.c...
compiling pb_encode.c...$ N5 L- ?2 O" A& U/ m$ x* V Q
compiling stm32msg.pb.c...0 x5 N& S( G( D/ s$ k; ]
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库6 F6 {0 ^; A1 I) n' W
5 j, R# |4 P' r/ S) R, t
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。
' t, P- J! }$ \, j- R9 U
) k8 l4 v6 X% }- x; X
. E+ g) k1 p6 w3 m# }8 o
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗# b: d7 K2 ~, x6 x+ j5 W