未验证 提交 aa7ace64 编写于 作者: baiyu33's avatar baiyu33 提交者: GitHub

Fix tengine lite doc (#449)

* polish readme

* add example/README.md's english version
上级 d48aa271
......@@ -12,17 +12,18 @@
## 简介
**Tengine Lite****OPEN AI LAB** 主导开发,该项目实现了深度学习神经网络模型在嵌入式设备上的**快速****高效**部署需求。为实现在众多 **AIoT** 应用中的跨平台部署,本项目基于原有 Tengine 项目使用 **C 语言**进行重构,针对嵌入式设备资源有限的特点进行了深度框架裁剪。同时采用了完全分离的前后端设计,有利于 CPU、GPU、NPU 等异构计算单元的快速移植和部署。同时**兼容 Tengine** 框架原有 API 和 模型格式 tmfile,降低评估、迁移成本。
**Tengine Lite****[OPEN AI LAB](http://www.openailab.com)** 主导开发,该项目实现了深度学习神经网络模型在嵌入式设备上的**快速****高效**部署需求。为实现在众多 **AIoT** 应用中的跨平台部署,本项目基于原有 Tengine 项目使用 **C 语言**进行重构,针对嵌入式设备资源有限的特点进行了深度框架裁剪。同时采用了完全分离的前后端设计,有利于 CPU、GPU、NPU 等异构计算单元的快速移植和部署。同时**兼容 Tengine** 框架原有 API 和 模型格式 tmfile,降低评估、迁移成本。
Tengine Lite 核心代码由 4 个模块组成:
- [**dev**](src/dev) NN Operators 后端模块,当前提供 CPU 代码,后续逐步开源 GPU、NPU 参考代码;
- [**dev**](src/dev):NN Operators 后端模块,当前提供 CPU 代码,后续逐步开源 GPU、NPU 参考代码;
- [**lib**](src/lib):框架核心部件,包括 NNIR、计算图、硬件资源、模型解析器的调度和执行模块;
- [**op**](src/op):NN Operators 前端模块,实现 NN Operators 注册、初始化;
- [**serializer**](src/serializer):模型解析器,实现 tmfile 格式的网络模型参数解析。
## 架构简析
![Tengine Lite 架构](doc/architecture.png)
......@@ -38,7 +39,7 @@ Tengine Lite 核心代码由 4 个模块组成:
### 模型仓库
- [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q) 兼容原有 Tengine 的模型示例仓库(密码:hhgc)。
- [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q) 兼容原有 Tengine 的模型示例仓库(密码:_hhgc_)。
### 转换工具
......@@ -55,6 +56,7 @@ Tengine Lite 核心代码由 4 个模块组成:
- [Road map](doc/roadmap.md)
## 致谢
Tengine Lite 参考和借鉴了下列项目:
- [Caffe](https://github.com/BVLC/caffe)
......@@ -66,7 +68,7 @@ Tengine Lite 参考和借鉴了下列项目:
- [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite)
- [ACL](https://github.com/ARM-software/ComputeLibrary)
- [stb](https://github.com/nothings/stb)
- [convertmodel](https://convertmodel.com/)
- [convertmodel](https://convertmodel.com)
## License
......@@ -77,7 +79,8 @@ Tengine Lite 参考和借鉴了下列项目:
- [FAQ 常见问题](doc/faq.md)
## 技术讨论
- Github issues
- QQ 群: 829565581
- Email: Support@openailab.com
- Tengine 社区: http://www.tengine.org.cn/
- Tengine 社区: http://www.tengine.org.cn
......@@ -12,7 +12,7 @@
## Introduction
**Tengine Lite** is developed by **OPEN AI LAB**. This project implements the **fast** and **efficient** deployment of deep learning neural network models on embedded devices. In order to achieve cross-platform deployment in many **AIoT** applications, this project is based on the original Tengine project using **C language** for reconstruction, and deep frame tailoring for the characteristics of limited embedded device resources. Also, it adopts a completely separated front-end/back-end design, which makes it possible to be transplanted and deployed onto CPU, GPU, NPU and other heterogeneous computing units rapidly, conveniently. At the same time, it is compatible with the original API and model format `tmfile` of **Tengine**, which reduces the cost of evaluation and migration.
**Tengine Lite** is developed by **[OPEN AI LAB](http://www.openailab.com)**. This project meet the demand of **fast** and **efficient** deployment of deep learning neural network models on embedded devices. In order to achieve cross-platform deployment in many **AIoT** applications, this project is based on the original Tengine project using **C language** for reconstruction, and deep frame tailoring for the characteristics of limited embedded device resources. Also, it adopts a completely separated front-end/back-end design, which makes it possible to be transplanted and deployed onto CPU, GPU, NPU and other heterogeneous computing units rapidly, conveniently. At the same time, it is compatible with the original API and model format `tmfile` of **Tengine**, which reduces the cost of evaluation and migration.
......@@ -25,6 +25,7 @@ The core code of Tengine Lite consists of 4 modules:
## Architecture
![Tengine Lite 架构](doc/architecture.png)
......@@ -40,7 +41,7 @@ The core code of Tengine Lite consists of 4 modules:
### Model Zoo
- [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q) Model zoo samples are compatible with the original Tengine (password: hhgc).
- [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q) Model zoo samples are compatible with the original Tengine (password: _hhgc_).
### Model Convert tool
......@@ -50,7 +51,7 @@ The core code of Tengine Lite consists of 4 modules:
### Speed assessment
-[Benchmark](benchmark/) Basic network speed assessment tool, any pull request is welcomed.
- [Benchmark](benchmark/) Basic network speed assessment tool, any pull request is welcomed.
## Roadmap
......@@ -69,7 +70,7 @@ Tengine Lite got ideas and developed based on these projects:
- [Paddle Lite](https://github.com/PaddlePaddle/Paddle-Lite)
- [ACL](https://github.com/ARM-software/ComputeLibrary)
- [stb](https://github.com/nothings/stb)
- [convertmodel](https://convertmodel.com/)
- [convertmodel](https://convertmodel.com)
## License
......@@ -80,7 +81,8 @@ Tengine Lite got ideas and developed based on these projects:
- [FAQ common questions](doc/faq.md)
## Tech Forum
- Github issues
- QQ groupchat: 829565581
- Email: Support@openailab.com
- Tengine Community: http://www.tengine.org.cn/
- Tengine Community: http://www.tengine.org.cn
# examples
[**English Version**](README_EN.md)
Tengine Lite 的 examples 将提供简单的、好玩的 demo。
## 分类任务 - [tm_classification.c](tm_classification.c)
......@@ -54,8 +56,8 @@ install
将测试图片和模型文件放在 Tengine-Lite 根目录下,运行:
```bash
$ export LD_LIBRARY_PATH=./build/install/lib
$ ./build/install/bin/tm_classification -m models/mobilenet.tmfile -i images/cat.jpg -g 224,224 -s 0.017,0.017,0.017 -w 104.007,116.669,122.679
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_classification -m models/mobilenet.tmfile -i images/cat.jpg -g 224,224 -s 0.017,0.017,0.017 -w 104.007,116.669,122.679
```
结果如下:
......@@ -84,8 +86,8 @@ Repeat 1 times, thread 1, avg time 656.76 ms, max_time 656.76 ms, min_time 656.7
![](https://github.com/OAID/Tengine/blob/master/tests/images/mobileface02.jpg)
```bash
$ export LD_LIBRARY_PATH=./build/install/lib
$ ./build/install/bin/tm_landmark -m models/landmark.tmfile -i images/mobileface02.jpg -r 1 -t 1
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_landmark -m models/landmark.tmfile -i images/mobileface02.jpg -r 1 -t 1
```
结果如下:
......@@ -294,8 +296,8 @@ KeyPoints Coordinate:
![](https://s1.ax1x.com/2020/10/20/BSlFPS.jpg)
```bash
$ export LD_LIBRARY_PATH=./build/install/lib
$ ./build/install/bin/tm_crnn -m model/crnn_lite_dense.tmfile -i model/o2_resize.jpg -l model/keys.txt
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_crnn -m model/crnn_lite_dense.tmfile -i model/o2_resize.jpg -l model/keys.txt
```
结果如下:
......
# examples
[**中文版本**](README.md)
Tengine Lite's examples providing simple yet fancy demos.
## Classification task - [tm_classification.c](tm_classification.c)
Tengine Lite is compatible with original Tengine's C API. Here we demonstrate how to run MobileNet v1 via tm_classification example code, providing image classification functionality. This would help you get involve with Tengine Lite C API. We use the popular tiger cat image for test.
![lu mao](https://github.com/OAID/Tengine/blob/master/tests/images/cat.jpg)
Model files can be found here: [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q), which are compatible with original Tengine example models(password:_hhgc_)。
### Reference Code
[tm_classification.c](tm_classification.c)
### Compilation
build.sh compiles example folders demo programs on default. Take x86 platform as example, the compilation generated demos are stored in `./build/install/bin/` folder.
```bash
bug1989@DESKTOP-SGN0H2A:/mnt/d/ubuntu/gitlab/build-linux$ tree install
install
├── bin
│   ├── cpp_tm_classification
│   ├── cpp_tm_mobilenet_ssd
│   ├── tm_benchmark
│   ├── tm_classification
│   ├── tm_classification_fp16
│   ├── tm_classification_uint8
│   ├── tm_classification_vulkan
│   ├── tm_crnn
│   ├── tm_landmark
│   ├── tm_landmark_uint8
│   ├── tm_mobilefacenet
│   ├── tm_mobilenet_ssd
│   ├── tm_mobilenet_ssd_acl
│   ├── tm_mobilenet_ssd_uint8
│   ├── tm_openpose
│   ├── tm_retinaface
│   ├── tm_yolact
│   ├── tm_yolov3_tiny
│   ├── tm_yolov3_uint8
│   ├── tm_yolov4
│   └── tm_yolov4_tiny
├── include
│   └── tengine_c_api.h
└── lib
└── libtengine-lite.so
```
### Running Result
Put testing images and models under root folder of Tengine-Lite project, and run it:
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_classification -m models/mobilenet.tmfile -i images/cat.jpg -g 224,224 -s 0.017,0.017,0.017 -w 104.007,116.669,122.679
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
model file : ./temp/models/mobilenet.tmfile
image file : ./temp/images/cat.jpg
img_h, img_w, scale[3], mean[3] : 224 224 , 0.017 0.017 0.017, 104.0 116.7 122.7
Repeat 1 times, thread 1, avg time 656.76 ms, max_time 656.76 ms, min_time 656.76 ms
--------------------------------------
8.574148, 282
7.880116, 277
7.812579, 278
7.286453, 263
6.357488, 281
--------------------------------------
```
## Facial Landmark Detection Task - [tm_landmark.cpp](tm_landmark.cpp)
We use this image:
![](https://github.com/OAID/Tengine/blob/master/tests/images/mobileface02.jpg)
Run it with:
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_landmark -m models/landmark.tmfile -i images/mobileface02.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat [1] min 17.461 ms, max 17.461 ms, avg 17.461 ms
```
![](https://s1.ax1x.com/2020/08/28/doZQxO.jpg)
## SSD Object Detection Task - [tm_mobilenet_ssd.cpp](tm_mobilenet_ssd.cpp)
We use this image:
![](https://github.com/OAID/Tengine/blob/master/tests/images/ssd_dog.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_mobilenet_ssd -m models/mobilenet_ssd.tmfile -i images/ssd_dog.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat 1 times, thread 1, avg time 206.30 ms, max_time 206.30 ms, min_time 206.30 ms
--------------------------------------
detect result num: 3
dog :99.8%
BOX:( 138 , 209 ),( 324 , 541 )
car :99.7%
BOX:( 467 , 72 ),( 687 , 171 )
bicycle :99.5%
BOX:( 107 , 141 ),( 574 , 415 )
======================================
[DETECTED IMAGE SAVED]:
======================================
```
![](https://s1.ax1x.com/2020/08/28/doeJ6U.jpg)
## RetinaFace Face Detection Task - [tm_refinaface.cpp](tm_refinaface.cpp)
We use this image:
![](https://github.com/OAID/Tengine/blob/master/tests/images/mtcnn_face4.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_retinaface -m models/retinaface.tmfile -i images/mtcnn_face4.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
img_h, img_w : 316, 474
Repeat 1 times, thread 1, avg time 75.72 ms, max_time 75.72 ms, min_time 75.72 ms
--------------------------------------
detected face num: 4
BOX 0.99:( 38.9179 , 86.3346 ),( 45.7028 , 63.2934 )
BOX 0.99:( 168.12 , 86.14 ),( 37.5249 , 47.7839 )
BOX 0.98:( 383.673 , 56.4136 ),( 77.176 , 83.8093 )
BOX 0.98:( 289.365 , 103.773 ),( 38.0025 , 47.6989 )
```
![](https://s1.ax1x.com/2020/08/28/doeBfx.jpg)
## Yolact Instance Segmentation Task - [tm_yolact.cpp](tm_yolact.cpp)
We use this image:
![](https://github.com/OAID/Tengine/blob/master/tests/images/ssd_car.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_yolact -m models/yolact.tmfile -i images/ssd_car.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat 1 times, thread 1, avg time 15833.47 ms, max_time 15833.47 ms, min_time 15833.47 ms
--------------------------------------
6 = 0.99966 at 130.82 57.77 340.78 x 237.36
3 = 0.99675 at 323.39 194.97 175.57 x 132.96
1 = 0.33431 at 191.24 195.78 103.06 x 179.22
```
![](https://s1.ax1x.com/2020/08/28/doe4ht.png)
## YoloV3 Object Detection Task - [tm_yolov3.cpp](tm_yolov3.cpp)
We use this image:
![](https://github.com/OAID/Tengine/blob/master/tests/images/ssd_dog.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_yolact -m models/yolov3_tiny.tmfile -i images/ssd_dog.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat 1 times, thread 1, avg time 262.52 ms, max_time 262.52 ms, min_time 262.52 ms
--------------------------------------
num_detections,4
16: 57%
left = 129,right = 369,top = 186,bot = 516
2: 65%
left = 465,right = 677,top = 74,bot = 171
1: 60%
left = 205,right = 576,top = 153,bot = 447
```
![](https://s1.ax1x.com/2020/08/28/domYCt.jpg)
## Human Pose Estimation Task - [tm_openpose.cpp](tm_openpose.cpp)
We use this image:
![](https://s1.ax1x.com/2020/09/01/dvJm8A.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_openpose -m models/openpose_coco.tmfile -i image/pose.jpg -r 1 -t 1
```
output:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat 1 times, thread 1, avg time 15350.25 ms, max_time 15350.25 ms, min_time 15350.25 ms
--------------------------------------
KeyPoints Coordinate:
0:[292.174, 55.6522]
1:[306.087, 125.217]
2:[250.435, 139.13]
3:[236.522, 222.609]
4:[222.609, 306.087]
5:[361.739, 125.217]
6:[403.478, 208.696]
7:[417.391, 292.174]
8:[264.348, 306.087]
9:[264.348, 431.304]
10:[264.348, 570.435]
11:[347.826, 306.087]
12:[375.652, 431.304]
13:[333.913, 542.609]
14:[278.261, 41.7391]
15:[306.087, 41.7391]
16:[264.348, 55.6522]
17:[320, 55.6522]
```
![](https://s1.ax1x.com/2020/09/01/dvJ2x1.jpg)
![](https://s1.ax1x.com/2020/09/01/dvJxZ8.jpg)
The result of human pose estimation will be saved as images, whose names are: `Output-Keypionts.jpg` and `Output-Skeleton.jpg`.
## Chinese character recognition task - [tm_crnn.cpp](tm_crnn.cpp)
Folder structure: create `model` directory under project root directory, and download corresponding model and testing image files from [Tengine model zoo](https://pan.baidu.com/s/1Ar9334MPeIV1eq4pM1eI-Q) ( password:_hhgc_ ) there. Specifically, `crnn_lite_dense.tmfile` as model file, `o2_resize.jpg` as testing image, `keys.txt` as font file. Then we execute:
![](https://s1.ax1x.com/2020/10/20/BSlFPS.jpg)
```bash
export LD_LIBRARY_PATH=./build/install/lib
./build/install/bin/tm_crnn -m model/crnn_lite_dense.tmfile -i model/o2_resize.jpg -l model/keys.txt
```
result:
```bash
start to run register cpu allocator
tengine-lite library version: 1.0-dev
Repeat 1 times, thread 1, avg time 43.32 ms, max_time 43.32 ms, min_time 43.32 ms
--------------------------------------
如何突破自己的颜值上限
--------------------------------------
```
The result of ocr recognition is displayed in terminal, you may also modify the source code to save it to file.
We will continously updating more fancy demos, please stay tuned...
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册