Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ import gradio as gr
|
|
12 |
sys.path.insert(0, "/StyleGAN2-GANbanales")
|
13 |
|
14 |
import dnnlib
|
15 |
-
|
16 |
|
17 |
##############################################################################
|
18 |
# Generation functions
|
@@ -24,12 +24,12 @@ def seed2vec(Gs, seed):
|
|
24 |
def init_random_state(Gs, seed):
|
25 |
rnd = np.random.RandomState(seed)
|
26 |
noise_vars = [var for name, var in Gs.components.synthesis.vars.items() if name.startswith('noise')]
|
27 |
-
|
28 |
|
29 |
def generate_image(Gs, z, truncation_psi, prefix="image", save=False, show=False):
|
30 |
# Render images for dlatents initialized from random seeds.
|
31 |
Gs_kwargs = {
|
32 |
-
'output_transform': dict(func=
|
33 |
'randomize_noise': False
|
34 |
}
|
35 |
if truncation_psi is not None:
|
@@ -119,7 +119,7 @@ def concatenate(img_array):
|
|
119 |
def initiate(seed, n_imgs, text):
|
120 |
|
121 |
pkl_file = "networks/experimento_2.pkl"
|
122 |
-
|
123 |
|
124 |
with open(pkl_file, 'rb') as pickle_file:
|
125 |
_G, _D, Gs = pickle.load(pickle_file)
|
|
|
12 |
sys.path.insert(0, "/StyleGAN2-GANbanales")
|
13 |
|
14 |
import dnnlib
|
15 |
+
import dnnlib.tflib as tflib
|
16 |
|
17 |
##############################################################################
|
18 |
# Generation functions
|
|
|
24 |
def init_random_state(Gs, seed):
|
25 |
rnd = np.random.RandomState(seed)
|
26 |
noise_vars = [var for name, var in Gs.components.synthesis.vars.items() if name.startswith('noise')]
|
27 |
+
tflib.set_vars({var: rnd.randn(*var.shape.as_list()) for var in noise_vars}) # [height, width]
|
28 |
|
29 |
def generate_image(Gs, z, truncation_psi, prefix="image", save=False, show=False):
|
30 |
# Render images for dlatents initialized from random seeds.
|
31 |
Gs_kwargs = {
|
32 |
+
'output_transform': dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True),
|
33 |
'randomize_noise': False
|
34 |
}
|
35 |
if truncation_psi is not None:
|
|
|
119 |
def initiate(seed, n_imgs, text):
|
120 |
|
121 |
pkl_file = "networks/experimento_2.pkl"
|
122 |
+
tflib.init_tf()
|
123 |
|
124 |
with open(pkl_file, 'rb') as pickle_file:
|
125 |
_G, _D, Gs = pickle.load(pickle_file)
|