a312863063 / seeprettyface-generator-wanghong

这是一个用StyleGAN训练出的网红脸生成器
691 stars 171 forks source link

怎么用生成码 dlatent? #3

Open athenawisdoms opened 4 years ago

athenawisdoms commented 4 years ago

请问该怎么与generator_wanghong_hd.pkl一起使用生成码 dlatent?

如果使用 generator_wanghong_hd.pkl,它会绘制错误的图像

# http://www.seeprettyface.com/generate_code/Fanbingbing.npy
dlatent= np.load('Fanbingbing.npy')
model_path = 'generator_wanghong_hd.pkl'

synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=1)
with dnnlib.util.open_url(model_path) as f:
    _G, _D, Gs = pickle.load(f)

img = Gs.components.synthesis.run(dlatent.reshape((-1, 18, 512)), randomize_noise=False, **synthesis_kwargs)[0]
plt.imshow(img)
plt.axis('off')
plt.show()

image

只有使用 karras2019stylegan-ffhq-1024x1024.pkl 时才会绘制正确的图像

# http://www.seeprettyface.com/generate_code/Fanbingbing.npy
dlatent= np.load('Fanbingbing.npy')
model_path = 'karras2019stylegan-ffhq-1024x1024.pkl'

synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=1)
with dnnlib.util.open_url(model_path) as f:
    _G, _D, Gs = pickle.load(f)

img = Gs.components.synthesis.run(dlatent.reshape((-1, 18, 512)), randomize_noise=False, **synthesis_kwargs)[0]
plt.imshow(img)
plt.axis('off')
plt.show()

image

a312863063 commented 4 years ago

你好,Fanbingbing.npy是用官方生成器训练出来的,所以只能搭配karras2019stylegan-ffhq-1024x1024.pkl才能还原哦。如果想用generator_wanghong_hd.pkl,得搭配用网红脸生成器找到的生成码才行。