File size: 633 Bytes
3749ce1
 
 
 
7fce9b8
3749ce1
 
 
7fce9b8
f2ea880
7fce9b8
 
 
3749ce1
7fce9b8
3749ce1
 
 
6e25d46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from tensorflow import keras as k
import numpy as np

loaded_CNN = k.models.load_model('CNN_extended_dataset.h5') 

def predict(img):
    img_array = np.array(img)
    img_array = img_array.reshape(1, 28, 28)
    img_array = img_array/255
    pred = loaded_CNN.predict(img_array)
    print(pred)
    return np.argmax(pred)

iface = gr.Interface(predict, inputs = 'sketchpad',
                     outputs = 'text',
                     allow_flagging = 'never',
                     description = 'Draw a Digit Below... (Draw in the centre for best results)')
iface.launch(share = True, width = 300, height = 500)