Update README.md

This commit is contained in:
gwg_xujiao 2024-10-24 19:11:13 +08:00
parent 953ce99955
commit 2e8c07d23f
1 changed files with 83 additions and 84 deletions

View File

@ -36,7 +36,7 @@ netrans 支持的 输入模型、量化数据和输出数据类型、算子 如
| ONNX|支持 ONNX 至 1.14.0 opset支持至19 |
| Pytorch | 支持 Pytorch 至 1.5.1 |
| Keras |支持以TensorFLow 2.0.x, 2.3.x, 2.6.x, 2.8.x, 2.10.x, 2.12.x 作为后端导出的keras模型|
| Darknet |支持[官网](https://pjreddie.com/darknet/)列出 darknet 模型|
| Darknet |支持Darknet官网列出 darknet 模型|
|数据支持|描述|
|:---|---|
@ -243,38 +243,38 @@ netrans_cli 脚本介绍
### 3.2 生成Inputmeta文件
在netrans_cli目录下使用inputmeta_gen.sh脚本生成inputmeta文件
- 用法: ./inputmeta_gen.sh 以模型文件名命名的模型数据文件夹,例如:
```shell
$ ./inputmeta_gen.sh lenet
... ...
I Namespace(generate='inputmeta', input_meta_output=None, model='lenet.json', separated_database=True, which='generate')
I Load model in lenet.json
I Generate input meta lenet_inputmeta.yml
I ----------------Error(0),Warning(0)----------------
```shell
$ ./inputmeta_gen.sh lenet
... ...
I Namespace(generate='inputmeta', input_meta_output=None, model='lenet.json', separated_database=True, which='generate')
I Load model in lenet.json
I Generate input meta lenet_inputmeta.yml
I ----------------Error(0),Warning(0)----------------
$ ls -lrt lenet
total 3400
-rwxr-xr-x 1 hope hope 1727201 Nov 5 2018 lenet.pb
-rw-r--r-- 1 hope hope 553 Nov 5 2018 0.jpg
-rwxr--r-- 1 hope hope 6 Apr 21 17:04 dataset.txt
-rw-rw-r-- 1 hope hope 69 Jun 7 09:19 inputs_outputs.txt
-rw-r--r-- 1 hope hope 5553 Jun 7 09:21 lenet.json
-rw-r--r-- 1 hope hope 1725178 Jun 7 09:21 lenet.data
-rw-r--r-- 1 hope hope 948 Jun 7 09:35 lenet_inputmeta.yml
```
$ ls -lrt lenet
total 3400
-rwxr-xr-x 1 hope hope 1727201 Nov 5 2018 lenet.pb
-rw-r--r-- 1 hope hope 553 Nov 5 2018 0.jpg
-rwxr--r-- 1 hope hope 6 Apr 21 17:04 dataset.txt
-rw-rw-r-- 1 hope hope 69 Jun 7 09:19 inputs_outputs.txt
-rw-r--r-- 1 hope hope 5553 Jun 7 09:21 lenet.json
-rw-r--r-- 1 hope hope 1725178 Jun 7 09:21 lenet.data
-rw-r--r-- 1 hope hope 948 Jun 7 09:35 lenet_inputmeta.yml
```
可以看到,最终生成的是*.yml文件该文件用于为Netrans中间模型配置输入层数据集合。<b>Netrans中的量化、推理、导出和图片转dat的操作都需要用到这个文件。因此此步骤不可跳过。</b>
Inputmeta.yml文件结构如下
```yaml
%YAML 1.2
---
# !!!This file disallow TABs!!!
# "category" allowed values: "image, undefined"
# "database" allowed types: "H5FS, SQLITE, TEXT, LMDB, NPY, GENERATOR"
# "tensor_name" only support in H5FS database
# "preproc_type" allowed types:"IMAGE_RGB, IMAGE_RGB888_PLANAR, IMAGE_RGB888_PLANAR_SEP,
IMAGE_I420,
# IMAGE_NV12, IMAGE_YUV444, IMAGE_GRAY, IMAGE_BGRA, TENSOR"
input_meta:
```yaml
%YAML 1.2
---
# !!!This file disallow TABs!!!
# "category" allowed values: "image, undefined"
# "database" allowed types: "H5FS, SQLITE, TEXT, LMDB, NPY, GENERATOR"
# "tensor_name" only support in H5FS database
# "preproc_type" allowed types:"IMAGE_RGB, IMAGE_RGB888_PLANAR, IMAGE_RGB888_PLANAR_SEP,
IMAGE_I420,
# IMAGE_NV12, IMAGE_YUV444, IMAGE_GRAY, IMAGE_BGRA, TENSOR"
input_meta:
databases:
- path: dataset.txt
type: TEXT
@ -313,8 +313,7 @@ input_meta:
shape:
- 1
- 1
```
```
上面示例文件的各个参数解释:
@ -349,18 +348,18 @@ input_meta:
如果我们训练好的模型的数据类型是float32的为了使模型以更高的效率在pnna上运行我们可以对模型进行量化操作量化操作可能会带来一定程度的精度损失。<
在netrans_cli目录下使用quantize.sh脚本进行量化操作。
用法:./quantize.sh 以模型文件名命名的模型数据文件夹 量化类型,例如:
- 用法:./quantize.sh 以模型文件名命名的模型数据文件夹 量化类型,例如:
```shell
$ ./quantize.sh lenet uint8
... ...
I End quantization...
I Dump net quantize tensor table to lenet_asymmetric_affine.quantize
I Save net to lenet.data
I ----------------Error(0),Warning(0)----------------
SUCCESS
```shell
$ ./quantize.sh lenet uint8
... ...
I End quantization...
I Dump net quantize tensor table to lenet_asymmetric_affine.quantize
I Save net to lenet.data
I ----------------Error(0),Warning(0)----------------
SUCCESS
```
```
支持的量化类型有uint8、int8、int16
@ -397,7 +396,7 @@ SUCCESS
在netrans_cli目录下使用export.sh脚本进行推理。
用法:./export.sh 以模型文件名命名的模型数据文件夹 数据类型,例如:
- 用法:./export.sh 以模型文件名命名的模型数据文件夹 数据类型,例如:
```shell
./export.sh lenet uint8
@ -412,10 +411,10 @@ I ----------------Error(0),Warning(0)----------------
导出支持的数据类型float、uint8、int8、int16其中使用uint8、int8、int16导出时需要先进行[模型量化](#33-模型量化)。导出的工程会在模型所在的目录下面的wksp目录里。
network_binary.nb文件在"asymmetric_affine"文件夹中:
```shell
ls -lrt lenet/wksp/asymmetric_affine/
-rw-r--r-- 1 hope hope 694912 Jun 7 09:55 network_binary.nb
```
```shell
ls -lrt lenet/wksp/asymmetric_affine/
-rw-r--r-- 1 hope hope 694912 Jun 7 09:55 network_binary.nb
```
目前支持将生成的network_binary.nb文件部署到pnna硬件平台。具体部署方法请参阅模型部署相关文档。