Spaces:
Runtime error
Runtime error
ravikagitha
commited on
Commit
•
359f0b3
1
Parent(s):
d2cbe17
Update app.py
Browse files
app.py
CHANGED
@@ -8,11 +8,10 @@ model = tf.keras.models.load_model('mnist_trained_model_2(acc-97%).h5')
|
|
8 |
# Classification prediction function
|
9 |
labels = [0,1,2,3,4,5,6,7,8,9]
|
10 |
def classify_image(image):
|
11 |
-
prediction = model.predict(image.reshape(
|
12 |
confidences = {labels[i]: float(prediction[i]) for i in range(10)}
|
13 |
return confidences
|
14 |
-
|
15 |
-
# Interface
|
16 |
label = gr.outputs.Label(num_top_classes=3)
|
17 |
interface = gr.Interface(fn=classify_image,
|
18 |
inputs="sketchpad",
|
@@ -20,6 +19,5 @@ interface = gr.Interface(fn=classify_image,
|
|
20 |
capture_session="True",
|
21 |
title = "Digits Classification",
|
22 |
description = "This is a machine learning model which can classify the hand written digits from 0-9.")
|
23 |
-
|
24 |
# Launch
|
25 |
interface.launch(inline = False)
|
|
|
8 |
# Classification prediction function
|
9 |
labels = [0,1,2,3,4,5,6,7,8,9]
|
10 |
def classify_image(image):
|
11 |
+
prediction = model.predict(image.reshape(-1,784)/255).flatten()
|
12 |
confidences = {labels[i]: float(prediction[i]) for i in range(10)}
|
13 |
return confidences
|
14 |
+
|
|
|
15 |
label = gr.outputs.Label(num_top_classes=3)
|
16 |
interface = gr.Interface(fn=classify_image,
|
17 |
inputs="sketchpad",
|
|
|
19 |
capture_session="True",
|
20 |
title = "Digits Classification",
|
21 |
description = "This is a machine learning model which can classify the hand written digits from 0-9.")
|
|
|
22 |
# Launch
|
23 |
interface.launch(inline = False)
|