Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
learner = load_learner('anime_classifier.pkl')
|
6 |
+
categories = anime_characters = ['Jotaro Kujo', 'Princess Mononoke', 'Enrico Pucci', 'Dio Brando', 'Totoro', 'Madara Uchiha', 'Hatsune Miku']
|
7 |
+
|
8 |
+
def classify_anime(img):
|
9 |
+
prediction, index, probability = learner.predict(img)
|
10 |
+
return dict(zip(categories, map(float, probability)))
|
11 |
+
|
12 |
+
intf = gr.Interface(fn=classify_anime,
|
13 |
+
inputs=gr.Image(shape=(192, 192)),
|
14 |
+
outputs=gr.Label(),
|
15 |
+
title="Which Anime Character?!",
|
16 |
+
description="This model very accurately can tell you if a image you input is one of the characters it knows well: Jotaro Kujo, Princess Mononoke, Enrico Pucci, Dio Brando, Totoro, Madara Uchiha, and 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 was a part of my homeschool curriculum for my children, so the character choices are biased. My two were Totoro and Princess Mononoke.)",
|
17 |
+
examples=['dio.jpg', 'jotaro.jpg', 'madara.jpg', 'miku.jpg', 'mononoke.jpg', 'pucci.jpg', 'totoro.jpg'])
|
18 |
+
intf.launch(inline=False)
|
19 |
+
|