From 7cad4933f0d0882be3fca4e6b15853ad66788b31 Mon Sep 17 00:00:00 2001 From: syq163 Date: Thu, 7 Dec 2023 16:00:09 +0800 Subject: [PATCH] fix: depedency of transformers==4.26.1, and you are able to use newer version --- README.md | 2 +- README.zh.md | 2 +- data/youdao/text/tokenlist | 8 ++++---- demo_page.py | 2 +- inference_am_vocoder_joint.py | 2 +- models/hifigan/models.py | 3 ++- models/prompt_tts_modified/jets.py | 16 ++++++++-------- openaiapi.py | 2 +- predict.py | 2 +- requirements.txt | 2 +- 10 files changed, 21 insertions(+), 20 deletions(-) mode change 100644 => 100755 models/hifigan/models.py diff --git a/README.md b/README.md index 7238b2c..2ac905d 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Now open your browser and navigate to http://localhost:8501 to start using Emoti conda create -n EmotiVoice python=3.8 -y conda activate EmotiVoice pip install torch torchaudio -pip install numpy numba scipy transformers==4.26.1 soundfile yacs g2p_en jieba pypinyin +pip install numpy numba scipy transformers soundfile yacs g2p_en jieba pypinyin ``` ### Prepare model files diff --git a/README.zh.md b/README.zh.md index 887f12b..7e40436 100644 --- a/README.zh.md +++ b/README.zh.md @@ -59,7 +59,7 @@ docker run -dp 127.0.0.1:8501:8501 syq163/emoti-voice:latest conda create -n EmotiVoice python=3.8 -y conda activate EmotiVoice pip install torch torchaudio -pip install numpy numba scipy transformers==4.26.1 soundfile yacs g2p_en jieba pypinyin +pip install numpy numba scipy transformers soundfile yacs g2p_en jieba pypinyin ``` ### 准备模型文件 diff --git a/data/youdao/text/tokenlist b/data/youdao/text/tokenlist index de9a920..bcd36e2 100644 --- a/data/youdao/text/tokenlist +++ b/data/youdao/text/tokenlist @@ -411,10 +411,10 @@ err1 rr ier2 or1 -uncased11 -uncased12 -uncased13 -uncased14 +ueng2 +ir5 +iar1 +iour1 uncased15 uncased16 uncased17 diff --git a/demo_page.py b/demo_page.py index e2cc2e9..6ee4ba9 100644 --- a/demo_page.py +++ b/demo_page.py @@ -84,7 +84,7 @@ def get_models(): for key, value in model_CKPT['model'].items(): new_key = key[7:] model_ckpt[new_key] = value - style_encoder.load_state_dict(model_ckpt) + style_encoder.load_state_dict(model_ckpt, strict=False) generator = JETSGenerator(conf).to(DEVICE) model_CKPT = torch.load(am_checkpoint_path, map_location=DEVICE) diff --git a/inference_am_vocoder_joint.py b/inference_am_vocoder_joint.py index a2d9e33..3b1d54a 100644 --- a/inference_am_vocoder_joint.py +++ b/inference_am_vocoder_joint.py @@ -63,7 +63,7 @@ def main(args, config): for key, value in model_CKPT['model'].items(): new_key = key[7:] model_ckpt[new_key] = value - style_encoder.load_state_dict(model_ckpt) + style_encoder.load_state_dict(model_ckpt, strict=False) diff --git a/models/hifigan/models.py b/models/hifigan/models.py old mode 100644 new mode 100755 index d70c632..fb6a47c --- a/models/hifigan/models.py +++ b/models/hifigan/models.py @@ -7,7 +7,8 @@ import torch.nn.functional as F import torch.nn as nn from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d -from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm +from torch.nn.utils.parametrizations import weight_norm +from torch.nn.utils import remove_weight_norm, spectral_norm LRELU_SLOPE = 0.1 diff --git a/models/prompt_tts_modified/jets.py b/models/prompt_tts_modified/jets.py index 060b85f..135074a 100644 --- a/models/prompt_tts_modified/jets.py +++ b/models/prompt_tts_modified/jets.py @@ -36,14 +36,14 @@ def __init__(self, config) -> None: self.generator = HiFiGANGenerator(config.model) - try: - model_CKPT = torch.load(config.pretrained_am, map_location="cpu") - self.am.load_state_dict(model_CKPT['model']) - state_dict_g = torch.load(config.pretrained_vocoder,map_location="cpu") - self.generator.load_state_dict(state_dict_g['generator']) - print("pretrained generator is loaded") - except: - print("pretrained generator is not loaded for training") + # try: + # model_CKPT = torch.load(config.pretrained_am, map_location="cpu") + # self.am.load_state_dict(model_CKPT['model']) + # state_dict_g = torch.load(config.pretrained_vocoder,map_location="cpu") + # self.generator.load_state_dict(state_dict_g['generator']) + # print("pretrained generator is loaded") + # except: + # print("pretrained generator is not loaded for training") self.config=config diff --git a/openaiapi.py b/openaiapi.py index a8cfaf5..c218fb1 100644 --- a/openaiapi.py +++ b/openaiapi.py @@ -73,7 +73,7 @@ def get_models(): for key, value in model_CKPT['model'].items(): new_key = key[7:] model_ckpt[new_key] = value - style_encoder.load_state_dict(model_ckpt) + style_encoder.load_state_dict(model_ckpt, strict=False) generator = JETSGenerator(conf).to(DEVICE) model_CKPT = torch.load(am_checkpoint_path, map_location=DEVICE) diff --git a/predict.py b/predict.py index f67d883..33bbbb5 100644 --- a/predict.py +++ b/predict.py @@ -116,7 +116,7 @@ def setup_models(self): for key, value in model_CKPT['model'].items(): new_key = key[7:] model_ckpt[new_key] = value - style_encoder.load_state_dict(model_ckpt) + style_encoder.load_state_dict(model_ckpt, strict=False) generator = JETSGenerator(conf).to(self.device) model_CKPT = torch.load(am_checkpoint_path, map_location=self.device) diff --git a/requirements.txt b/requirements.txt index 1913812..e80692b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ torchaudio numpy numba scipy -transformers==4.26.1 +transformers soundfile yacs g2p_en