in one_shot_domain_adaptation.py [0:0]
def initialize_models_all(opt):
"""Initialize the model and load the pre-trained weights. Note that we only
build the synthesis network which takes styles as input (no mapping network
is necessary for our task)."""
# load mapping network
g_all = nn.Sequential(
OrderedDict(
[
("g_mapping", G_mapping()),
# ('truncation', Truncation(avg_latent)),
(
"g_synthesis",
G_synthesis(
randomize_noise=False,
resolution=opt.resolution,
use_random_initial_noise=opt.use_random_initial_noise,
),
),
]
)
)
g_all.load_state_dict(
torch.load(
"./karras2019stylegan-ffhq-1024x1024.for_g_all.pt" # noqa
)
)
state = g_all.g_synthesis.state_dict()
state.update(torch.load(syn_pt_path))
loaded_dict = {k: state[k] for k in g_all.g_synthesis.state_dict()}
g_all.g_synthesis.load_state_dict(loaded_dict)
g_all.eval()
g_mapping = g_all.g_mapping.cuda()
g_synthesis = g_all.g_synthesis.cuda()
return g_mapping, g_synthesis