Files
ascend-tools/imgtobin/Readme.md
T
fuyangchenghu c1f7c3911f commit tools
2020-06-21 18:42:05 -07:00

40 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# imgtobin
imgtobin能够生成模型推理所需的输入数据,以.bin格式保存。
有两类数据,一类是图片数据,另一类是模型需要的第二个输入数据,如fasterrcnn的第二个输入是图片的shape信息。
## 使用方法
-i后跟**目录**表示转换图片,-i后跟**文件路径**表示转换第二类数据。
### 第一类图片:
- 脚本会将 -i 后指定的图片目录下的所有图片按参数设置做相应的预处理,并以"文件名.bin"命名保存在-o指定的输出目录下。
```
python3 imgtobin.py -i ./images -w 416 -h 416 -f BGR -a NCHW -m [104,117,123] -c [1,1,1] -o ./out
```
### 第二类:
- 第二类数据,需要新建一个文件,文件模板为test.txtinput_node为数据,shape为数据的shape信息。
- 第二类数据只需 -i、-t、-o三个参数。
- 参数 -i 需要指定文件的路径,-t 需要指定数据类型,-o指定输出目录。
```
python3 imgtobin.py -i ./test.txt -t uint8 -o ./out
```
## 参数说明
| 参数名 | 说明 |
| - | - |
| -i | 图片的输入目录或第二个输入的文件路径 |
| -w | 输出图片宽 |
| -h | 输出图片高 |
| -f | 输出图片色彩格式,支持(BGR/RGB/YUV/GRAY |
| -a | 输出图片格式,支持(NCHW/NHWC) |
| -t | 图片或第二个数据的输出数据类型,支持(float32/uint8/int32/uint32 |
| -m | 减均值,默认为[0,0,0],顺序与图片色彩格式保持一致 <br>当色彩格式为yuv时,设置[0,0] <br>当色彩格式为gray时,设置[0] |
| -c | 归一化,默认为 [1,1,1],顺序与图片色彩格式保持一致 <br>当色彩格式为yuv时,设置[1,1] <br>当色彩格式为gray时,设置[1] |
| -o | 输出目录 |