Spaces:
Sleeping
Sleeping
File size: 620 Bytes
1ea937d 6811c82 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import torch
from models.networks import define_G
def load_generator(checkpoint_path):
checkpoint = torch.load(checkpoint_path, map_location='cpu')
if 'G_A' in checkpoint:
state_dict = checkpoint['G_A']
elif 'state_dict' in checkpoint:
state_dict = checkpoint['state_dict']
else:
state_dict = checkpoint
# Match your trained generator architecture here!
netG = define_G(input_nc=1, output_nc=1, ngf=64, netG='unet_128', norm='batch', use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[])
netG.load_state_dict(state_dict)
netG.eval()
return netG |