# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + id="Ng4P3Zuri_Z8"
# %tensorflow_version 1.x

# + id="hcDlSfu4jc2t"
# !wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1ovYLYG7e15QqOafzvy_nhxUeKM9uxyXd' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1ovYLYG7e15QqOafzvy_nhxUeKM9uxyXd" -O Clarkson_Finger_Generator.pkl && rm -rf /tmp/cookies.txt

# + id="J2qQo3k1jExA"
# !git clone https://github.com/keivanB/Clarkson_Finger_Gen

# + id="O5tQe-koh8cI"
import os
import sys
new_path = '/content/Clarkson_Finger_Gen/stylegan_K1/'
sys.path.append(new_path)
import pickle
import numpy as np
import PIL.Image
import dnnlib
import dnnlib.tflib as tflib
import config
import io
import matplotlib.pyplot as plt

# + id="jvq0faZhh8cx"
'''Loading Pre trained network'''
tflib.init_tf()
f = open('/content/Clarkson_Finger_Generator.pkl', 'rb')
_G, _D, Gs = pickle.load(f)

# + id="QO3JNdLAh8c5"
# Pick latent vector.
rnd = np.random.RandomState(100)
latents = rnd.randn(32, Gs.input_shape[1])

# Generate image.
fmt = dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True)
images = Gs.run(latents, None, truncation_psi=1, randomize_noise=True, output_transform=fmt)
images = np.transpose(images,(0,3, 1, 2))

# + id="qLSiHyRnh8dV"
fig, ax = plt.subplots(8,4, figsize=(30,30))
for i in range(32):
    r = int(i%4)
    c = int(i/4)
    ax[c,r].imshow(np.transpose(np.squeeze(images[i,:,:,:]), (1,2,0)))

StarcoderdataJupyterScriptsDedupFiltered