cmck commited on
Commit
a2f64c2
1 Parent(s): 45f891c

messing with gradio interfaces

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -2,9 +2,14 @@ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
  learn = load_learner('model.pkl')
 
5
 
6
- def is_cat(img):
7
- return 0
 
8
 
9
- iface = gr.Interface(fn=is_cat, inputs="text", outputs="text")
 
 
 
10
  iface.launch()
 
2
  import gradio as gr
3
 
4
  learn = load_learner('model.pkl')
5
+ categories = ('Cat', 'Dog')
6
 
7
+ def classify_image(img):
8
+ pred,idx,probs = learn.predict(img)
9
+ return dict(zip(categories, map(float,probs)))
10
 
11
+ iface = gr.Interface(fn=classify_image,
12
+ inputs=gr.inputs.Image(shape=(512, 512)),
13
+ outputs=gr.outputs.Label(num_top_classes=1),
14
+ title="Pet classifier")
15
  iface.launch()