Spaces:
Sleeping
Sleeping
Overlord03
commited on
Commit
•
3e5a049
1
Parent(s):
0cd973d
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
#| export (creating a gradio interface)
|
3 |
+
from fastbook import *
|
4 |
+
from fastai.vision.widgets import *
|
5 |
+
from fastai.vision.all import *
|
6 |
+
|
7 |
+
learn = load_learner("bear_model.pkl")
|
8 |
+
categories = ('black', 'grizzly', 'teddy')
|
9 |
+
|
10 |
+
def classify_image(img):
|
11 |
+
pred,idx,probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
+
image = gr.inputs.Image(shape=(192, 192))
|
14 |
+
label = gr.outputs.Label()
|
15 |
+
# example images
|
16 |
+
examples = ['blackbear.jpg', 'teddybear.jpg', 'grizzlybear.jpg']
|
17 |
+
|
18 |
+
# define interface below
|
19 |
+
intf = gr.Interface(fn=classify_image, inputs = image, outputs = label, examples=examples)
|
20 |
+
intf.launch(inline=False)
|