Fmt only (maybe)

This commit is contained in:
litagin02
2024-05-25 18:15:36 +09:00
parent acf93b80ce
commit 2274087da4
33 changed files with 216 additions and 166 deletions

View File

@@ -47,9 +47,9 @@ def merge_style(
style_vectors_b = np.load(
assets_root / model_name_b / "style_vectors.npy"
) # (style_num_b, 256)
with open(assets_root / model_name_a / "config.json", "r", encoding="utf-8") as f:
with open(assets_root / model_name_a / "config.json", encoding="utf-8") as f:
config_a = json.load(f)
with open(assets_root / model_name_b / "config.json", "r", encoding="utf-8") as f:
with open(assets_root / model_name_b / "config.json", encoding="utf-8") as f:
config_b = json.load(f)
style2id_a = config_a["data"]["style2id"]
style2id_b = config_b["data"]["style2id"]
@@ -83,7 +83,7 @@ def merge_style(
# recipe.jsonを読み込んで、style_triple_listを追記
info_path = assets_root / output_name / "recipe.json"
if info_path.exists():
with open(info_path, "r", encoding="utf-8") as f:
with open(info_path, encoding="utf-8") as f:
info = json.load(f)
else:
info = {}
@@ -143,7 +143,7 @@ def merge_models(
merged_model_weight = model_a_weight.copy()
for key in model_a_weight.keys():
for key in model_a_weight:
if any([key.startswith(prefix) for prefix in voice_keys]):
weight = voice_weight
elif any([key.startswith(prefix) for prefix in voice_pitch_keys]):
@@ -256,12 +256,12 @@ def update_two_model_names_dropdown(model_holder: TTSModelHolder):
def load_styles_gr(model_name_a: str, model_name_b: str):
config_path_a = assets_root / model_name_a / "config.json"
with open(config_path_a, "r", encoding="utf-8") as f:
with open(config_path_a, encoding="utf-8") as f:
config_a = json.load(f)
styles_a = list(config_a["data"]["style2id"].keys())
config_path_b = assets_root / model_name_b / "config.json"
with open(config_path_b, "r", encoding="utf-8") as f:
with open(config_path_b, encoding="utf-8") as f:
config_b = json.load(f)
styles_b = list(config_b["data"]["style2id"].keys())

View File

@@ -5,13 +5,14 @@ import subprocess
import sys
import time
import webbrowser
from dataclasses import dataclass
from datetime import datetime
from multiprocessing import cpu_count
from pathlib import Path
import gradio as gr
import yaml
from dataclasses import dataclass
from config import get_path_config
from style_bert_vits2.logging import logger
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT
@@ -75,7 +76,7 @@ def initialize(
"configs/config.json" if not use_jp_extra else "configs/config_jp_extra.json"
)
with open(default_config_path, "r", encoding="utf-8") as f:
with open(default_config_path, encoding="utf-8") as f:
config = json.load(f)
config["model_name"] = model_name
config["data"]["training_files"] = str(paths.train_path)
@@ -121,7 +122,7 @@ def initialize(
json.dump(config, f, indent=2, ensure_ascii=False)
if not Path("config.yml").exists():
shutil.copy(src="default_config.yml", dst="config.yml")
with open("config.yml", "r", encoding="utf-8") as f:
with open("config.yml", encoding="utf-8") as f:
yml_data = yaml.safe_load(f)
yml_data["model_name"] = model_name
yml_data["dataset_path"] = str(paths.dataset_path)
@@ -331,7 +332,7 @@ def train(
):
paths = get_path(model_name)
# 学習再開の場合を考えて念のためconfig.ymlの名前等を更新
with open("config.yml", "r", encoding="utf-8") as f:
with open("config.yml", encoding="utf-8") as f:
yml_data = yaml.safe_load(f)
yml_data["model_name"] = model_name
yml_data["dataset_path"] = str(paths.dataset_path)