Refactor: No preloading of BERT models to avoid unnecessary GPU VRAM consumption during training in the Web UI

Since the BERT features of the dataset are pre-extracted by bert_gen.py, there is no need to load the BERT model at training time.
This commit is contained in:
tsukumi
2024-03-12 18:22:34 +00:00
committed by litagin02
parent 8baecb138a
commit 9e5222619f
2 changed files with 12 additions and 9 deletions

View File

@@ -29,6 +29,7 @@ from style_bert_vits2.models.models import SynthesizerTrn
from style_bert_vits2.models.models_jp_extra import (
SynthesizerTrn as SynthesizerTrnJPExtra,
)
from style_bert_vits2.nlp import bert_models
from style_bert_vits2.voice import adjust_voice
@@ -379,6 +380,13 @@ class TTSModelHolder:
def get_model_for_gradio(
self, model_name: str, model_path_str: str
) -> tuple[gr.Dropdown, gr.Button, gr.Dropdown]:
bert_models.load_model(Languages.JP)
bert_models.load_tokenizer(Languages.JP)
bert_models.load_model(Languages.EN)
bert_models.load_tokenizer(Languages.EN)
bert_models.load_model(Languages.ZH)
bert_models.load_tokenizer(Languages.ZH)
model_path = Path(model_path_str)
if model_name not in self.model_files_dict:
raise ValueError(f"Model `{model_name}` is not found")