vumichien commited on
Commit
93ed2e5
1 Parent(s): f8393d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -22,7 +22,8 @@ learner = from_pretrained_fastai(repo_id)
22
 
23
  def inference(image):
24
  label_predict,_,probs = learner.predict(image)
25
- return f"This rice image is {label_predict} with {100*probs[torch.argmax(probs)].item():.2f}% probability"
 
26
 
27
  gr.Interface(
28
  fn=inference,
@@ -30,7 +31,7 @@ gr.Interface(
30
  description = "Predict which type of rice belong to Arborio, Basmati, Ipsala, Jasmine, Karacadag",
31
  inputs="image",
32
  examples=examples,
33
- outputs=gr.Textbox(label='Prediction'),
34
  cache_examples=False,
35
  article = "Author: <a href=\"https://www.linkedin.com/in/vumichien/\">Vu Minh Chien</a>",
36
  ).launch(debug=True, enable_queue=True)
 
22
 
23
  def inference(image):
24
  label_predict,_,probs = learner.predict(image)
25
+ labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
26
+ return labels_probs
27
 
28
  gr.Interface(
29
  fn=inference,
 
31
  description = "Predict which type of rice belong to Arborio, Basmati, Ipsala, Jasmine, Karacadag",
32
  inputs="image",
33
  examples=examples,
34
+ output=gr.outputs.Label(num_top_classes=5, label='Prediction'),
35
  cache_examples=False,
36
  article = "Author: <a href=\"https://www.linkedin.com/in/vumichien/\">Vu Minh Chien</a>",
37
  ).launch(debug=True, enable_queue=True)