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()