Spaces:
Runtime error
Runtime error
Commit
·
e27972a
1
Parent(s):
afa25e8
Update app.py
Browse files
app.py
CHANGED
@@ -1,74 +1,3 @@
|
|
1 |
-
# import streamlit as st
|
2 |
-
# import transformers
|
3 |
-
# import torch
|
4 |
-
|
5 |
-
# # Load the model and tokenizer
|
6 |
-
# model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/twitter-xlm-roberta-base-sentiment_dee")
|
7 |
-
# tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/twitter-xlm-roberta-base-sentiment_dee")
|
8 |
-
|
9 |
-
# # Define the function for sentiment analysis
|
10 |
-
# @st.cache_resource
|
11 |
-
# def predict_sentiment(text):
|
12 |
-
# # Load the pipeline.
|
13 |
-
# pipeline = transformers.pipeline("sentiment-analysis")
|
14 |
-
|
15 |
-
# # Predict the sentiment.
|
16 |
-
# prediction = pipeline(text)
|
17 |
-
# sentiment = prediction[0]["label"]
|
18 |
-
# score = prediction[0]["score"]
|
19 |
-
|
20 |
-
# return sentiment, score
|
21 |
-
|
22 |
-
# # Setting the page configurations
|
23 |
-
# st.set_page_config(
|
24 |
-
# page_title="Sentiment Analysis App",
|
25 |
-
# page_icon=":smile:",
|
26 |
-
# layout="wide",
|
27 |
-
# initial_sidebar_state="auto",
|
28 |
-
# )
|
29 |
-
|
30 |
-
# # Add description and title
|
31 |
-
# st.write("""
|
32 |
-
# # Predict if your text is Positive, Negative or Nuetral ...
|
33 |
-
# Please type your text and press ENTER key to know if your text is positive, negative, or neutral sentiment!
|
34 |
-
# """)
|
35 |
-
|
36 |
-
|
37 |
-
# # Add image
|
38 |
-
# image = st.image("sentiment.jpeg", width=400)
|
39 |
-
|
40 |
-
# # Get user input
|
41 |
-
# text = st.text_input("Type here:")
|
42 |
-
|
43 |
-
# # Define the CSS style for the app
|
44 |
-
# st.markdown(
|
45 |
-
# """
|
46 |
-
# <style>
|
47 |
-
# body {
|
48 |
-
# background-color: #f5f5f5;
|
49 |
-
# }
|
50 |
-
# h1 {
|
51 |
-
# color: #4e79a7;
|
52 |
-
# }
|
53 |
-
# </style>
|
54 |
-
# """,
|
55 |
-
# unsafe_allow_html=True
|
56 |
-
# )
|
57 |
-
|
58 |
-
# # Show sentiment output
|
59 |
-
# if text:
|
60 |
-
# sentiment, score = predict_sentiment(text)
|
61 |
-
# if sentiment == "Positive":
|
62 |
-
# st.success(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
63 |
-
# elif sentiment == "Negative":
|
64 |
-
# st.error(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
65 |
-
# else:
|
66 |
-
# st.warning(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
import streamlit as st
|
73 |
import transformers
|
74 |
import torch
|
@@ -141,3 +70,77 @@ if predict_button and text:
|
|
141 |
st.warning(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
142 |
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import transformers
|
3 |
import torch
|
|
|
70 |
st.warning(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
71 |
|
72 |
|
73 |
+
|
74 |
+
|
75 |
+
# import streamlit as st
|
76 |
+
# import transformers
|
77 |
+
# import torch
|
78 |
+
|
79 |
+
# # Load the model and tokenizer
|
80 |
+
# model = transformers.AutoModelForSequenceClassification.from_pretrained("DeeeTeeee01/twitter-xlm-roberta-base-sentiment_dee")
|
81 |
+
# tokenizer = transformers.AutoTokenizer.from_pretrained("DeeeTeeee01/twitter-xlm-roberta-base-sentiment_dee")
|
82 |
+
|
83 |
+
# # Define the function for sentiment analysis
|
84 |
+
# @st.cache_resource
|
85 |
+
# def predict_sentiment(text):
|
86 |
+
# # Load the pipeline.
|
87 |
+
# pipeline = transformers.pipeline("sentiment-analysis")
|
88 |
+
|
89 |
+
# # Predict the sentiment.
|
90 |
+
# prediction = pipeline(text)
|
91 |
+
# sentiment = prediction[0]["label"]
|
92 |
+
# score = prediction[0]["score"]
|
93 |
+
|
94 |
+
# return sentiment, score
|
95 |
+
|
96 |
+
# # Setting the page configurations
|
97 |
+
# st.set_page_config(
|
98 |
+
# page_title="Sentiment Analysis App",
|
99 |
+
# page_icon=":smile:",
|
100 |
+
# layout="wide",
|
101 |
+
# initial_sidebar_state="auto",
|
102 |
+
# )
|
103 |
+
|
104 |
+
# # Add description and title
|
105 |
+
# st.write("""
|
106 |
+
# # Predict if your text is Positive, Negative or Nuetral ...
|
107 |
+
# Please type your text and press ENTER key to know if your text is positive, negative, or neutral sentiment!
|
108 |
+
# """)
|
109 |
+
|
110 |
+
|
111 |
+
# # Add image
|
112 |
+
# image = st.image("sentiment.jpeg", width=400)
|
113 |
+
|
114 |
+
# # Get user input
|
115 |
+
# text = st.text_input("Type here:")
|
116 |
+
|
117 |
+
# # Define the CSS style for the app
|
118 |
+
# st.markdown(
|
119 |
+
# """
|
120 |
+
# <style>
|
121 |
+
# body {
|
122 |
+
# background-color: #f5f5f5;
|
123 |
+
# }
|
124 |
+
# h1 {
|
125 |
+
# color: #4e79a7;
|
126 |
+
# }
|
127 |
+
# </style>
|
128 |
+
# """,
|
129 |
+
# unsafe_allow_html=True
|
130 |
+
# )
|
131 |
+
|
132 |
+
# # Show sentiment output
|
133 |
+
# if text:
|
134 |
+
# sentiment, score = predict_sentiment(text)
|
135 |
+
# if sentiment == "Positive":
|
136 |
+
# st.success(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
137 |
+
# elif sentiment == "Negative":
|
138 |
+
# st.error(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
139 |
+
# else:
|
140 |
+
# st.warning(f"The sentiment is {sentiment} with a score of {score*100:.2f}%!")
|
141 |
+
|
142 |
+
|
143 |
+
|
144 |
+
|
145 |
+
|
146 |
+
|