File size: 1,198 Bytes
a8fa568
 
 
 
 
847e104
a8fa568
 
 
 
 
 
 
 
 
f8592b9
76ce456
a8fa568
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from fastai.vision.all import *
import gradio as gr


learner = load_learner('anime_classifier.pkl')
categories = anime_characters = ['Dio Brando', 'Enrico Pucci', 'Hatsune Miku', 'Jotaro Kujo', 'Madara Uchiha',  'Princess Mononoke', 'Totoro']

def classify_anime(img):
  prediction, index, probability = learner.predict(img)
  return dict(zip(categories, map(float, probability)))

intf = gr.Interface(fn=classify_anime,
             inputs=gr.Image(shape=(192, 192)),
             outputs=gr.Label(),
             title="Which Anime Character?!",
             description="This model very accurately can tell you if an image you input is one of the characters it knows well: Jotaro Kujo, Princess Mononoke, Enrico Pucci, Dio Brando, Totoro, Madara Uchiha, or Hatsune Miku. But what if you put in a photo of you? What about your cat? Did you always think he looked like Totoro? Find out if it is true! (This project is a part of my homeschool curriculum for my children, so the character choices are biased. My two were Totoro and Princess Mononoke.)",
             examples=['jotaro.jpg', 'dio.jpg', 'madara.jpg', 'miku.jpg', 'mononoke.jpg', 'pucci.jpg','totoro.jpg'])
intf.launch(inline=False)