jaypinedabengco commited on
Commit
51fdae5
1 Parent(s): 9ae32a6
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -1,18 +1,13 @@
1
  import gradio as gr
2
- from fastai.vision.widgets import *
3
- # def greet(name):
4
- # return "Hello " + name + "!!"
5
- image = gr.inputs.Image(shape=(192, 192))
6
- label = gr.outputs.Label()
7
  examples = ['bear.jpeg']
8
 
9
- path = Path()
10
- learn = load_learner(path/'model.pkl')
11
 
12
  def classify_image(img):
13
- pred,pred_idx,probs = learn.predict(img)
14
- return {'Type': pred, 'Probability': f'{probs[pred_idx]:.04f}'}
15
-
16
 
17
- iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
18
  iface.launch(inline=False)
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+
 
 
 
4
  examples = ['bear.jpeg']
5
 
6
+ learn = load_learner('./model.pkl')
 
7
 
8
  def classify_image(img):
9
+ pred, pred_idx,probs = learn.predict(img)
10
+ return {k: '{:.04f}'.format(v) for k, v in zip(learn.dls.vocab, map(float, probs))}
 
11
 
12
+ iface = gr.Interface(fn=classify_image, inputs='image', outputs='label', examples=examples)
13
  iface.launch(inline=False)