提交 9ab89afe 编写于 作者: 一生痴绝处's avatar 一生痴绝处

Update tflite_micro doc

上级 da6da2c8
......@@ -2,11 +2,11 @@
**作者:**
Github: [Derekduke](https://github.com/Derekduke) E-mail: dkeji627@gmail.com
Github ID: [Derekduke](https://github.com/Derekduke) E-mail: dkeji627@gmail.com
Github: [QingChuanWS](https://github.com/QingChuanWS) E-mail: bingshan45@163.com
Github ID: [QingChuanWS](https://github.com/QingChuanWS) E-mail: bingshan45@163.com
Github: [yangqings](https://github.com/yangqings) E-mail: yangqingsheng12@outlook.com
Github ID: [yangqings](https://github.com/yangqings) E-mail: yangqingsheng12@outlook.com
## 概述
......@@ -50,7 +50,7 @@ Github: [yangqings](https://github.com/yangqings) E-mail: yangqingsheng12@outlo
有三种方式获取tflite_micro:
1. 从TencentOS tiny 代码仓库 `components\ai\tflite_micro`目录获取;
2. 以lib文件的形式使用tflite_micro组件,lib文件`TencentOS-tiny\components\ai\tflite_micro`的ARM_CortexM4_lib、ARM_CortexM7_lib和ARM_CortexM55_lib文件夹
2. 以lib文件的形式使用tflite_micro组件,lib文件`TencentOS-tiny\components\ai\tflite_micro`的ARM_CortexM4_lib、ARM_CortexM7_lib和ARM_CortexM55_lib文件夹
3. 从Tensorflow代码仓库获取,TFlite_Micro的源码已经开源,github仓库地址为:https://github.com/tensorflow/tensorflow ,可根据google TFLite Micro官方教程获得Tensorflow Lite Micro的全部源码。
如果没有tflite_micro开发经验,建议以**第一种**或者**第二种**方式获取tflite_micro,希望自行获取最新源码,或者编译lib文件,请参考`TencentOS-tiny\components\tflite_micro`目录的TFlite_Micro_Component_User_Guide.md文档,本指南将直接使用TencentOS tiny 代码仓库内的tflite_micro组件。
......@@ -61,17 +61,16 @@ Github: [yangqings](https://github.com/yangqings) E-mail: yangqingsheng12@outlo
以下是整个例程的目录规划:
| 一级目录 | 二级目录 | 三级目录 | 说明 |
| :-------: | :--------------------------: | :-------------------: | :----------------------------------------------------------: |
| arch | arm | | TencentOS tiny适配的IP核架构(含M核中断、调度、tick相关代码) |
| board | NUCLEO_STM32L496ZG | | 移植目标芯片的工程文件 |
| | | BSP | 板级支持包,外设驱动代码在Hardware目录 |
| component | ai | tflite_micro | tflite_micro源码及有关库文件 |
| examples | tflitemicro_person_detection | | 行人检测demo示例 |
| | | tflu_person_detection | 行人检测实例代码 |
| kernel | core | | TencentOS tiny内核源码 |
| | pm | | TencentOS tiny低功耗模块源码 |
| osal | cmsis_os | | TencentOS tiny提供的cmsis os 适配 |
| 一级目录 | 二级目录 | 三级目录 | 说明 |
| :-------: | :--------------------------: | :----------: | :----------------------------------------------------------: |
| arch | arm | | TencentOS tiny适配的IP核架构(含M核中断、调度、tick相关代码) |
| board | NUCLEO_STM32L496ZG | | 移植目标芯片的工程文件 |
| | | BSP | 板级支持包,外设驱动代码在Hardware目录 |
| component | ai | tflite_micro | tflite_micro源码 |
| examples | tflitemicro_person_detection | | 行人检测demo示例 |
| kernel | core | | TencentOS tiny内核源码 |
| | pm | | TencentOS tiny低功耗模块源码 |
| osal | cmsis_os | | TencentOS tiny提供的cmsis os 适配 |
完成TencentOS tiny基础keil工程准备工作后,在这个keil工程的基础上继续添加外设驱动代码。
......@@ -210,9 +209,9 @@ void task1(void *arg)
其中,retarget.c的路径为:`TencentOS-tiny\components\ai\tflite_micro\KEIL\retarget.c`
tensorflow_lite_micro.lib的路径为:`TencentOS-stiny\components\ai\tflite_micro\ARM_CortexM4_lib\tensorflow_lite_micro.lib`
tensorflow_lite_micro.lib的路径为:`TencentOS-tiny\components\ai\tflite_micro\ARM_CortexM4_lib\tensorflow_lite_micro.lib`
其余.cc文件和.h均在`examples\tflu_person_detection\tflu_person_detection`文件夹中。
其余.cc文件均在当前目录下的`tflu_person_detection`文件夹中。
#### 1.3 关闭Keil的MicroLib库
......@@ -244,7 +243,7 @@ TencentOS-tiny\components\ai\tflite_micro\ARM_CortexM4_lib\tensorflow\lite\micro
本例程的任务函数在
`TencentOS-tiny\examples\tflitemicro_person_detection\tflitemicro_person_detection.c`
`TencentOS-tiny\examples\tflitemicro_person_detection\tflitemicro_person_detection.c`目录下
#### 2.1 图像预处理
......@@ -312,13 +311,13 @@ void task2(void *arg)
#### 2.3 运行效果
通过串行输出实时打印信息,移动摄像头,没有对准行人时,输出如下:
通过串行输出实时打印信息,移动摄像头,镜头没有对准行人时,输出如下:
<div align=center>
<img src="./image/reasult_no_person.png" width=70% />
</div>
摄像头对准行人时,输出如下:
头对准行人时,输出如下:
<div align=center>
<img src="./image/reasult_person.png" width=70% />
......
# Tensorflow Lite Micro 使用指南
## 1.组件介绍
## 1. 组件介绍
TensorFlow Lite Micro 组件是 Google TensorFlow 团队针对微处理器平台设计的端侧推理框架,该推理框架主要解决在资源, 功耗, 性能受限的嵌入式系统中, 如何简单快速高效部署 Tensorflow Lite 深度学习模型。CMSIS 全称 Software Interface Standard for Arm Cortex-based Microcontrollers,其中 CMSIS-NN 组件为 AI 加速库,包含高效的神经网络算子来减小内存占用和最大化硬件性能。相关代码和文档已经开源并在多个平台上得到验证( https://www.keil.com/pack/doc/CMSIS/NN/html/index.html )。
## 2.目录结构
## 2. 目录结构
组件目录结构如下图所示:
......@@ -20,13 +20,13 @@ tflite_micro
```
其中,KEIL 文件夹包含针对 KEIL 编程环境需要额外添加的源文件(将其中的源文件一同加入工程)。
其中,KEIL 文件夹包含针对 KEIL 编程环境需要额外添加的源文件(将其中的源文件一同加入工程)。
ARM_CortexM4_lib 和 ARM_CortexM7_lib 两个文件夹中存放了针对 Cortex M4、Cortex M7 平台预编译的 tensorflow_lite_micro.lib 库,优化后的性能数据可以参考附录部分;如果在开发过程中采用 ARM Cortex M4 或 Cortex M7 系列芯片可以直接使用对应的 tensorflow_lite_micro.lib 库,并包含相关的头文件,极大的缩短了开发时间。
[TFlite_Micro_Component_User_Guide.md](./TFlite_Micro_Component_User_Guide.md) 中提供了本组件的使用说明以及上述 .lib 库的制作方法。
## 3.组件使用案例
## 3. 组件使用案例
基于本组件我们以 STM32L496RG 为例设计了行人检测案例,具体使用流程可参考[Neclue STM32L496RG案例](../../../board/NUCLEO_STM32L496ZG/KEIL/tflitemicro_person_detection/TFlite_Micro_Demo移植参考指南(Keil版).md)
......@@ -37,9 +37,21 @@ ARM_CortexM4_lib 和 ARM_CortexM7_lib 两个文件夹中存放了针对 Cortex M
- 测试输入图片:`tensorflow\lite\micro\tools\make\downloads\person_model_int8` 目录中 `person_image_data.cc``no_person_image_data.cc` 保存的 96 * 96 pixels ( uint_8 ) 灰度图。
- 单次执行和 10 次累计执行的测试结果如下:
| Case | Disable ARM-CMSIS-NN | Enable ARM-CMSISNN | Improvement |
| Case | Disable ARM-CMSIS-NN | Enable ARM-CMSISNN | Improvement |
| :--------------------------------------------: | :----------------------: | :------------------: | :---------: |
| Initialize_Benchmark_Runner | 65 ticks (65 ms) | 66 ticks (66 ms) | * |
| Run_Single_Iteration | 12476 ticks (12476 ms) | 633 ticks (633 ms) | 19.71X |
| Person_Detection_Ten_Ierations_With_Person | 124769 ticks (124769 ms) | 6324 ticks (6324 ms) | 19.73X |
| Person_Detection_Ten_Ierations_With_out_Person | 124770 ticks (124770 ms) | 6325 ticks (6325 ms) | 19.72X |
\ No newline at end of file
| Person_Detection_Ten_Ierations_With_out_Person | 124770 ticks (124770 ms) | 6325 ticks (6325 ms) | 19.72X |
## 5. TencentOS-tiny AI 开发组件
TencentOS-tiny 已将 Tensorflow Lite Micro 以及 CMSIS-NN 集成到 AI 组件中,并通过其他组件与腾讯云无缝相连,打通从云到端整条链路,助力 AI 的发展与落地。随着越来越多的厂商采用 Arm Cortex M55 和 Ethos U NPU IP,相信未来端侧AI的应用会更加广阔。
TencentOS-tiny AI组件:https://github.com/rceet/tencentos-tiny-with-tflitemicro-and-iot/tree/master/components/ai/tflite_micro
Arm Cortex M55:https://www.arm.com/products/silicon-ip-cpu/cortex-m/cortex-m55
Arm Ethos U55:https://www.arm.com/products/silicon-ip-cpu/ethos/ethos-u55
Arm Ethos U65:https://www.arm.com/products/silicon-ip-cpu/ethos/ethos-u65
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册