Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,20 +11,30 @@ def classify_feedback(feedback_text):
|
|
11 |
labels = ["Value", "Facilities", "Experience", "Functionality", "Quality"]
|
12 |
result = classifier(feedback_text, labels, multi_label=True)
|
13 |
|
14 |
-
# Get the top two labels associated with the feedback
|
15 |
top_labels = result["labels"][:2]
|
16 |
scores = result["scores"][:2]
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Create Gradio interface
|
21 |
feedback_textbox = gr.Textbox(label="Enter your feedback:")
|
22 |
-
feedback_output = gr.
|
23 |
|
24 |
-
gr.Interface(
|
25 |
fn=classify_feedback,
|
26 |
inputs=feedback_textbox,
|
27 |
outputs=feedback_output,
|
28 |
title="Feedback Classifier",
|
29 |
-
description="Enter your feedback and get the top 2 associated labels with scores."
|
30 |
-
|
|
|
|
|
|
|
|
11 |
labels = ["Value", "Facilities", "Experience", "Functionality", "Quality"]
|
12 |
result = classifier(feedback_text, labels, multi_label=True)
|
13 |
|
14 |
+
# Get the top two labels associated with the feedback and their scores
|
15 |
top_labels = result["labels"][:2]
|
16 |
scores = result["scores"][:2]
|
17 |
|
18 |
+
# Prepare the outputs to display both labels and their corresponding meters
|
19 |
+
outputs = []
|
20 |
+
for label, score in zip(top_labels, scores):
|
21 |
+
label_with_score = f"{label}: {score:.2f}"
|
22 |
+
outputs.append(gr.Label(label_with_score))
|
23 |
+
outputs.append(gr.Meter(value=score))
|
24 |
+
|
25 |
+
return outputs
|
26 |
|
27 |
# Create Gradio interface
|
28 |
feedback_textbox = gr.Textbox(label="Enter your feedback:")
|
29 |
+
feedback_output = [gr.Label(), gr.Meter(), gr.Label(), gr.Meter()] # Output placeholders for two labels and meters
|
30 |
|
31 |
+
iface = gr.Interface(
|
32 |
fn=classify_feedback,
|
33 |
inputs=feedback_textbox,
|
34 |
outputs=feedback_output,
|
35 |
title="Feedback Classifier",
|
36 |
+
description="Enter your feedback and get the top 2 associated labels with scores.",
|
37 |
+
layout="vertical"
|
38 |
+
)
|
39 |
+
|
40 |
+
iface.launch()
|