Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
return greeting, round(celsius, 2)
|
8 |
|
|
|
|
|
9 |
|
10 |
-
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
import tensorflow as tf
|
4 |
+
import keras
|
5 |
+
from matplotlib import pyplot as plt
|
6 |
+
import numpy as np
|
|
|
7 |
|
8 |
+
objects = tf.keras.datasets.mnist
|
9 |
+
(training_images, training_labels), (test_images, test_labels) = objects.load_data()
|
10 |
|
11 |
+
training_images = training_images / 255.0
|
12 |
+
test_images = test_images / 255.0
|
13 |
|
14 |
+
from keras.layers import Flatten, Dense
|
15 |
+
model = tf.keras.models.Sequential([Flatten(input_shape=(28,28)),
|
16 |
+
Dense(256, activation='relu'),
|
17 |
+
Dense(256, activation='relu'),
|
18 |
+
Dense(128, activation='relu'),
|
19 |
+
Dense(10, activation=tf.nn.softmax)])
|
20 |
+
|
21 |
+
model.compile(optimizer = 'adam',
|
22 |
+
loss = 'sparse_categorical_crossentropy',
|
23 |
+
metrics=['accuracy'])
|
24 |
+
|
25 |
+
model.fit(training_images, training_labels, epochs=10)
|
26 |
+
|
27 |
+
test=test_images[0].reshape(-1,28,28)
|
28 |
+
pred=model.predict(test)
|
29 |
+
print(pred)
|
30 |
+
|
31 |
+
iface = gr.Interface(predict_image, inputs="sketchpad", outputs="label")
|
32 |
+
|
33 |
+
iface.launch(debug='True')
|