Spaces:
Runtime error
Runtime error
Anders
commited on
Commit
·
7287d12
1
Parent(s):
1a6178a
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
learn = load_learner("model.pkl")
|
| 5 |
+
|
| 6 |
+
categories = ("Dog", "Cat")
|
| 7 |
+
|
| 8 |
+
def image_classifier(im):
|
| 9 |
+
pred, idx, probs = learn.predict(im)
|
| 10 |
+
return dict(zip(categories, map(float, probs)))
|
| 11 |
+
|
| 12 |
+
input = gr.inputs.Image(shape=(192, 192))
|
| 13 |
+
output = gr.outputs.Label()
|
| 14 |
+
examples = ["dog1.jpeg", "dog2.jpeg", "cat.jpeg"]
|
| 15 |
+
|
| 16 |
+
interface = gr.Interface(fn=image_classifier, inputs=input, outputs=output, examples=examples)
|
| 17 |
+
interface.launch()
|