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