示例#1
0
    logger.info("INFO: Starting inference...")
    evaluator_engine.run(loader_test)

    save_predictions(evaluator_engine,
                     os.path.splitext(m_cp_path)[0],
                     accumulate_predictions.state_dict)


if __name__ == "__main__":
    parser = ArgumentParser()
    parser.add_argument('-c',
                        '--config',
                        default=None,
                        type=str,
                        required=True,
                        help='config file path (default: None)')
    parser.add_argument('--checkpoint',
                        default=None,
                        type=str,
                        help='Checkpoint to use for test')
    args = parser.parse_args()

    config = Experiment.load_from_path(args.config)

    if args.checkpoint:
        config.checkpoint = args.checkpoint

    assert config, "Config could not be loaded."

    main(config)
示例#2
0
    parser.add_argument('-c', '--config', default=None, type=str, required=True, help='config file path (default: None)')
    parser.add_argument('--checkpoint', default=None, type=str, help='Checkpoint tag to reload')    
    parser.add_argument('--checkpoint_dir', default=None, type=str, help='Checkpoint directory to reload')
    parser.add_argument('--suffix', default=None, type=str, help='Add to the name')
    parser.add_argument('--epochs', default=None, type=int, help='Number of epochs')
    parser.add_argument('--resume_from', default=None, type=int, help='Epoch to resume from, allows using checkpoints as initialisation')
    args = parser.parse_args()

    OVERLOADABLE = ['checkpoint', 'epochs', 'checkpoint_dir', 'resume_from']

    overloaded = {}
    for k, v in vars(args).items():
        if (k in OVERLOADABLE) and (v is not None):
            overloaded[k] = v

    config = Experiment.load_from_path(args.config, overloaded, args.suffix)

    assert config, "Config could not be loaded."

    # Else load the saved config from the results dir or throw an error if one doesn't exist
    if len(config.checkpoint) > 0:
        logger.warning("WARNING: --config specifies resuming, overriding config with exising experiment config.")
        # resume_config = Experiment(config.name, desc=config.desc, result_dir=config.result_dir).load()
        # assert resume_config is not None, "No experiment {} exists, cannot resume training".format(config.name)
        # config = resume_config
        assert config, "Config could not be loaded for resume"
    # If we have resume_from in the config but have it < 0 to start a fresh training run then throw and error if the directory already exists
    elif config.overwrite is False:
        assert not config.exists(), "Results directory {} already exists! Please specify a new experiment name or the remove old files.".format(config.result_path)
    else:
        empty_folder(config.result_path)