Create model.py
Browse files
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
|