Python utils.str2bool() Examples

The following are 4 code examples of utils.str2bool(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module utils , or try the search function .
Example #1
Source File: demo.py    From LEDNet with MIT License 5 votes vote down vote up
def parse_args():
    parser = argparse.ArgumentParser(description='Demo for LEDNet from a given image')

    parser.add_argument('--input-pic', type=str, default=os.path.join(cur_path, 'png/demo.png'),
                        help='path to the input picture')
    parser.add_argument('--pretrained', type=str,
                        default=os.path.expanduser('~/cbb/own/pretrained/seg/lednet/LEDNet_final.pth'),
                        help='Default Pre-trained model root.')
    parser.add_argument('--cuda', type=ptutil.str2bool, default='true',
                        help='demo with GPU')

    opt = parser.parse_args()
    return opt 
Example #2
Source File: eval.py    From LEDNet with MIT License 5 votes vote down vote up
def parse_args():
    parser = argparse.ArgumentParser(description='Eval Segmentation.')
    parser.add_argument('--batch-size', type=int, default=1,
                        help='Training mini-batch size')
    parser.add_argument('--num-workers', '-j', dest='num_workers', type=int,
                        default=4, help='Number of data workers')
    parser.add_argument('--dataset', type=str, default='citys',
                        help='Select dataset.')
    parser.add_argument('--split', type=str, default='val',
                        help='Select val|test, evaluate in val or test data')
    parser.add_argument('--mode', type=str, default='testval',
                        help='Select testval|val, w/o corp and with crop')
    parser.add_argument('--base-size', type=int, default=1024,
                        help='base image size')
    parser.add_argument('--crop-size', type=int, default=768,
                        help='crop image size')

    parser.add_argument('--pretrained', type=str,
                        default='./LEDNet_iter_073600.pth',
                        help='Default Pre-trained model root.')

    # device
    parser.add_argument('--cuda', type=ptutil.str2bool, default='true',
                        help='Training with GPUs.')
    parser.add_argument('--local_rank', type=int, default=0)
    parser.add_argument('--init-method', type=str, default="env://")

    args = parser.parse_args()
    return args 
Example #3
Source File: train_tacotron.py    From Tacotron-Wavenet-Vocoder-Korean with MIT License 4 votes vote down vote up
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('--log_dir', default='logdir-tacotron')
    
    parser.add_argument('--data_paths', default='.\\data\\moon,.\\data\\son')
    
    
    parser.add_argument('--load_path', default=None)   # 아래의 'initialize_path'보다 우선 적용
    #parser.add_argument('--load_path', default='logdir-tacotron/moon+son_2018-12-25_19-03-21')
    
    
    parser.add_argument('--initialize_path', default=None)   # ckpt로 부터 model을 restore하지만, global step은 0에서 시작

    parser.add_argument('--batch_size', type=int, default=32)
    parser.add_argument('--num_test_per_speaker', type=int, default=2)
    parser.add_argument('--random_seed', type=int, default=123)
    parser.add_argument('--summary_interval', type=int, default=100000)
    parser.add_argument('--test_interval', type=int, default=500)  # 500
    parser.add_argument('--checkpoint_interval', type=int, default=2000) # 2000
    parser.add_argument('--skip_path_filter', type=str2bool, default=False, help='Use only for debugging')

    parser.add_argument('--slack_url', help='Slack webhook URL to get periodic reports.')
    parser.add_argument('--git', action='store_true', help='If set, verify that the client is clean.')  # The store_true option automatically creates a default value of False.

    config = parser.parse_args()
    config.data_paths = config.data_paths.split(",")
    setattr(hparams, "num_speakers", len(config.data_paths))

    prepare_dirs(config, hparams)

    log_path = os.path.join(config.model_dir, 'train.log')
    infolog.init(log_path, config.model_dir, config.slack_url)

    tf.set_random_seed(config.random_seed)
    print(config.data_paths)

    if any("krbook" not in data_path for data_path in config.data_paths) and  hparams.sample_rate != 20000:
        warning("Detect non-krbook dataset. May need to set sampling rate from {} to 20000".format(hparams.sample_rate))
        
    if any('LJ' in data_path for data_path in config.data_paths) and  hparams.sample_rate != 22050:
        warning("Detect LJ Speech dataset. Set sampling rate from {} to 22050".format(hparams.sample_rate))

    if config.load_path is not None and config.initialize_path is not None:
        raise Exception(" [!] Only one of load_path and initialize_path should be set")

    train(config.model_dir, config) 
Example #4
Source File: train_tacotron2.py    From Tacotron2-Wavenet-Korean-TTS with MIT License 4 votes vote down vote up
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument('--log_dir', default='logdir-tacotron2')
    
    parser.add_argument('--data_paths', default='D:\\hccho\\Tacotron-Wavenet-Vocoder-hccho\\data\\moon,D:\\hccho\\Tacotron-Wavenet-Vocoder-hccho\\data\\son')
    #parser.add_argument('--data_paths', default='D:\\hccho\\Tacotron-Wavenet-Vocoder-hccho\\data\\small1,D:\\hccho\\Tacotron-Wavenet-Vocoder-hccho\\data\\small2')
    
    
    #parser.add_argument('--load_path', default=None)   # 아래의 'initialize_path'보다 우선 적용
    parser.add_argument('--load_path', default='logdir-tacotron2/moon+son_2019-03-01_10-35-44')
    
    
    parser.add_argument('--initialize_path', default=None)   # ckpt로 부터 model을 restore하지만, global step은 0에서 시작

    parser.add_argument('--batch_size', type=int, default=32)
    parser.add_argument('--num_test_per_speaker', type=int, default=2)
    parser.add_argument('--random_seed', type=int, default=123)
    parser.add_argument('--summary_interval', type=int, default=100)
    
    parser.add_argument('--test_interval', type=int, default=500)  # 500
    
    parser.add_argument('--checkpoint_interval', type=int, default=2000) # 2000
    parser.add_argument('--skip_path_filter', type=str2bool, default=False, help='Use only for debugging')

    parser.add_argument('--slack_url', help='Slack webhook URL to get periodic reports.')
    parser.add_argument('--git', action='store_true', help='If set, verify that the client is clean.')  # The store_true option automatically creates a default value of False.

    config = parser.parse_args()
    config.data_paths = config.data_paths.split(",")
    setattr(hparams, "num_speakers", len(config.data_paths))

    prepare_dirs(config, hparams)

    log_path = os.path.join(config.model_dir, 'train.log')
    infolog.init(log_path, config.model_dir, config.slack_url)

    tf.set_random_seed(config.random_seed)
    print(config.data_paths)


    if config.load_path is not None and config.initialize_path is not None:
        raise Exception(" [!] Only one of load_path and initialize_path should be set")

    train(config.model_dir, config)