tmt3103 commited on
Commit
ae2a2c7
·
1 Parent(s): 03adbbe

update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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="Enter text for Classification", placeholder="Type your text here..."),
41
- outputs=[gr.Textbox(label="Sentiment Output"), gr.Textbox(label="Topic Output")],
42
- title="Vietnamese students Feedback Corpus Classifier",
43
- description="Classify the sentiment and topic of a given text into separate outputs."
 
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=" 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 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