Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit b75dee4

Browse files
author
Molugan
authored
FEATURES : StyleGan on hubconf (#115)
1 parent 7275ecb commit b75dee4

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

hubconf.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
55
## Users can get the diverse models of pytorch_gan_zoo by calling
66
hub_model = hub.load(
7-
'??/pytorch_gan_zoo:master',
7+
'facebookresearch/pytorch_gan_zoo:master',
88
$MODEL_NAME, #
99
config = None,
1010
useGPU = True,
1111
pretrained=False) # (Not pretrained models online yet)
1212
13-
Available model'names are [DCGAN, PGAN].
13+
Available model'names are [DCGAN, PGAN, StyleGAN].
1414
The config option should be a dictionnary defining the training parameters of
1515
the model. See ??/pytorch_gan_zoo/models/trainer/standard_configurations to see
1616
all possible options
@@ -99,6 +99,28 @@ def PGAN(pretrained=False, *args, **kwargs):
9999
return model
100100

101101

102+
def StyleGAN(pretrained=False, *args, **kwargs):
103+
"""
104+
NVIDIA StyleGAN
105+
pretrained (bool): load a 1024x1024 model trained on FlickrHQ
106+
"""
107+
from models.styleGAN import StyleGAN
108+
if 'config' not in kwargs or kwargs['config'] is None:
109+
kwargs['config'] = {}
110+
111+
model = StyleGAN(useGPU=kwargs.get('useGPU', True),
112+
storeAVG=True,
113+
**kwargs['config'])
114+
115+
checkpoint = 'https://dl.fbaipublicfiles.com/gan_zoo/StyleGAN/FFHQ_styleGAN-7cbdec00.pth'
116+
if pretrained:
117+
print("Loading default model : Flickr-HQ")
118+
state_dict = model_zoo.load_url(checkpoint,
119+
map_location='cpu')
120+
model.load_state_dict(state_dict)
121+
return model
122+
123+
102124
def DCGAN(pretrained=False, *args, **kwargs):
103125
"""
104126
DCGAN basic model

0 commit comments

Comments
 (0)