sanjid commited on
Commit
6e02710
·
1 Parent(s): 4101cf5
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -21,15 +21,16 @@ class_label_mapping = {label: idx for idx, label in enumerate(learner_inf.dls.vo
21
  # Define a function to make predictions
22
  def predict_text(text):
23
  prediction = learner_inf.blurr_predict(text)[0]
24
- predicted_class_index = prediction['class_index']
25
- predicted_class_label = list(class_label_mapping.keys())[list(class_label_mapping.values()).index(predicted_class_index)]
26
- return predicted_class_label
 
27
 
28
  # Create a Gradio interface
29
  iface = gr.Interface(
30
  fn=predict_text,
31
  inputs="text",
32
- outputs="text",
33
  title="Food Origin Classification App",
34
  description="Enter a Recipe, and it will predict the class label.",
35
  )
 
21
  # Define a function to make predictions
22
  def predict_text(text):
23
  prediction = learner_inf.blurr_predict(text)[0]
24
+ predicted_probs = prediction['scores']
25
+ predicted_labels = prediction['class_labels']
26
+ result = {label: f"{prob*100:.2f}%" for label, prob in zip(predicted_labels, predicted_probs)}
27
+ return result
28
 
29
  # Create a Gradio interface
30
  iface = gr.Interface(
31
  fn=predict_text,
32
  inputs="text",
33
+ outputs="label",
34
  title="Food Origin Classification App",
35
  description="Enter a Recipe, and it will predict the class label.",
36
  )