Armyman91 commited on
Commit
52d4e45
·
verified ·
1 Parent(s): 68808ab

Create model.py

Browse files
Files changed (1) hide show
  1. model.py +15 -0
model.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # model.py
2
+ import torch
3
+ from models.networks import define_G
4
+
5
+ def load_generator(model_path):
6
+ # Define the generator with default CycleGAN config
7
+ netG = define_G(
8
+ input_nc=1, output_nc=1, ngf=64,
9
+ netG='resnet_9blocks', norm='instance',
10
+ use_dropout=False, init_type='normal', init_gain=0.02, gpu_ids=[]
11
+ )
12
+ state_dict = torch.load(model_path, map_location='cpu')
13
+ netG.load_state_dict(state_dict)
14
+ netG.eval()
15
+ return netG