ravikagitha commited on
Commit
6a2e948
·
1 Parent(s): 14ab8f7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+
5
+ # Load the model
6
+ model = tf.keras.saving.load_model('/content/mnist_trained_model_2(acc-97%).h5')
7
+
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
+ # Interface
16
+ label = gr.outputs.Label(num_top_classes=3)
17
+ interface = gr.Interface(fn=classify_image,
18
+ inputs="sketchpad",
19
+ outputs=label,
20
+ capture_session="True")
21
+
22
+ # Launch
23
+ interface.launch(inline = False)