Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
! [ -e /content ] && pip install -Uqq fastbook
|
2 |
+
import fastbook
|
3 |
+
fastbook.setup_book()
|
4 |
+
|
5 |
+
from fastbook import *
|
6 |
+
from fastai.vision.widgets import *
|
7 |
+
|
8 |
+
path = Path()
|
9 |
+
path.ls(file_exts='.pkl')
|
10 |
+
|
11 |
+
learn_inf = load_learner(path/'export.pkl')
|
12 |
+
|
13 |
+
categories = ('grizzly', 'black', 'teddy')
|
14 |
+
|
15 |
+
def classify_image(img):
|
16 |
+
pred,idx,probs = learn_inf.predict(img)
|
17 |
+
return dict(zip(categories, map(float,probs)))
|
18 |
+
|
19 |
+
image = gr.inputs.Image(shape=(192,192))
|
20 |
+
label = gr.outputs.Label()
|
21 |
+
examples = ['bear.jpg']
|
22 |
+
|
23 |
+
intf = gr.Interface(fn = classify_image, inputs=image, outputs=label, examples=examples)
|
24 |
+
intf.launch(inline=False)
|