gurwindersingh commited on
Commit
c2a382d
·
1 Parent(s): b70836d

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +22 -0
  2. handwritten_digits.model +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from matplotlib import pyplot as plt
3
+ import numpy as np
4
+ import gradio as gr
5
+
6
+ # Load the model
7
+ model = tf.keras.models.load_model('handwritten_digits.model')
8
+
9
+ def recognize_digit(image):
10
+ if image is not None:
11
+ image = image.reshape((1,28,28,1)).astype('float32')/255
12
+ prediction = model.predict(image)
13
+ return {str(i) : float(prediction[0][i]) for i in range(10)}
14
+ else:
15
+ return ''
16
+
17
+ iface = gr.Interface(
18
+ fn = recognize_digit,
19
+ inputs=gr.Image(shape=(28,28),image_mode = 'L',invert_colors=True, source = 'canvas'),
20
+ outputs=gr.Label(top_num_classes=3))
21
+
22
+ iface.launch(server_port=8888)
handwritten_digits.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b2da4238c9f066443aab7b3989cacf27a722a9ebf614ae4ab5183a8be69d029
3
+ size 1447256
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.50.2
2
+ numpy
3
+ keras
4
+ tensorflow