From 30c8b6d5a67869462d52738369eb886e38c0ca63 Mon Sep 17 00:00:00 2001 From: Alexander Pivovarov Date: Tue, 9 Oct 2018 22:18:09 -0700 Subject: [PATCH] Use modern onnx API to load model from file --- docs/tutorials/onnx/export_mxnet_to_onnx.md | 2 +- python/mxnet/contrib/onnx/onnx2mx/import_model.py | 4 ++-- python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/onnx/export_mxnet_to_onnx.md b/docs/tutorials/onnx/export_mxnet_to_onnx.md index dc34bd520b43..b838bae94311 100644 --- a/docs/tutorials/onnx/export_mxnet_to_onnx.md +++ b/docs/tutorials/onnx/export_mxnet_to_onnx.md @@ -121,7 +121,7 @@ from onnx import checker import onnx # Load onnx model -model_proto = onnx.load(converted_model_path) +model_proto = onnx.load_model(converted_model_path) # Check if converted ONNX protobuf is valid checker.check_graph(model_proto.graph) diff --git a/python/mxnet/contrib/onnx/onnx2mx/import_model.py b/python/mxnet/contrib/onnx/onnx2mx/import_model.py index b8d3bf28ee2f..bf3601a6953d 100644 --- a/python/mxnet/contrib/onnx/onnx2mx/import_model.py +++ b/python/mxnet/contrib/onnx/onnx2mx/import_model.py @@ -50,7 +50,7 @@ def import_model(model_file): raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to install - https://github.com/onnx/onnx") # loads model file and returns ONNX protobuf object - model_proto = onnx.load(model_file) + model_proto = onnx.load_model(model_file) sym, arg_params, aux_params = graph.from_onnx(model_proto.graph) return sym, arg_params, aux_params @@ -81,6 +81,6 @@ def get_model_metadata(model_file): except ImportError: raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to install - https://github.com/onnx/onnx") - model_proto = onnx.load(model_file) + model_proto = onnx.load_model(model_file) metadata = graph.get_graph_metadata(model_proto.graph) return metadata diff --git a/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py b/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py index 5df41c3f327d..8e1b35441f07 100644 --- a/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py +++ b/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py @@ -43,6 +43,6 @@ def import_to_gluon(model_file, ctx): except ImportError: raise ImportError("Onnx and protobuf need to be installed. Instructions to" + " install - https://github.com/onnx/onnx#installation") - model_proto = onnx.load(model_file) + model_proto = onnx.load_model(model_file) net = graph.graph_to_gluon(model_proto.graph, ctx) return net