os.makedirs(pt_dir, exist_ok=True) os.makedirs(log_dir, exist_ok=True) logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler( os.path.join( log_dir, '%s-%d.log' % (args.name, time.time()))), logging.StreamHandler() ]) logger = logging.getLogger() writer = MyWriter(hp, log_dir) assert hp.audio.hop_length == 256, \ 'hp.audio.hop_length must be equal to 256, got %d' % hp.audio.hop_length assert hp.data.train != '' and hp.data.validation != '', \ 'hp.data.train and hp.data.validation can\'t be empty: please fix %s' % args.config trainloader = create_dataloader(hp, args, True) valloader = create_dataloader(hp, args, False) train(args, pt_dir, args.checkpoint_path, trainloader, valloader, writer, logger, hp, hp_str) def repl_test(): chkpt_path = args.checkpoint_path
pt_dir = os.path.join(args.base_dir, hp.log.chkpt_dir, args.model) os.makedirs(pt_dir, exist_ok=True) log_dir = os.path.join(args.base_dir, hp.log.log_dir, args.model) os.makedirs(log_dir, exist_ok=True) chkpt_path = args.checkpoint_path if args.checkpoint_path is not None else None logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler(os.path.join(log_dir, '%s-%d.log' % (args.model, time.time()))), logging.StreamHandler() ] ) logger = logging.getLogger() if hp.data.train_dir == '' or hp.data.test_dir == '': logger.error("train_dir, test_dir cannot be empty.") raise Exception("Please specify directories of data in %s" % args.config) writer = MyWriter(hp, log_dir) trainloader = create_dataloader(hp, args, train=True) testloader = create_dataloader(hp, args, train=False) train(args, pt_dir, chkpt_path, trainloader, testloader, writer, logger, hp, hp_str)