sanjid commited on
Commit
4101cf5
·
1 Parent(s): 632b770

app update

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -21,19 +21,19 @@ 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_probs = prediction['probs']
25
- top_5_indices = predicted_probs.argsort(descending=True)[:5]
26
- top_5_labels = [list(class_label_mapping.keys())[list(class_label_mapping.values()).index(idx)] for idx in top_5_indices]
27
- return top_5_labels
28
 
29
  # Create a Gradio interface
30
  iface = gr.Interface(
31
  fn=predict_text,
32
  inputs="text",
33
- outputs=gr.outputs.Label(num_top_classes=5),
34
  title="Food Origin Classification App",
35
  description="Enter a Recipe, and it will predict the class label.",
36
  )
37
 
38
  # Start the Gradio app
39
  iface.launch()
 
 
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
  )
36
 
37
  # Start the Gradio app
38
  iface.launch()
39
+