[Python API] Fix import/export of model + update speech sample (#10103)

* Fix import/export of model

* update speech sample

* fix code-style

Co-authored-by: jiwaszki <jan.iwaszkiewicz@intel.com>
This commit is contained in:
Anastasia Kuporosova
2022-02-07 12:12:06 +03:00
committed by GitHub
parent 38f470c184
commit 3c13cea02b
4 changed files with 206 additions and 20 deletions

View File

@@ -5,6 +5,7 @@
import re
import sys
from io import BytesIO
from timeit import default_timer
from typing import Dict
@@ -148,12 +149,16 @@ def main():
if args.model:
compiled_model = core.compile_model(model, device_str, plugin_config)
else:
compiled_model = core.import_model(args.import_gna_model, device_str, plugin_config)
with open(args.import_gna_model, 'rb') as f:
buf = BytesIO(f.read())
compiled_model = core.import_model(buf, device_str, plugin_config)
# --------------------------- Exporting GNA model using InferenceEngine AOT API ---------------------------------------
if args.export_gna_model:
log.info(f'Writing GNA Model to {args.export_gna_model}')
compiled_model.export_model(args.export_gna_model)
user_stream = compiled_model.export_model()
with open(args.export_gna_model, 'wb') as f:
f.write(user_stream)
return 0
if args.export_embedded_gna_model: