Spaces:
Runtime error
Runtime error
Commit
·
7eabb4f
1
Parent(s):
4644430
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,26 +17,26 @@ article = """
|
|
| 17 |
</p>
|
| 18 |
"""
|
| 19 |
|
| 20 |
-
def
|
| 21 |
-
random_latent_vectors = tf.random.normal(shape=(int(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
n = 0
|
| 26 |
-
for i in range(
|
| 27 |
-
for j in range(
|
| 28 |
-
if n ==
|
| 29 |
break
|
| 30 |
-
|
| 31 |
n += 1
|
| 32 |
-
return
|
| 33 |
|
| 34 |
|
| 35 |
examples = [[5],[8],[2],[3]]
|
| 36 |
|
| 37 |
|
| 38 |
iface = gr.Interface(
|
| 39 |
-
fn =
|
| 40 |
inputs = ["number"],
|
| 41 |
outputs = ["image"],
|
| 42 |
examples = examples,
|
|
|
|
| 17 |
</p>
|
| 18 |
"""
|
| 19 |
|
| 20 |
+
def Predict(num_images):
|
| 21 |
+
random_latent_vectors = tf.random.normal(shape=(int(num_images), 128))
|
| 22 |
+
preds = model(random_latent_vectors)
|
| 23 |
+
num = ceil(sqrt(num_images))
|
| 24 |
+
images = np.zeros((28*num, 28*num), dtype=float)
|
| 25 |
n = 0
|
| 26 |
+
for i in range(num):
|
| 27 |
+
for j in range(num):
|
| 28 |
+
if n == num_images:
|
| 29 |
break
|
| 30 |
+
images[i* 28 : (i+1)*28, j*28 : (j+1)*28] = preds[n, :, :, 0]
|
| 31 |
n += 1
|
| 32 |
+
return images
|
| 33 |
|
| 34 |
|
| 35 |
examples = [[5],[8],[2],[3]]
|
| 36 |
|
| 37 |
|
| 38 |
iface = gr.Interface(
|
| 39 |
+
fn = Predict,
|
| 40 |
inputs = ["number"],
|
| 41 |
outputs = ["image"],
|
| 42 |
examples = examples,
|