Spaces:
Sleeping
Sleeping
Luciferalive
commited on
Commit
•
25ba03e
1
Parent(s):
4297311
Update app.py
Browse files
app.py
CHANGED
@@ -11,30 +11,26 @@ 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 |
-
for
|
21 |
-
|
22 |
-
|
23 |
-
outputs.append(gr.Meter(value=score))
|
24 |
|
25 |
-
return
|
26 |
|
27 |
# Create Gradio interface
|
28 |
feedback_textbox = gr.Textbox(label="Enter your feedback:")
|
29 |
-
feedback_output =
|
30 |
|
31 |
-
|
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 |
-
|
38 |
-
)
|
39 |
-
|
40 |
-
iface.launch()
|
|
|
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 |
+
# Generate HTML content for displaying the scores as meters/progress bars
|
19 |
+
html_content = ""
|
20 |
+
for i in range(len(top_labels)):
|
21 |
+
score_percentage = scores[i] * 100 # Convert score to percentage
|
22 |
+
html_content += f"<div><b>{top_labels[i]}:</b> {scores[i]:.2f} <div style='background-color: #e0e0e0; border-radius: 10px;'><div style='height: 24px; width: {score_percentage}%; background-color: #76b900; border-radius: 10px;'></div></div></div>"
|
|
|
23 |
|
24 |
+
return html_content
|
25 |
|
26 |
# Create Gradio interface
|
27 |
feedback_textbox = gr.Textbox(label="Enter your feedback:")
|
28 |
+
feedback_output = gr.HTML(label="Top 2 Labels with Scores:")
|
29 |
|
30 |
+
gr.Interface(
|
31 |
fn=classify_feedback,
|
32 |
inputs=feedback_textbox,
|
33 |
outputs=feedback_output,
|
34 |
title="Feedback Classifier",
|
35 |
+
description="Enter your feedback and get the top 2 associated labels with scores."
|
36 |
+
).launch()
|
|
|
|
|
|