sylwia malinowska commited on
Commit
2f3d61d
1 Parent(s): fc2db54
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -5,16 +5,19 @@ learn = load_learner('cat.pkl')
5
  labels = learn.dls.vocab
6
 
7
 
8
- def predict(img):
9
  img = PILImage.create(img)
10
  pred, pred_idx, probs = learn.predict(img)
11
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
13
 
 
 
 
14
  examples = ['british-shorthair.jpg',
15
  'maine-coon.jpg', 'european-shorthair.jpg']
16
 
17
- gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(300, 300)),
18
- outputs=gr.outputs.Label(num_top_classes=3), examples=examples).launch()
19
 
20
- iface.launch(inline=False)
 
5
  labels = learn.dls.vocab
6
 
7
 
8
+ def classify_image(img):
9
  img = PILImage.create(img)
10
  pred, pred_idx, probs = learn.predict(img)
11
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
13
 
14
+ images = gr.inputs.Image(shape=(300, 300))
15
+ outputs = gr.outputs.Label(num_top_classes=3)
16
+
17
  examples = ['british-shorthair.jpg',
18
  'maine-coon.jpg', 'european-shorthair.jpg']
19
 
20
+ interface = gr.Interface(fn=classify_image, inputs=images,
21
+ outputs=outputs, examples=examples)
22
 
23
+ interface.launch(inline=False)