app update
Browse files
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 |
-
|
25 |
-
|
26 |
-
|
27 |
-
return top_5_labels
|
28 |
|
29 |
# Create a Gradio interface
|
30 |
iface = gr.Interface(
|
31 |
fn=predict_text,
|
32 |
inputs="text",
|
33 |
-
outputs=
|
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 |
+
|