Created
September 21, 2020 16:13
-
-
Save woctezuma/71b89d6a61e373ddec08a5520e86055b to your computer and use it in GitHub Desktop.
StyleGAN2: minimal usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pretrained_networks | |
import numpy as np | |
import dnnlib | |
import dnnlib.tflib as tflib | |
import PIL.Image | |
network_pkl = 'gdrive:networks/stylegan2-ffhq-config-f.pkl' | |
_, _, Gs = pretrained_networks.load_networks(network_pkl) | |
rng_seed = 5616 | |
z = np.random.RandomState(rng_seed).randn(1, 512) | |
w = Gs.components.mapping.run(z, None) # [18, 512] | |
Gs_syn_kwargs = dnnlib.EasyDict() | |
Gs_syn_kwargs.output_transform = dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True) | |
Gs_syn_kwargs.randomize_noise = False | |
image = Gs.components.synthesis.run(w, **Gs_syn_kwargs)[0] | |
image = PIL.Image.fromarray(image) | |
image # display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment