From 6d65db1f76ad7e3722d8d7141feaab35ce17952c Mon Sep 17 00:00:00 2001 From: Emberstar <969242373@qq.com> Date: Wed, 14 Jun 2023 12:23:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B8=83=E5=B0=94=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=9C=A8=E4=BC=A0=E5=85=A5False=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E5=BD=93=E6=88=90=E5=AD=97=E7=AC=A6=E4=B8=B2=E8=80=8C?= =?UTF-8?q?=E5=8F=98=E6=88=90True?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/utils.py b/utils.py index 205d929..648ae27 100644 --- a/utils.py +++ b/utils.py @@ -293,6 +293,17 @@ def load_filepaths_and_text(filename, split="|"): return filepaths_and_text +def str2bool(v): + if isinstance(v, bool): + return v + if v.lower() in ('yes', 'true', 't', 'y', '1'): + return True + elif v.lower() in ('no', 'false', 'f', 'n', '0'): + return False + else: + raise argparse.ArgumentTypeError('Boolean value expected.') + + def get_hparams(init=True): parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', type=str, default="./configs/modified_finetune_speaker.json", @@ -301,9 +312,9 @@ def get_hparams(init=True): help='Model name') parser.add_argument('-n', '--max_epochs', type=int, default=50, help='finetune epochs') - parser.add_argument('--cont', type=bool, default=False, help='whether to continue training on the latest checkpoint') - parser.add_argument('--drop_speaker_embed', type=bool, default=False, help='whether to drop existing characters') - parser.add_argument('--train_with_pretrained_model', type=bool, default=True, + parser.add_argument('--cont', type=str2bool, default=False, help='whether to continue training on the latest checkpoint') + parser.add_argument('--drop_speaker_embed', type=str2bool, default=False, help='whether to drop existing characters') + parser.add_argument('--train_with_pretrained_model', type=str2bool, default=True, help='whether to train with pretrained model') parser.add_argument('--preserved', type=int, default=4, help='Number of preserved models')