MasleK commited on
Commit
3137728
·
1 Parent(s): 9bf0489

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -12,12 +12,13 @@ def dummy():
12
  return "ABC"
13
 
14
  def predict(image):
15
- predictions = learner.predict(image)
16
- return {p["label"]: p["score"] for p in predictions}
 
17
 
18
  gr.Interface(
19
  predict,
20
  inputs=gr.inputs.Image(label="candidate", type="filepath"),
21
- outputs=dummy,
22
  title="Snail? Snake? Slug?",
23
  ).launch()
 
12
  return "ABC"
13
 
14
  def predict(image):
15
+ label, index, scores = learner.predict(image)
16
+
17
+ return {l: scores[i].item() for i,l in enumerate(learner.dls.vocab)}
18
 
19
  gr.Interface(
20
  predict,
21
  inputs=gr.inputs.Image(label="candidate", type="filepath"),
22
+ outputs=gr.outputs.Label(num_top_classes=3),
23
  title="Snail? Snake? Slug?",
24
  ).launch()