Spaces:
Runtime error
Runtime error
File size: 949 Bytes
050cd50 96d6848 73f4af1 050cd50 73f4af1 86de679 61b77d9 86de679 050cd50 cbd2841 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from huggingface_hub import from_pretrained_keras
import gradio as gr
import numpy as np
import tensorflow
model = from_pretrained_keras("merve/riddikulus")
labels = {0:"Ravenclaw π¦
π ", 1:"Gryffindor π¦", 2:"Ravenclaw π¦
π",3:"Slytherinππ",
4:"Hufflepuff π¦‘π", 9:"Death eater detected! ", 6: "Hufflepuff π¦‘π", 7:"Slytherinππ",
8:"Ravenclaw π¦
π", 5:"Gryffindor π¦"}
canvas = gr.inputs.Image(source="canvas", shape=(28,28))
text = gr.outputs.Textbox()
def infer(image):
cls = np.argmax(model.predict(np.expand_dims(image, axis = 0)[:,:,:,1]))
if cls == 9:
output = "Death eater detected! π"
else:
cls = labels[cls]
output = f"Welcome to {cls}"
return output
gr.Interface(infer, inputs=[canvas], outputs=[text], title="Welcome to Hogwarts Sorting Hat!", description="Draw something and let the sorting hat sort you! π© ").launch() |