saadul commited on
Commit
f30814b
1 Parent(s): 627887f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -42
app.py CHANGED
@@ -1,55 +1,17 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Model path
5
- model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetuned"
6
 
7
- # Set Streamlit page config
8
  st.set_page_config(page_title="Sentiment Analysis App")
9
 
10
- # Load sentiment analysis model
11
  sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
12
 
13
- # Title and user input
14
  st.title("Sentiment Analysis App")
 
15
  user_input = st.text_area("Enter a message:")
16
 
17
- # Function to add CSS style and icons
18
- def custom_css():
19
- st.markdown(
20
- """
21
- <style>
22
- /* Add some custom CSS */
23
- .btn {
24
- background-color: #008CBA;
25
- color: white;
26
- padding: 8px 20px;
27
- text-align: center;
28
- text-decoration: none;
29
- display: inline-block;
30
- font-size: 16px;
31
- margin: 4px 2px;
32
- transition-duration: 0.4s;
33
- cursor: pointer;
34
- border-radius: 8px;
35
- }
36
- /* Add an icon to the button */
37
- .icon {
38
- display: inline-block;
39
- vertical-align: middle;
40
- width: 20px;
41
- height: 20px;
42
- margin-right: 5px;
43
- }
44
- </style>
45
- """,
46
- unsafe_allow_html=True,
47
- )
48
-
49
- # Render the custom CSS
50
- custom_css()
51
-
52
- # Analyze sentiment button
53
  if st.button("Analyze Sentiment"):
54
  if user_input:
55
  # Perform sentiment analysis
@@ -58,4 +20,4 @@ if st.button("Analyze Sentiment"):
58
  sentiment_score = results[0]["score"]
59
 
60
  st.write(f"Sentiment: {sentiment_label}")
61
- st.write(f"Confidence Score: {sentiment_score:.2f}")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned"
 
5
 
 
6
  st.set_page_config(page_title="Sentiment Analysis App")
7
 
8
+
9
  sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path)
10
 
 
11
  st.title("Sentiment Analysis App")
12
+
13
  user_input = st.text_area("Enter a message:")
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  if st.button("Analyze Sentiment"):
16
  if user_input:
17
  # Perform sentiment analysis
 
20
  sentiment_score = results[0]["score"]
21
 
22
  st.write(f"Sentiment: {sentiment_label}")
23
+ st.write(f"Confidence Score: {sentiment_score:.2f}")