提交 200a1fbe 编写于 作者: B BBuf

convert

上级 7a6c8760
......@@ -14,8 +14,8 @@ OneFlow 相关的模型转换工具
#### 简介
- OneFlow2ONNX 模型支持,支持 OneFlow 动态图模型转为 ONNX,详情可以参考 [OneFlow2ONNX 模型列表](docs/oneflow2onnx/oneflow2onnx_model_zoo.md)
- OneFlow2ONNX 算子支持,支持 CV 中大部分常见算子,详情可以参考 [OneFlow2ONNX 算子列表](docs/oneflow2onnx/op_list.md)
- OneFlow2ONNX 模型支持,支持 OneFlow 静态图模型转为 ONNX,可转换由 [flow.checkpoint.save ](https://docs.oneflow.org/basics_topics/model_load_save.html) 方法保存下来的 OneFlow 模型,详情可以参考 [OneFlow2ONNX 模型列表](docs/oneflow2onnx/oneflow2onnx_model_zoo.md)
- OneFlow2ONNX 算子支持,目前稳定支持导出 ONNX Opset10,部分 OneFlow 算子支持更低的 ONNX Opset 转换,详情可以参考 [OneFlow2ONNX 算子列表](docs/oneflow2onnx/op_list.md)
#### 环境依赖
......@@ -25,6 +25,8 @@ OneFlow 相关的模型转换工具
```sh
python>=3.5
onnx>=1.8.0
onnx-simplifier>=0.3.3
onnxoptimizer>=0.2.5
onnxruntime>=1.6.0
oneflow>=0.5.0
```
......
......@@ -10,8 +10,8 @@
#### Introduction
- OneFlow2ONNX models are supported. Specifically, OneFlow's eager mode model can be transfomed into ONNX's format. For more information, please refer to [OneFlow2ONNX Model List](docs/oneflow2onnx/oneflow2onnx_model_zoo.md).
- OneFlow2ONNX operators are supported. Please refer to [OneFlow2ONNX Operator Lists](docs/oneflow2onnx/op_list.md) for more information.
- OneFlow2ONNX models are supported. Specifically, OneFlow's lazy mode model can be transfomed into ONNX's format. Transformable OneFlow model can be obtained by using the method explained on [flow.checkpoint.save ](https://docs.oneflow.org/basics_topics/model_load_save.html). For more information, please refer to [OneFlow2ONNX Model List](docs/oneflow2onnx/oneflow2onnx_model_zoo.md).
- OneFlow2ONNX operators are supported. Currently, oneflow_onnx is fully capable of exporting ONNX Opset10, and parts of OneFlow operator can transform ONNX Opsets that are in lower order. Please refer to [OneFlow2ONNX Operator Lists](docs/oneflow2onnx/op_list.md) for more information.
#### Environment Dependencies
......@@ -21,6 +21,8 @@
```sh
python>=3.5
onnx>=1.8.0
onnx-simplifier>=0.3.3
onnxoptimizer>=0.2.5
onnxruntime>=1.6.0
oneflow (https://github.com/Oneflow-Inc/oneflow#install-with-pip-package)
```
......
......@@ -74,6 +74,6 @@ def test_alexnet():
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(alexnet.state_dict(), tmpdirname)
convert_to_onnx_and_check(alexnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(alexnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_alexnet()
......@@ -468,8 +468,8 @@ def test_inceptionv3():
inceptionv3_graph = inceptionv3Graph()
inceptionv3_graph._compile(flow.randn(1, 3, 299, 299).to("cuda"))
# with tempfile.TemporaryDirectory() as tmpdirname:
# flow.save(inceptionv3.state_dict(), tmpdirname)
# convert_to_onnx_and_check(inceptionv3_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(inceptionv3.state_dict(), tmpdirname)
convert_to_onnx_and_check(inceptionv3_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_inceptionv3()
......@@ -62,6 +62,6 @@ def test_lenet():
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(lenet.state_dict(), tmpdirname)
convert_to_onnx_and_check(lenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(lenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_lenet()
......@@ -272,6 +272,6 @@ def test_mobilenetv2():
# print(mobilenetv2_graph._full_graph_proto)
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(mobilenetv2.state_dict(), tmpdirname)
convert_to_onnx_and_check(mobilenetv2_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(mobilenetv2_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_mobilenetv2()
......@@ -391,6 +391,6 @@ def test_repvgg():
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(repvgg.state_dict(), tmpdirname)
convert_to_onnx_and_check(repvgg_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(repvgg_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_repvgg()
......@@ -312,6 +312,6 @@ def test_resnet():
print(resnet_graph._full_graph_proto)
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(resnet.state_dict(), tmpdirname)
convert_to_onnx_and_check(resnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(resnet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=False)
test_resnet()
......@@ -215,6 +215,6 @@ def test_shufflenet():
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(shufflenet.state_dict(), tmpdirname)
convert_to_onnx_and_check(shufflenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(shufflenet_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_shufflenet()
......@@ -190,6 +190,6 @@ def test_vgg16():
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(vgg16.state_dict(), tmpdirname)
convert_to_onnx_and_check(vgg16_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp", print_outlier=True)
convert_to_onnx_and_check(vgg16_graph, flow_weight_dir=tmpdirname, onnx_model_path="/tmp")
test_vgg16()
......@@ -24,7 +24,11 @@ long_description += "Email: zhangxiaoyu@oneflow.org"
setuptools.setup(
name="oneflow_onnx",
<<<<<<< HEAD
version="0.5.1",
=======
version="0.5.0.rc",
>>>>>>> parent of cca89ba... release v0.5.0 (#42)
author="zhangxiaoyu",
author_email="zhangxiaoyu@oneflow.org",
description="a toolkit for converting trained model of OneFlow to ONNX and ONNX to OneFlow.",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册