dsatya commited on
Commit
255aa74
1 Parent(s): 880a86b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -3,15 +3,17 @@ import gradio as gr
3
 
4
  def is_cat(x): return x[0].isupper()
5
 
 
 
 
 
6
  def predict(img):
7
- img = PILImage.create(img)
8
  pred,pred_idx,probs = learn.predict(img)
9
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
10
 
11
- learn = load_learner('model.pkl')
12
- labels = learn.dls.vocab
13
 
14
- input = gr.inputs.Image(shape=(512, 512))
15
- output = gr.outputs.Label(num_top_classes=3)
 
16
 
17
- gr.Interface(fn=predict, inputs=input, outputs=output).launch(share=True)
 
3
 
4
  def is_cat(x): return x[0].isupper()
5
 
6
+ categories = ('Dog', 'Cat')
7
+
8
+ learn = load_learner('model.pkl')
9
+
10
  def predict(img):
 
11
  pred,pred_idx,probs = learn.predict(img)
12
+ return dict(zip(categories,map(float,probs)))
13
 
 
 
14
 
15
+ input = gr.inputs.Image(shape=(192, 192))
16
+ output = gr.outputs.Label()
17
+
18
 
19
+ gr.Interface(fn=predict, inputs=input, outputs=output).launch(share=False)