File size: 468 Bytes
52d4e45 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # model.py
import torch
from models.networks import define_G
def load_generator(model_path):
# Define the generator with default CycleGAN config
netG = define_G(
input_nc=1, output_nc=1, ngf=64,
netG='resnet_9blocks', norm='instance',
use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[]
)
state_dict = torch.load(model_path, map_location='cpu')
netG.load_state_dict(state_dict)
netG.eval()
return netG |