Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import from_pretrained_keras
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import numpy as np
|
| 4 |
+
import tensorflow
|
| 5 |
+
|
| 6 |
+
model = from_pretrained_keras("merve/riddikulus")
|
| 7 |
+
|
| 8 |
+
labels = {0:"ravenclaw", 1:"gryffindor", 2:"slytherin",3:"ravenclaw",
|
| 9 |
+
4:"ravenclaw", 5:"gryffindor", 6: "hufflepuff", 7:"ravenclaw",
|
| 10 |
+
8:"ravenclaw", 9:"slytherin"}
|
| 11 |
+
|
| 12 |
+
canvas = gr.inputs.Image(source="canvas", shape=(28,28))
|
| 13 |
+
text = gr.outputs.Textbox()
|
| 14 |
+
def infer(image):
|
| 15 |
+
cls = np.argmax(model.predict(np.expand_dims(image, axis = 0)[:,:,:,1]))
|
| 16 |
+
cls = labels[cls]
|
| 17 |
+
return f"Welcome to {cls}"
|
| 18 |
+
|
| 19 |
+
gr.Interface(infer, inputs=[canvas], outputs=[text]).launch(debug=True)
|