NazmusAshrafi commited on
Commit
6e011da
1 Parent(s): ebb742b

Added prediction system

Browse files
Files changed (2) hide show
  1. app.py +21 -5
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,15 +1,31 @@
1
  import streamlit as st
2
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
3
 
4
- tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
5
 
6
- pulled_model = AutoModelForSequenceClassification.from_pretrained(
7
- "NazmusAshrafi/stock_twitter_sentiment_Bert")
 
 
 
 
 
 
 
 
8
 
9
  classifier = pipeline("sentiment-analysis",
10
- model=pulled_model, tokenizer=tokenizer)
11
 
12
 
13
- print(classifier("AAP Up Theory = Will go up in future, buy now"))
14
 
15
  st.title("Topic Modeling and Sentiment Analysis of Stock Tweets")
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
3
 
 
4
 
5
+ @st.cache(allow_output_mutation=True)
6
+ def get_model():
7
+ tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
8
+ pulled_model = AutoModelForSequenceClassification.from_pretrained(
9
+ "NazmusAshrafi/stock_twitter_sentiment_Bert")
10
+ return tokenizer, pulled_model
11
+
12
+
13
+ tokenizer, model = get_model()
14
+
15
 
16
  classifier = pipeline("sentiment-analysis",
17
+ model=model, tokenizer=tokenizer)
18
 
19
 
20
+ # print(classifier("AAP Up Theory = Will go up in future, buy now"))
21
 
22
  st.title("Topic Modeling and Sentiment Analysis of Stock Tweets")
23
+
24
+ user_input = st.text_area("Enter a tweet about a stock")
25
+ button = st.button("Analyze")
26
+
27
+
28
+ if user_input and button:
29
+ # output
30
+ classifier("AAP Up Theory = Will go up in future, buy now")
31
+ st.write("Raw Pred: ", classifier(user_input))
requirements.txt CHANGED
@@ -1,2 +1,3 @@
 
1
  transformers
2
  torch
 
1
+ streamlit
2
  transformers
3
  torch