
偶然看到一篇好文章,分享给大家。 3 g3 S' N& S/ D. z ![]() 今天介绍下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 $ Q1 `. h9 B5 T那先前的准备工作就是需要安装最新版本的CubeMx 5.0.1 然后使用CubeMx 去安装X-CUBE-AI插件, 700多M的容量。。慢慢下载吧 0 k; G; a3 t4 s6 Y5 F/ M![]() 下载好后,CubeMx里的Artificial intelligent 激活Enable * Y, L+ V0 K4 ?7 C! m! x* \9 n, g![]() 这里我们就可以看到里面的选项了 下载下来。。然后选择Keras 的AI API算法 ( M. Q0 K3 Q w) T! b![]() model.h5就是我们需要导入到工程里的AI Keras的训练好的模型 2 P7 e' O9 U! P( ^9 h![]() Human Activity Recognition Using Convolutional Neural Network in Keras 人类活动识别卷积神经网络算法模型 ![]() 然后我们导入到工程里 ![]() 这里选择压缩参数,不同的压缩参数对MCU的flash容量 要求也不一样。。 ![]() 点击Analyze cube就好计算使用这个神经网络算法的ram和flash容量占用 ![]() 好了结果出来了, ![]() 经过分析后Cube会自动列出可以使用的MCU 然后显示在列表里 ![]() 这里举个例子,我们选择没有压缩优化 分析模型算法后的结果我没有匹配的MCU可以使用 ![]() 这是选择压缩比参数8的结果,可以支持很多的MCU使用这个神经网络算法。。 , o2 C; a9 @) P" e Y8 r5 N& t![]() 好了,这里我们就选择STM32F767ZI Nucleo 板卡作为 这次演示使用的板卡 ![]() ![]() 选择好Validation 和打勾 AI core ) {( P% h L) N% H: p- j5 g1 U![]() 然后在cube 左下方可以看到下图箭头 提示的插件功能 - x7 ^& l5 e- m0 l) H% |( T![]() 我们需要打勾以下2个功能 1 c" k3 ?4 h5 j! S c g1 s![]() 然后创建我的AI算法名称,这个名称会在后续的里自动创建好。 ![]() 添加好,我们下载好的AI神经网络算法,然后再Analyze下就好。。打勾表示验证通过 $ K+ w3 N- V0 U* T" z+ Z![]() 然后我们需要配置我们的mcu的 CPU ICache 和 CPU DCache ![]() 然后配置MCU主频为216Mhz ( G& A$ L9 x2 i( Y8 O& r2 y& f/ P![]() 然后我们需要配置串口3和CubeMx进行通讯,验证我们工程。。。 : H, @- {( E6 u' \![]() 然后在 AI扩展功能里选择通讯端口为串口3 $ C5 J! p/ Q! Z' S![]() . D. r5 {8 D5 r ![]() 好了工程生成好了,我们就可以 使用IAR 打开工程了 工程如下,工程里自动生成了基于AI的算法的所以文件 0 D. k" _& q% e: h( X w" Y![]() 这里可以看到,基于AI训练好的模型数据列表。。。 $ }8 C3 m: i# V) `! v![]() 好了,配置位STLINK,然后编译好就可以直接下载到板子上了 $ u' v, B' R& ^. |: H![]() ![]() 好了,现在我们需要回到CubeMx里,回到 AI扩展功能里。。 先重启下开发板,然后 点击Validation on target . d, g; G" L) Y5 Q& I$ H![]() 选择手动,然后选择对应的串口端口 3 f! q7 d" o2 l9 N i# e![]() 这里可以看到验证已经开始了‘ ’ ![]() 好了,结果出来了。我们可以在串口输出的信息里看到有关的数据 ; y) Y3 V' ~: o![]() ![]() ![]() ![]() 好了,基于CubeMx+AI扩展库的使用就分享到这了,想了解更多关于 使用STM32 AI的朋友可以关注ST官网的教程。。。 |
【STM32N6570-DK评测】1.开箱测评
【STM32F769I-DISC1】开发板刷入Micropython并完成点灯、读取内部温度测试
【STM32F769I-DISC1】测评01:创建STM32cube IDE 工程,点个灯
【STM32F769】创建deepseek本地服务,并实现http请求
【STM32N6570-DK评测】1.你好N6
实战经验 | STM32 AI Model Zoo 的安装及实例介绍
STM32F10xxx 正交编码器接口应用笔记 及源代码
汇编浮点库qfplib移植STM32F769I-DISCO开发板与硬件浮点运算性能测试对比
coremark移植到STM32F769I-DISCO开发板的两种方法
【GUI板免费申请活动】【圣诞GUI】使用F746-DISO基于TouchGFX的圣诞树
assembling startup_stm32f767xx.s...+ e1 e3 x3 w$ X+ {
compiling main.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory3 R2 s4 Q$ e, A; ^2 M
#include "network.h"# d1 M* S4 Z( D+ D. A! @. F9 f5 w
../Src/main.c: 0 warnings, 1 error
compiling app_x-cube-ai.c... G3 W+ \( B. {
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory/ u4 b' q. L. m7 s- a
#include "network.h"
../Src/app_x-cube-ai.c: 0 warnings, 1 error
compiling stm32f7xx_it.c...
compiling stm32f7xx_hal_msp.c...( C' T/ w6 a- e% H/ s6 ~4 w7 O k
compiling stm32f7xx_hal_cortex.c...' G5 Y4 ~ L% b
compiling stm32f7xx_hal_crc.c...
compiling stm32f7xx_hal_crc_ex.c...6 B8 z9 v3 s1 o: n
compiling stm32f7xx_hal_tim.c...
compiling stm32f7xx_hal_tim_ex.c...
compiling stm32f7xx_hal_uart.c...' F, ~" F9 g9 ]: g# L
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...* ]5 X8 S" A/ {3 W, P4 n; }& J
compiling stm32f7xx_hal_rcc_ex.c...) [4 e, o" x" H7 D0 W3 V9 n) H
compiling stm32f7xx_hal_flash.c...& H( Z7 d: a, a% T' _& ]
compiling stm32f7xx_hal_flash_ex.c...1 S4 }9 U' X. g) T1 H a3 e4 s5 N( y
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...6 G" s# O t8 e# ]
compiling stm32f7xx_hal_dma_ex.c...% G+ w$ w3 m2 l" V
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...1 G7 t- P5 a, G2 y! _5 x
compiling stm32f7xx_hal.c...
compiling stm32f7xx_hal_i2c.c...
compiling stm32f7xx_hal_i2c_ex.c...
compiling stm32f7xx_hal_exti.c...# r, j5 R/ o1 P A4 d! Q
compiling system_stm32f7xx.c...: b7 `6 c! X& V* @& t. g
compiling aiPbMgr.c...6 T" E: f- F& S" ~5 K
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory1 S+ L' x+ q5 @, u, m# ?
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error
compiling aiTestUtility.c...3 c! \8 o' O, ^& W+ S
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory: V% @7 G6 Z& n
#include "network.h"4 Q, i" v: W: E- ~- Q; H$ d) O
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error( V H8 s) L8 {2 ?9 P! u7 h
compiling aiValidation.c...* ~ k$ i+ H) m, H, l. 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"6 X2 _; V: z- k, K, ]& R4 e
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiValidation.c: 0 warnings, 1 error' j6 [+ E/ V }) `! o H$ J: ]
compiling pb_common.c...
compiling pb_decode.c...
compiling pb_encode.c...
compiling stm32msg.pb.c...
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
assembling startup_stm32f767xx.s...! W- v+ a8 M! B0 Q& J, _6 q5 C9 L
compiling main.c...5 `" N# X+ c5 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"
../Src/main.c: 0 warnings, 1 error
compiling app_x-cube-ai.c...$ O$ G" J8 Y" T
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory
#include "network.h"& P2 W! t, ~1 ^) E
../Src/app_x-cube-ai.c: 0 warnings, 1 error$ k; f/ ?* W; D& [: ?+ d8 Y7 s2 Q
compiling stm32f7xx_it.c...
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...
compiling stm32f7xx_hal_tim_ex.c...- k, J/ d% I8 {+ D+ Q& l. l+ r( d
compiling stm32f7xx_hal_uart.c...
compiling stm32f7xx_hal_uart_ex.c...
compiling stm32f7xx_hal_rcc.c...& w( G- a+ V4 }
compiling stm32f7xx_hal_rcc_ex.c...' y3 c, O) e2 ]3 g
compiling stm32f7xx_hal_flash.c...
compiling stm32f7xx_hal_flash_ex.c...
compiling stm32f7xx_hal_gpio.c...
compiling stm32f7xx_hal_dma.c...
compiling stm32f7xx_hal_dma_ex.c...) W9 O# ?/ J7 U
compiling stm32f7xx_hal_pwr.c...
compiling stm32f7xx_hal_pwr_ex.c...
compiling stm32f7xx_hal.c.../ V# f( o$ p5 B( D" i. Q, \( q
compiling stm32f7xx_hal_i2c.c...# m$ B4 s3 w& b/ t7 i4 S8 T I
compiling stm32f7xx_hal_i2c_ex.c...2 c3 C- I1 U2 i
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$ B3 d' z) w; Y7 N6 y
#include "network.h"
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiPbMgr.c: 0 warnings, 1 error! Q$ ~) G6 ^+ \! G) l
compiling aiTestUtility.c...
../Inc/app_x-cube-ai.h(77): error: #5: cannot open source input file "network.h": No such file or directory+ l( U3 D) k, n* ?
#include "network.h"6 V: Z" x8 V8 q- D9 h
../Middlewares/ST/X-CUBE-AI_Application/Validation/Src/aiTestUtility.c: 0 warnings, 1 error! u/ \# p6 E5 q
compiling aiValidation.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"7 i) q' ]- E4 n3 l
../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...
compiling stm32msg.pb.c...1 V ~2 H! ^' \9 R: T, M
"STM32F767_AI\STM32F767_AI.axf" - 5 Error(s), 0 Warning(s).
Target not created.
首先确保已经安装了AI库& a- w6 D1 s2 R: H# |' e U9 C
使能Atificial intelligence后,配置好参数,确保自己使用的单片机是在列表中的。" |9 f6 f" E) }" e6 j
z! m( q$ f/ n# n/ y5 E
9 `( D7 [ @8 U$ `
如果确定上面操作无误,界面还是空的话那就看看这里的配置是否和你真实的路径是一致的。
厉害了
model.h5就是我们需要导入到工程里的AI Keras的训练好的模型
输出吗 这是去使用库的AI神经算法
我导入model.h5就没反应了,没有出现他教程中的STM32F767AI.H5,请问要怎么操作
导入到工程的时候,没出现STM32F767AI.h5吗4 f) {/ X1 ?; G1 r9 C