Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,14 +3,18 @@ import tensorflow as tf
|
|
3 |
import keras
|
4 |
from keras.datasets import mnist
|
5 |
import matplotlib.pyplot as plt
|
|
|
6 |
|
7 |
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
|
8 |
|
9 |
def get_digit(digit_choice):
|
10 |
-
|
|
|
|
|
|
|
11 |
fig = plt.figure()
|
12 |
plt.imshow(digit)
|
13 |
-
out_txt = "digit: %d" % digit_choice
|
14 |
return fig, out_txt
|
15 |
|
16 |
iface = gr.Interface(
|
|
|
3 |
import keras
|
4 |
from keras.datasets import mnist
|
5 |
import matplotlib.pyplot as plt
|
6 |
+
import random
|
7 |
|
8 |
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
|
9 |
|
10 |
def get_digit(digit_choice):
|
11 |
+
rn = 0
|
12 |
+
while(test_labels[rn] != digit_choice):
|
13 |
+
rn = int(random.random() * 1000)
|
14 |
+
digit = train_images[rn]
|
15 |
fig = plt.figure()
|
16 |
plt.imshow(digit)
|
17 |
+
out_txt = "digit index: %d\ndigit label: %d" % digit_choice, rn
|
18 |
return fig, out_txt
|
19 |
|
20 |
iface = gr.Interface(
|