Example #1
0
def load_model(checkpoint_file):
    checkpoint = torch.load(checkpoint_file)
    args = checkpoint['args']
    model = UnetModel(1, 1, args.num_chans, args.num_pools, args.drop_prob).to(args.device)
    if args.data_parallel:
        model = torch.nn.DataParallel(model)
    model.load_state_dict(checkpoint['model'])
    return model
Example #2
0
def load_model(checkpoint_file):
    checkpoint = torch.load(checkpoint_file)
    args = checkpoint['args']
    model = UnetModel(in_chans=1,
                      out_chans=1,
                      chans=args.num_chans,
                      num_pool_layers=args.num_pools,
                      drop_prob=args.drop_prob,
                      acceleration=args.accelerations,
                      center_fraction=args.center_fractions,
                      res=args.resolution).to(args.device)
    if args.data_parallel:
        model = torch.nn.DataParallel(model)
    model.load_state_dict(checkpoint['model'])
    return model