From a7d7a0f3a2e7cd44a337ced34e3536b12ccb534e Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 11 三月 2024 19:24:44 +0800
Subject: [PATCH] Dev gzf (#1467)

---
 funasr/auto/auto_model.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/funasr/auto/auto_model.py b/funasr/auto/auto_model.py
index c4bab03..28b9e94 100644
--- a/funasr/auto/auto_model.py
+++ b/funasr/auto/auto_model.py
@@ -156,7 +156,7 @@
             kwargs["batch_size"] = 1
         kwargs["device"] = device
         
-        if kwargs.get("ncpu", None):
+        if kwargs.get("ncpu", 4):
             torch.set_num_threads(kwargs.get("ncpu"))
         
         # build tokenizer
@@ -476,11 +476,13 @@
                calib_num: int = 100,
                opset_version: int = 14,
                **cfg):
-        os.environ['EXPORTING_MODEL'] = 'TRUE'
+    
+        device = cfg.get("device", "cpu")
+        model = self.model.to(device=device)
         kwargs = self.kwargs
         deep_update(kwargs, cfg)
+        kwargs["device"] = device
         del kwargs["model"]
-        model = self.model
         model.eval()
 
         batch_size = 1

--
Gitblit v1.9.1