Spaces:
Runtime error
Runtime error
| 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 π¦‘π", 5:"Death eater detected! ", 6: "Hufflepuff π¦‘π", 7:"Slytherinππ", | |
| 8:"Ravenclaw π¦ π", 9:"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() |