lohedman commited on
Commit
af58218
·
1 Parent(s): 279936d

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -1,7 +1,23 @@
1
- import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hellos " + name + "!!"
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
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)