Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Sat Dec 18 15:52:10 2021
|
4 |
+
|
5 |
+
@author: riche
|
6 |
+
"""
|
7 |
+
|
8 |
+
import pandas as pd
|
9 |
+
import numpy as np
|
10 |
+
from sklearn.preprocessing import MinMaxScaler
|
11 |
+
from keras.models import load_model
|
12 |
+
import gradio as gr
|
13 |
+
|
14 |
+
X_train = train.copy()
|
15 |
+
y_train = X_train.pop('label')
|
16 |
+
|
17 |
+
|
18 |
+
scale = MinMaxScaler()
|
19 |
+
X_train = scale.fit_transform(X_train)
|
20 |
+
|
21 |
+
model = load_model('digit_recognizer_modeldef.h5')
|
22 |
+
|
23 |
+
def sketch_recognition(img):
|
24 |
+
# Implement sketch recognition model here...
|
25 |
+
# Return labels and confidences as dictionary
|
26 |
+
img = img.reshape((1, 784))
|
27 |
+
img = scale.transform(img.reshape(1, -1))
|
28 |
+
preds = model.predict(np.array(img).reshape((1, 28, 28, 1))).tolist()[0]
|
29 |
+
return {str(i): preds[i] for i in range(10)}
|
30 |
+
|
31 |
+
interface = gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs=gr.outputs.Label()).launch(share=True)
|