vumichien commited on
Commit
3933122
1 Parent(s): 4306b36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -14,16 +14,18 @@ def get_x(r):
14
  return path/r["fname"]
15
 
16
  learner = from_pretrained_fastai(repo_id)
 
17
 
18
  def inference(image):
19
  label_predict,_,probs = learner.predict(image)
20
- return f"This grapevine leave is {label_predict} with {100*probs[torch.argmax(probs)].item():.2f}% probability"
 
21
 
22
  gr.Interface(
23
  fn=inference,
24
  title="Grapevine leave image classification",
25
  description = "Predict which type of grapevine leave belong to Ak, Ala_Idris, Buzgulu, Dimnit, Nazli",
26
- inputs="image",
27
  examples=examples,
28
  outputs=gr.Textbox(label='Prediction'),
29
  cache_examples=False,
 
14
  return path/r["fname"]
15
 
16
  learner = from_pretrained_fastai(repo_id)
17
+ labels = learner.dls.vocab
18
 
19
  def inference(image):
20
  label_predict,_,probs = learner.predict(image)
21
+ labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
22
+ return labels_probs
23
 
24
  gr.Interface(
25
  fn=inference,
26
  title="Grapevine leave image classification",
27
  description = "Predict which type of grapevine leave belong to Ak, Ala_Idris, Buzgulu, Dimnit, Nazli",
28
+ inputs=output = gr.outputs.Label(num_top_classes=3),
29
  examples=examples,
30
  outputs=gr.Textbox(label='Prediction'),
31
  cache_examples=False,