|
|
|
@ -1,15 +1,21 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import argparse
|
|
|
|
|
import onnx
|
|
|
|
|
from onnx import version_converter, helper
|
|
|
|
|
|
|
|
|
|
import onnx
|
|
|
|
|
from onnx import version_converter
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
parser = argparse.ArgumentParser(prog=__doc__)
|
|
|
|
|
parser.add_argument("--model-file", type=str, required=True, help='path/to/the/model.onnx.')
|
|
|
|
|
parser.add_argument("--save-model", type=str, required=True, help='path/to/saved/model.onnx.')
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--model-file", type=str, required=True, help='path/to/the/model.onnx.')
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--save-model",
|
|
|
|
|
type=str,
|
|
|
|
|
required=True,
|
|
|
|
|
help='path/to/saved/model.onnx.')
|
|
|
|
|
# Models must be opset10 or higher to be quantized.
|
|
|
|
|
parser.add_argument("--target-opset", type=int, default=11, help='path/to/the/model.onnx.')
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--target-opset", type=int, default=11, help='path/to/the/model.onnx.')
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
@ -24,7 +30,8 @@ if __name__ == '__main__':
|
|
|
|
|
# A full list of supported adapters can be found here:
|
|
|
|
|
# https://github.com/onnx/onnx/blob/main/onnx/version_converter.py#L21
|
|
|
|
|
# Apply the version conversion on the original model
|
|
|
|
|
converted_model = version_converter.convert_version(original_model, args.target_opset)
|
|
|
|
|
converted_model = version_converter.convert_version(original_model,
|
|
|
|
|
args.target_opset)
|
|
|
|
|
|
|
|
|
|
# print('The model after conversion:\n{}'.format(converted_model))
|
|
|
|
|
onnx.save(converted_model, args.save_model)
|
|
|
|
|