Spaces:
Runtime error
Runtime error
Commit
·
c187c6a
1
Parent(s):
d3a958b
Application
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastbook import *
|
| 2 |
+
import gradio.components as gr
|
| 3 |
+
import gradio
|
| 4 |
+
|
| 5 |
+
model = load_learner('model.pkl')
|
| 6 |
+
|
| 7 |
+
categories = ("Egyptian Mau", "Persian Cat", "Sphynx Cat")
|
| 8 |
+
|
| 9 |
+
def classify(im):
|
| 10 |
+
cat, idx, probs = model.predict(im)
|
| 11 |
+
return dict(zip(categories, map(float, probs)))
|
| 12 |
+
|
| 13 |
+
img = gr.Image()
|
| 14 |
+
label = gr.Label()
|
| 15 |
+
examples = ["persian.jpg", "egypian.jpg", "sphynix.jpg"]
|
| 16 |
+
|
| 17 |
+
intr = gradio.Interface(fn=classify, inputs=img, outputs=label)
|
| 18 |
+
intr.launch(inline=False)
|