提交 92408c16 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!771 Update Convertor tools docs in windows enviroment

Merge pull request !771 from liuwenhao/master
...@@ -143,7 +143,9 @@ tar -xvf mindspore-lite-0.7.0-runtime-x86-cpu.tar.gz ...@@ -143,7 +143,9 @@ tar -xvf mindspore-lite-0.7.0-runtime-x86-cpu.tar.gz
- 编译依赖(基本项) - 编译依赖(基本项)
- [CMake](https://cmake.org/download/) >= 3.14.1 - [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) >= 7.3.0 - [MinGW GCC](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z/download) >= 7.3.0
- [Python](https://www.python.org/) >= 3.7.5
- [Git](https://git-scm.com/downloads) >= 2.28.0
### 编译选项 ### 编译选项
......
...@@ -4,10 +4,16 @@ ...@@ -4,10 +4,16 @@
- [模型转换工具](#模型转换工具) - [模型转换工具](#模型转换工具)
- [概述](#概述) - [概述](#概述)
- [环境准备](#环境准备) - [Linux环境使用说明](#linux环境使用说明)
- [参数说明](#参数说明) - [环境准备](#环境准备)
- [模型可视化](#模型可视化) - [参数说明](#参数说明)
- [使用示例](#使用示例) - [模型可视化](#模型可视化)
- [使用示例](#使用示例)
- [Windows环境使用说明](#windows环境使用说明)
- [环境准备](#环境准备-1)
- [参数说明](#参数说明-1)
- [模型可视化](#模型可视化-1)
- [使用示例](#使用示例-1)
<!-- /TOC --> <!-- /TOC -->
...@@ -19,7 +25,9 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 ...@@ -19,7 +25,9 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模
目前支持的输入格式有:MindSpore、TensorFlow Lite、Caffe和ONNX。 目前支持的输入格式有:MindSpore、TensorFlow Lite、Caffe和ONNX。
## 环境准备 ## Linux环境使用说明
### 环境准备
使用MindSpore Lite模型转换工具,需要进行如下环境准备工作。 使用MindSpore Lite模型转换工具,需要进行如下环境准备工作。
...@@ -27,7 +35,7 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 ...@@ -27,7 +35,7 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模
- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id4),获得`converter`工具,并配置环境变量。 - 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id4),获得`converter`工具,并配置环境变量。
## 参数说明 ### 参数说明
使用`./converter_lite <args>`即可完成转换,同时提供了多种参数设置,用户可根据需要来选择使用。 使用`./converter_lite <args>`即可完成转换,同时提供了多种参数设置,用户可根据需要来选择使用。
此外,用户可输入`./converter_lite --help`获取实时帮助。 此外,用户可输入`./converter_lite --help`获取实时帮助。
...@@ -46,13 +54,13 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 ...@@ -46,13 +54,13 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模
> - 参数名和参数值之间用等号连接,中间不能有空格。 > - 参数名和参数值之间用等号连接,中间不能有空格。
> - Caffe模型一般分为两个文件:`*.prototxt`模型结构,对应`--modelFile`参数;`*.caffemodel`模型权值,对应`--weightFile`参数。 > - Caffe模型一般分为两个文件:`*.prototxt`模型结构,对应`--modelFile`参数;`*.caffemodel`模型权值,对应`--weightFile`参数。
## 模型可视化 ### 模型可视化
模型可视化工具提供了一种查验模型转换结果的方法。用户可使用Json命令生成`*.json`文件,与原模型相对比,确定转化效果。 模型可视化工具提供了一种查验模型转换结果的方法。用户可使用Json命令生成`*.json`文件,与原模型相对比,确定转化效果。
TODO: 此功能还在开发中。 TODO: 此功能还在开发中。
## 使用示例 ### 使用示例
首先,在源码根目录下,输入命令进行编译,可参考`deploy.md` 首先,在源码根目录下,输入命令进行编译,可参考`deploy.md`
```bash ```bash
...@@ -104,3 +112,78 @@ bash build.sh -I x86_64 ...@@ -104,3 +112,78 @@ bash build.sh -I x86_64
``` ```
你可以选择使用模型打印工具,可视化查验上述转化后生成的MindSpore Lite模型。本部分功能开发中。 你可以选择使用模型打印工具,可视化查验上述转化后生成的MindSpore Lite模型。本部分功能开发中。
## Windows环境使用说明
### 环境准备
使用MindSpore Lite模型转换工具,需要进行如下环境准备工作。
- 编译:模型转换工具代码在MindSpore源码的`mindspore/lite/tools/converter`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id7)[编译示例](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id10),安装编译依赖基本项与模型转换工具所需附加项,并编译Windows版本。
- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id9),获得`converter`工具,并将MinGW/bin目录下的几个依赖文件(libgcc_s_seh-1.dll、libwinpthread-1.dll、libssp-0.dll、libstdc++-6.dll)拷贝至`converter`工具的主目录。
### 参数说明
参考Linux环境模型转换工具的[参数说明](https://www.mindspore.cn/lite/docs/zh-CN/master/converter_tool.html#id4)
### 模型可视化
参考Linux环境模型转换工具的[模型可视化](https://www.mindspore.cn/lite/docs/zh-CN/master/converter_tool.html#id5)
### 使用示例
首先,使用cmd工具在源码根目录下,输入命令进行编译,可参考`deploy.md`
```bash
call build.bat lite
```
然后,设置日志打印级别为INFO。
```bash
set MSLOG=INFO
```
下面选取了几个常用示例,说明转换命令的使用方法。
- 以Caffe模型LeNet为例,执行转换命令。
```bash
call converter_lite --fmk=CAFFE --modelFile=lenet.prototxt --weightFile=lenet.caffemodel --outputFile=lenet
```
本例中,因为采用了Caffe模型,所以需要模型结构、模型权值两个输入文件。再加上其他必需的fmk类型和输出路径两个参数,即可成功执行。
结果显示为:
```
INFO [converter/converter.cc:190] Runconverter] CONVERTER RESULT: SUCCESS!
```
这表示已经成功将Caffe模型转化为MindSpore Lite模型,获得新文件`lenet.ms`
- 以MindSpore、TensorFlow Lite、ONNX模型格式和感知量化模型为例,执行转换命令。
- MindSpore模型`model.mindir`
```bash
call converter_lite --fmk=MS --modelFile=model.mindir --outputFile=model
```
- TensorFlow Lite模型`model.tflite`
```bash
call converter_lite --fmk=TFLITE --modelFile=model.tflite --outputFile=model
```
- ONNX模型`model.onnx`
```bash
call converter_lite --fmk=ONNX --modelFile=model.onnx --outputFile=model
```
- TensorFlow Lite感知量化模型`model_quant.tflite`
```bash
call converter_lite --fmk=TFLITE --modelFile=model_quant.tflite --outputFile=model --quantType=AwareTraining
```
以上几种情况下,均显示如下转换成功提示,且同时获得`model.ms`目标文件。
```
INFO [converter/converter.cc:190] Runconverter] CONVERTER RESULT: SUCCESS!
```
你可以选择使用模型打印工具,可视化查验上述转化后生成的MindSpore Lite模型。本部分功能开发中。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册