Boaz commited on
Commit
b383b5d
·
1 Parent(s): f1dbc18

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner('export.pkl')
5
+
6
+ categories = ['alaskan malamute', 'gray wolf', 'siberian husky', 'swedish vallhund']
7
+
8
+ #|export
9
+
10
+ def classify_images(img):
11
+ pred,idx,probs = learn.predict(img)
12
+ return dict(zip(categories,map(float,probs)))
13
+
14
+
15
+ #|export
16
+
17
+ image = gr.inputs.Image(shape=(128,128))
18
+ label = gr.outputs.Label()
19
+ examples = ['siberian_jusky.jpg','alaskan_malmute.jpg','swedish_vallhund.jpg','gray_wolf.jpg']
20
+
21
+ #|export
22
+
23
+ intf = gr.Interface(fn=classify_images,inputs=image,outputs=label,examples=examples)
24
+ intf.launch(inline=False)
25
+