From 41c64e4729ca359f7212534055239c8289b5e2f4 Mon Sep 17 00:00:00 2001
From: hnluo <haoneng.lhn@alibaba-inc.com>
Date: 星期四, 21 九月 2023 16:15:15 +0800
Subject: [PATCH] Merge pull request #975 from alibaba-damo-academy/main

---
 funasr/utils/runtime_sdk_download_tool.py |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/funasr/utils/runtime_sdk_download_tool.py b/funasr/utils/runtime_sdk_download_tool.py
index f8d4bc9..9a0d40f 100644
--- a/funasr/utils/runtime_sdk_download_tool.py
+++ b/funasr/utils/runtime_sdk_download_tool.py
@@ -6,6 +6,7 @@
 parser = argparse.ArgumentParser()
 parser.add_argument('--model-name', type=str, required=True)
 parser.add_argument('--export-dir', type=str, required=True)
+parser.add_argument('--export', type=str2bool, default=True, help='whether to export model')
 parser.add_argument('--type', type=str, default='onnx', help='["onnx", "torch"]')
 parser.add_argument('--device', type=str, default='cpu', help='["cpu", "cuda"]')
 parser.add_argument('--quantize', type=str2bool, default=False, help='export quantized model')
@@ -23,17 +24,17 @@
 	except:
 		raise "model_dir must be model_name in modelscope or local path downloaded from modelscope, but is {}".format \
 			(model_dir)
-
-model_file = os.path.join(model_dir, 'model.onnx')
-if args.quantize:
-	model_file = os.path.join(model_dir, 'model_quant.onnx')
-if not os.path.exists(model_file):
-	print(".onnx is not exist, begin to export onnx")
-	from funasr.export.export_model import ModelExport
-	export_model = ModelExport(
-		cache_dir=args.export_dir,
-		onnx=True,
-		device="cpu",
-		quant=args.quantize,
-	)
-	export_model.export(model_dir)
\ No newline at end of file
+if args.export:
+	model_file = os.path.join(model_dir, 'model.onnx')
+	if args.quantize:
+		model_file = os.path.join(model_dir, 'model_quant.onnx')
+	if not os.path.exists(model_file):
+		print(".onnx is not exist, begin to export onnx")
+		from funasr.export.export_model import ModelExport
+		export_model = ModelExport(
+			cache_dir=args.export_dir,
+			onnx=True,
+			device="cpu",
+			quant=args.quantize,
+		)
+		export_model.export(model_dir)
\ No newline at end of file

--
Gitblit v1.9.1