Example #1
0
def get_student_cfg(cfg, path):
    if os.path.exists(path):
        with open(path) as file:
            student_file_cfg = config.load_cfg(file)
    else:
        print("File {} not exists".format(args.student_file))
        print("Please input a specific student config file")
        print("Exiting...")
        exit(-1)

    student_cfg = copy.deepcopy(cfg)
    for key, value in student_file_cfg.items():
        student_cfg[key] = value

    return student_cfg
Example #2
0
def load_cfg_from_file(cfg_filename):
    """Load config from a file

    Args:
        cfg_filename (str):

    Returns:
        CfgNode: loaded configuration

    """
    with open(cfg_filename, "r") as f:
        cfg = load_cfg(f)

    cfg_template = _C
    cfg_template.merge_from_other_cfg(cfg)
    return cfg_template
Example #3
0
def make_config(config_file):
    with open(config_file, 'r') as f:
        cfg = config.load_cfg(f)
        cfg.set_new_allowed(True)
    return cfg.clone()
Example #4
0
import numpy as np
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--mat", required=True)
    parser.add_argument("--weights", required=True)
    parser.add_argument("--var_name", required=True)
    parser.add_argument("--output_mat", required=True)
    parser.add_argument("--norm", required=True)

    args = parser.parse_args()

    var = sio.loadmat(args.mat)
    in_data = torch.tensor(var[args.var_name])

    with open(args.norm, "r") as f:
        cfg = config.load_cfg(f)
    input_mean = torch.tensor(cfg.input.mean)
    input_std = torch.tensor(cfg.input.std)

    target_mean = torch.tensor(cfg.target.mean)
    target_std = torch.tensor(cfg.target.std)

    in_data = (in_data - input_mean) / input_std

    with open(args.weights, "rb") as f:
        net = torch.load(f)
    net.eval()


    output = net(in_data) * target_std + target_mean
Example #5
0
 def get_cfg_from_file(self, fbase):
     with open(fbase + "model_and_cfg/exp_cfg", "rt") as cfg_file:
         return load_cfg(cfg_file)
Example #6
0
def make_config(config_file):
    with open(config_file, 'r') as f:
        cfg = config.load_cfg(f)
    return cfg.clone()
Example #7
0
def read_yaml(filepath: str):
    with open(filepath, "r") as f:
        return load_cfg(f)