faishaltm commited on
Commit
204fd70
·
1 Parent(s): 14c8518

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ # def is_cat(x): return x[0].isupper()
5
+
6
+ import pathlib
7
+ temp = pathlib.PosixPath
8
+ pathlib.PosixPath = pathlib.WindowsPath
9
+
10
+ learn = load_learner('export.pkl')
11
+
12
+ categories = ('black', 'grizzly', 'teddy')
13
+
14
+ def classify_image(img):
15
+ pred, idx, probs = learn.predict(img)
16
+ return dict(zip(categories, map(float, probs)))
17
+
18
+ image = gr.components.Image(type="pil", height=192, width=192)
19
+ label = gr.Label()
20
+ examples = ['bear.jpg', 'cat.jpg', 'dog.jpg']
21
+
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch(inline=False)