Refactor: add Pydantic model representing hyper-parameters of Style-Bert-VITS2 model
This commit is contained in:
@@ -357,39 +357,6 @@ def check_git_hash(model_dir):
|
||||
open(path, "w").write(cur_hash)
|
||||
|
||||
|
||||
def get_hparams(init=True):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--config",
|
||||
type=str,
|
||||
default="./configs/base.json",
|
||||
help="JSON file for configuration",
|
||||
)
|
||||
parser.add_argument("-m", "--model", type=str, required=True, help="Model name")
|
||||
|
||||
args = parser.parse_args()
|
||||
model_dir = os.path.join("./logs", args.model)
|
||||
|
||||
if not os.path.exists(model_dir):
|
||||
os.makedirs(model_dir)
|
||||
|
||||
config_path = args.config
|
||||
config_save_path = os.path.join(model_dir, "config.json")
|
||||
if init:
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
data = f.read()
|
||||
with open(config_save_path, "w", encoding="utf-8") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
with open(config_save_path, "r", vencoding="utf-8") as f:
|
||||
data = f.read()
|
||||
config = json.loads(data)
|
||||
hparams = HParams(**config)
|
||||
hparams.model_dir = model_dir
|
||||
return hparams
|
||||
|
||||
|
||||
def get_hparams_from_file(config_path):
|
||||
# print("config_path: ", config_path)
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
|
||||
Reference in New Issue
Block a user