gzcui163 commited on
Commit
f7252d6
·
1 Parent(s): f6005a6

update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -1,7 +1,18 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ learn = load_learner('model.pkl')
5
+ labels = learn.dls.vocab
6
+ def predict(img):
7
+ img = PILImage.create(img)
8
+ pred,pred_idx,probs = learn.predict(img)
9
+ return dict(zip(labels, map(float, probs)))
10
 
11
+ title = "Lion Tiger Classifier"
12
+ examples = ['lion.jpg', 'tiger.jpg', 'tigon.jpg', 'liger']
13
+ demo = gr.Interface(fn=predict,
14
+ inputs=gr.Image('lion.jpg'),
15
+ outputs=gr.Label(),
16
+ title=title,
17
+ examples=examples)
18
+ demo.launch(inline=False, show_error=True)