Spaces:
Running
Running
lohedman
commited on
Commit
·
af58218
1
Parent(s):
279936d
updated app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr #pip install gradio==3.50
|
3 |
+
import pathlib
|
4 |
+
temp = pathlib.PosixPath
|
5 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
6 |
|
7 |
+
#im = PILImage.create('grizzly.jpg')
|
8 |
+
learn = load_learner('export.pkl')
|
9 |
+
#print(learn.predict(im))
|
10 |
+
categories = ('grizzly', 'black', 'teddy')
|
11 |
|
12 |
+
def classify_image(img):
|
13 |
+
pred, idx, probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float,probs)))
|
15 |
+
|
16 |
+
#print(classify_image(im))
|
17 |
+
|
18 |
+
image = gr.inputs.Image(shape=(192,192))
|
19 |
+
label = gr.outputs.Label()
|
20 |
+
examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg', 'dunno.jpg']
|
21 |
+
|
22 |
+
inft = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
inft.launch(inline=False)
|