Spaces:
Sleeping
Sleeping
Commit
·
b6d9cbc
1
Parent(s):
f5977b2
Added app.py file for Gradio App
Browse files- app.py +20 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from keras.models import load_model
|
2 |
+
import cv2
|
3 |
+
|
4 |
+
loaded_model = load_model('model.h5')
|
5 |
+
|
6 |
+
def predict(img):
|
7 |
+
img = img['composite'][:,:,3]/255.0
|
8 |
+
img = cv2.resize(img, (28, 28))
|
9 |
+
prediction = np.argmax(loaded_model.predict(np.array([img]) ,verbose=0))
|
10 |
+
return prediction
|
11 |
+
|
12 |
+
input = [gr.Sketchpad(label="Sketchpad", canvas_size= (600,600) , image_mode = "RGBA")]
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=predict,
|
15 |
+
inputs=input,
|
16 |
+
outputs="textbox",
|
17 |
+
title="MNIST Handwritten Digit Recognition by Johnson Manuel",
|
18 |
+
description="Draw digits from 0 to 9 to see real-time recognition by a neural network trained on the MNIST dataset." ,live=True
|
19 |
+
)
|
20 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.32.2
|
2 |
+
keras==2.9.0
|
3 |
+
opencv-python==4.9.0.80
|
4 |
+
numpy==1.26.4
|