Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def wild_animal_classifier(x):
|
5 |
+
return x[0].isupper()
|
6 |
+
|
7 |
+
learn = load_learner('export.pkl')
|
8 |
+
|
9 |
+
categories = ('Puma', 'Tiger', 'Lion')
|
10 |
+
|
11 |
+
def classify_image(img):
|
12 |
+
pred, idx, probs = learn.predict(img)
|
13 |
+
return dict(zip(categories, map(float, probs)))
|
14 |
+
|
15 |
+
image = gr.inputs.Image(shape=(192, 192))
|
16 |
+
label = gr.outputs.Label()
|
17 |
+
examples = ['puma.jpg', 'tiger.jpg', 'lion.jpg']
|
18 |
+
|
19 |
+
intf = gr.Interface(fn=classify_image, inputs=imgae, outputs=label, examples=examples)
|
20 |
+
intf.launch(inline=False)
|