From 8b3b73c2ed09229cd6e41fa6897c8789923331fe Mon Sep 17 00:00:00 2001 From: Hawk Lee Date: Thu, 19 Feb 2026 12:39:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20QwenEmotion=20device=5Fmap=3Dauto=20?= =?UTF-8?q?=E4=B8=8E=20modelscope=20=E4=B8=8D=E5=85=BC=E5=AE=B9=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20IndexError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 device_map='auto',改为手动 .to(device) - 与 IndexTTS2 中其他模型(GPT/BigVGAN/CamPPlus)加载方式一致 - 修复 use_cuda_kernel=False 时的加载失败 --- libs/index-tts/indextts/infer_v2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/index-tts/indextts/infer_v2.py b/libs/index-tts/indextts/infer_v2.py index 43efc8e..77caab0 100644 --- a/libs/index-tts/indextts/infer_v2.py +++ b/libs/index-tts/indextts/infer_v2.py @@ -80,7 +80,7 @@ class IndexTTS2: self.use_accel = use_accel self.use_torch_compile = use_torch_compile - self.qwen_emo = QwenEmotion(os.path.join(self.model_dir, self.cfg.qwen_emo_path)) + self.qwen_emo = QwenEmotion(os.path.join(self.model_dir, self.cfg.qwen_emo_path), device=self.device) self.gpt = UnifiedVoice(**self.cfg.gpt, use_accel=self.use_accel) self.gpt_path = os.path.join(self.model_dir, self.cfg.gpt_checkpoint) @@ -717,14 +717,14 @@ def find_most_similar_cosine(query_vector, matrix): return most_similar_index class QwenEmotion: - def __init__(self, model_dir): + def __init__(self, model_dir, device="cuda:0"): self.model_dir = model_dir + self.device = device self.tokenizer = AutoTokenizer.from_pretrained(self.model_dir) self.model = AutoModelForCausalLM.from_pretrained( self.model_dir, - torch_dtype="float16", # "auto" - device_map="auto" - ) + torch_dtype="float16", + ).to(self.device) self.prompt = "文本情感分类" self.cn_key_to_en = { "高兴": "happy",