Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,13 @@ def generate_latent_points(digit, latent_dim, n_samples, n_classes=10):
|
|
18 |
labels = tf.keras.utils.to_categorical([digit for _ in range(n_samples)], n_classes)
|
19 |
return tf.concat([random_latent_vectors, labels], 1)
|
20 |
|
21 |
-
def create_digit_samples(digit, n_samples
|
22 |
-
|
23 |
-
|
|
|
24 |
examples = examples * 255.0
|
25 |
size = ceil(sqrt(n_samples))
|
26 |
-
digit_images = np.zeros((28*size, 28*size))
|
27 |
n = 0
|
28 |
for i in range(size):
|
29 |
for j in range(size):
|
@@ -31,7 +32,7 @@ def create_digit_samples(digit, n_samples, latent_dim=latent_dim):
|
|
31 |
break
|
32 |
digit_images[i* 28 : (i+1)*28, j*28 : (j+1)*28] = examples[n, :, :, 0]
|
33 |
n += 1
|
34 |
-
|
35 |
return digit_images
|
36 |
|
37 |
description = "This model is based on the example created here: https://keras.io/examples/generative/conditional_gan/"
|
|
|
18 |
labels = tf.keras.utils.to_categorical([digit for _ in range(n_samples)], n_classes)
|
19 |
return tf.concat([random_latent_vectors, labels], 1)
|
20 |
|
21 |
+
def create_digit_samples(digit, n_samples):
|
22 |
+
latent_dim = 128
|
23 |
+
random_vector_labels = generate_latent_points(int(digit), latent_dim, int(n_samples))
|
24 |
+
examples = model.predict(random_vector_labels)
|
25 |
examples = examples * 255.0
|
26 |
size = ceil(sqrt(n_samples))
|
27 |
+
digit_images = np.zeros((28*size, 28*size), dtype=float)
|
28 |
n = 0
|
29 |
for i in range(size):
|
30 |
for j in range(size):
|
|
|
32 |
break
|
33 |
digit_images[i* 28 : (i+1)*28, j*28 : (j+1)*28] = examples[n, :, :, 0]
|
34 |
n += 1
|
35 |
+
digit_images = (digit_images/127.5) -1
|
36 |
return digit_images
|
37 |
|
38 |
description = "This model is based on the example created here: https://keras.io/examples/generative/conditional_gan/"
|