Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,9 @@ import streamlit as st
|
|
5 |
import tweepy
|
6 |
from plotly.subplots import make_subplots
|
7 |
from transformers import pipeline
|
8 |
-
|
9 |
-
|
10 |
-
access_key
|
11 |
-
access_secret = "JDu1Rj4tj8kSilqawlH88LU8Y7nyu9GcbNZygNCpTk9kd"
|
12 |
-
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
|
13 |
-
auth.set_access_token(access_key,access_secret)
|
14 |
api = tweepy.API(auth)
|
15 |
|
16 |
|
@@ -60,14 +57,19 @@ def get_aggregation_period(df):
|
|
60 |
return "30D"
|
61 |
|
62 |
|
63 |
-
@st.
|
64 |
def load_model():
|
65 |
pipe = pipeline(task="sentiment-analysis", model="bhadresh-savani/distilbert-base-uncased-emotion")
|
66 |
return pipe
|
67 |
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
pipe = load_model()
|
70 |
-
twitter_handle = st.sidebar.text_input("Twitter handle:", "
|
71 |
twitter_count = st.sidebar.selectbox("Number of tweets:", (10, 100, 500, 1000, 3200))
|
72 |
|
73 |
|
@@ -130,4 +132,4 @@ if st.sidebar.button("Get tweets!"):
|
|
130 |
st.plotly_chart(fig)
|
131 |
|
132 |
# tweet sample
|
133 |
-
st.markdown(df.sample(n=5).to_markdown())
|
|
|
5 |
import tweepy
|
6 |
from plotly.subplots import make_subplots
|
7 |
from transformers import pipeline
|
8 |
+
|
9 |
+
auth = tweepy.OAuthHandler(st.secrets["consumer_key"], st.secrets["consumer_secret"])
|
10 |
+
auth.set_access_token(st.secrets["access_key"], st.secrets["access_secret"])
|
|
|
|
|
|
|
11 |
api = tweepy.API(auth)
|
12 |
|
13 |
|
|
|
57 |
return "30D"
|
58 |
|
59 |
|
60 |
+
@st.cache(allow_output_mutation=True)
|
61 |
def load_model():
|
62 |
pipe = pipeline(task="sentiment-analysis", model="bhadresh-savani/distilbert-base-uncased-emotion")
|
63 |
return pipe
|
64 |
|
65 |
|
66 |
+
"""
|
67 |
+
# Twitter Emotion Analyser
|
68 |
+
"""
|
69 |
+
|
70 |
+
|
71 |
pipe = load_model()
|
72 |
+
twitter_handle = st.sidebar.text_input("Twitter handle:", "huggingface")
|
73 |
twitter_count = st.sidebar.selectbox("Number of tweets:", (10, 100, 500, 1000, 3200))
|
74 |
|
75 |
|
|
|
132 |
st.plotly_chart(fig)
|
133 |
|
134 |
# tweet sample
|
135 |
+
st.markdown(df.sample(n=5).to_markdown())
|