Spaces:
Runtime error
Runtime error
App.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
|
5 |
+
learn = load_learner('model.pkl')
|
6 |
+
|
7 |
+
categories = ('Grizzly','Black','Toy','White','Brown')
|
8 |
+
|
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(sources="upload")
|
14 |
+
label = gr.Label()
|
15 |
+
examples = ['black.jpg','brown.jpg','grizzly.jpeg','toy.jpeg','./Imgs/white.jpg']
|
16 |
+
|
17 |
+
intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
|
18 |
+
intf.launch(inline=False,share=True)
|
19 |
+
|