Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from keras.datasets import mnist | |
| from keras.models import Sequential | |
| from keras.layers import Conv2D,MaxPooling2D,Dense,Flatten,Dropout | |
| from tensorflow import keras | |
| import cv2 | |
| model2 = keras.models.load_model("final_model.h5") | |
| def sketch_recognition(test_img): | |
| test_img = test_img/255 | |
| test_img = cv2.resize(test_img,(28,28)) | |
| test_input = test_img.reshape((1,28,28,1)) | |
| label = [x for x in range(10)] | |
| prediction = model2.predict(test_input)[0] | |
| confidences = {label[i]:float(prediction[i]) for i in range(10)} | |
| return confidences | |
| gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs=gr.outputs.Label(num_top_classes=3)).launch() | |