Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ def predict_topic(text):
|
|
| 25 |
encoding = tokenizer_topic(text, return_tensors='pt', truncation=True, padding=True, max_length=128)
|
| 26 |
output = model_topic(**encoding)
|
| 27 |
pred = torch.argmax(output.logits, dim=1).item()
|
| 28 |
-
topic_labels = ["Giảng viên", "Chương trình đào tạo", "Cơ sở vật chất", "Khác"]
|
| 29 |
return topic_labels[pred] # Trả về nhãn chủ đề
|
| 30 |
|
| 31 |
# Define a function to handle both predictions at once
|
|
@@ -37,10 +37,11 @@ def classify_sentiment_and_topic(text):
|
|
| 37 |
# Create Gradio Interface
|
| 38 |
iface = gr.Interface(
|
| 39 |
fn=classify_sentiment_and_topic,
|
| 40 |
-
inputs=gr.Textbox(label="
|
| 41 |
-
outputs=[gr.Textbox(label="
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
)
|
| 45 |
|
| 46 |
# Launch the app
|
|
|
|
| 25 |
encoding = tokenizer_topic(text, return_tensors='pt', truncation=True, padding=True, max_length=128)
|
| 26 |
output = model_topic(**encoding)
|
| 27 |
pred = torch.argmax(output.logits, dim=1).item()
|
| 28 |
+
topic_labels = ["Giảng viên", "Chương trình đào tạo", "Cơ sở vật chất", "Khác"]
|
| 29 |
return topic_labels[pred] # Trả về nhãn chủ đề
|
| 30 |
|
| 31 |
# Define a function to handle both predictions at once
|
|
|
|
| 37 |
# Create Gradio Interface
|
| 38 |
iface = gr.Interface(
|
| 39 |
fn=classify_sentiment_and_topic,
|
| 40 |
+
inputs=gr.Textbox(label="Nhập văn bản để phân loại", placeholder="Gõ văn bản của bạn ở đây..."),
|
| 41 |
+
outputs=[gr.Textbox(label="Kết quả phân loại cảm xúc"), gr.Textbox(label="Kết quả phân loại chủ đề")],
|
| 42 |
+
layout="vertical", # Thiết lập layout theo chiều dọc
|
| 43 |
+
title="Phân loại cảm xúc và chủ đề",
|
| 44 |
+
description="Phân loại cảm xúc (Tiêu cực, Trung lập, Tích cực) và chủ đề (Giảng viên, Chương trình đào tạo, Cơ sở vật chất, Khác) của văn bản."
|
| 45 |
)
|
| 46 |
|
| 47 |
# Launch the app
|