def main(args): logger.info('Using torch {}'.format(torch.__version__)) cfg = CommonConfiguration.from_yaml(args.setting) logger.info('Loaded training setting file: {}'.format(args.setting)) trainer = Trainer(cfg) logger.info('Started training...') trainer.start() logger.info('Finished training.')
def _parser_dict(self): dictionary = CommonConfiguration.from_yaml(cfg.DATASET.DICTIONARY) return dictionary[cfg.DATASET.DICTIONARY_NAME]
perf_log += "{:}: {:.4f}\n".format(k, v) perf_log += "------------------------------------\n" logger.info(perf_log) acc = performances['performance'] return acc, perf_log if __name__ == '__main__': parser = argparse.ArgumentParser(description='Generic Pytorch-based Training Framework') parser.add_argument('--setting', default='conf/cityscapes_deeplabv3plus.yml', help='The path to the configuration file.') # distributed training parameters parser.add_argument("--local_rank", default=0, type=int) args = parser.parse_args() cfg = CommonConfiguration.from_yaml(args.setting) cfg.local_rank = args.local_rank if cfg.local_rank==0: logger.info('Loaded configuration file: {}'.format(args.setting)) logger.info('Use gpu ids: {}'.format(cfg.GPU_IDS)) trainer = Trainer(cfg) logger.info('Begin to training ...') trainer.run() if cfg.local_rank == 0: logger.info('finish!') torch.cuda.empty_cache()
def _parser_dict(self): dictionary = CommonConfiguration.from_yaml(cfg.DATASET.DICTIONARY) return next(dictionary.items())[1] ## return first