Spaces:
Sleeping
Sleeping
Commit
·
5197ecd
1
Parent(s):
b5e7413
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
from fastai.vision.all import *
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
learn = load_learner('export.pkl')
|
7 |
+
|
8 |
+
categories = ('black', 'grizzly', 'teddy')
|
9 |
+
def classify_image(img):
|
10 |
+
pred, idx, probs = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probs)))
|
12 |
+
|
13 |
+
image=gr.Image(height = 192, width = 192)
|
14 |
+
label = gr.Label()
|
15 |
+
examples = ['Grizzly_bear_example.jpeg','black_bear.jpg',
|
16 |
+
'teddy_bear.jpeg']
|
17 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
18 |
+
intf.launch(inline=False)
|