Krittiya commited on
Commit
519572a
·
1 Parent(s): 4ec6131

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +26 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline, AutoTokenizer
3
+
4
+ model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
5
+ sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
6
+
7
+ model_name = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+
10
+ def main():
11
+ st.title("Twitter Sentiment Analysis")
12
+
13
+ with st.form("text_field"):
14
+ text = st.text_area('Enter some text:')
15
+ # clicked == True เมื่อปุ่มถูกคลิก
16
+ clicked = st.form_submit_button("Analyze Sentiment")
17
+
18
+ if clicked:
19
+ # วิเคราะห์ความรู้สึกของข้อความ
20
+ results = sentiment_classifier(text)
21
+ st.write("Sentiment Analysis Results:")
22
+ for result in results:
23
+ st.write(f"Label: {result['label']}, Score: {result['score']:.4f}")
24
+
25
+ if __name__ == "__main__":
26
+ main()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ altair<5