Spaces:
Runtime error
Runtime error
File size: 1,000 Bytes
9ee27f5 498bf53 9ee27f5 616d1dc 9ee27f5 f17f2f4 75a9c51 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from keras.models import load_model
import gradio as gr
train = pd.read_csv('train.csv')
X_train = train.copy()
y_train = X_train.pop('label')
scale = MinMaxScaler()
X_train = scale.fit_transform(X_train)
model = load_model('digit_recognizer_modeldef.h5')
def sketch_recognition(img):
# Implement sketch recognition model here...
# Return labels and confidences as dictionary
img = img.reshape((1, 784))
img = scale.transform(img.reshape(1, -1))
preds = model.predict(np.array(img).reshape((1, 28, 28, 1))).tolist()[0]
return {str(i): preds[i] for i in range(10)}
interface = gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs=gr.outputs.Label(), theme='darkdefault',
title='DIGIT RECOGNIZER', description='Ecrire un chiffre entre 0 et 9 et cliquer sur "Submit". Le modèle retourne la probabilité prédite pour chaque chiffre').launch(share=True) |